Addition of write support to the disk device manager. Courtesy of Tomas
Kucera and Jan Matejek. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21719 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#define _K_DISK_DEVICE_JOB_H
|
||||
|
||||
#include "disk_device_manager.h"
|
||||
#include <KPartitionVisitor.h>
|
||||
|
||||
struct user_disk_device_job_info;
|
||||
|
||||
@@ -12,19 +13,41 @@ namespace DiskDevice {
|
||||
|
||||
class KDiskDeviceJobQueue;
|
||||
|
||||
/**
|
||||
* Represents some action executed on the disk device.
|
||||
*
|
||||
* -
|
||||
*/
|
||||
class KDiskDeviceJob {
|
||||
public:
|
||||
/**
|
||||
* Creates a new job
|
||||
*
|
||||
* \param type actual type of the job (see DiskDeviceDefs.h for details)
|
||||
* \param partitionID the partition/device on which the action should be executed
|
||||
* \param scopeID partition/device which is the highest in the hierarchy (i.e. closest
|
||||
* to the root) that can be affected by the action
|
||||
* - every descendant of this partition is marked busy and all ancestors are marked descendant-
|
||||
busy
|
||||
*/
|
||||
KDiskDeviceJob(uint32 type, partition_id partitionID,
|
||||
partition_id scopeID = -1);
|
||||
virtual ~KDiskDeviceJob();
|
||||
|
||||
/**
|
||||
* Unique identification of the job
|
||||
*/
|
||||
disk_job_id ID() const;
|
||||
|
||||
void SetJobQueue(KDiskDeviceJobQueue *queue);
|
||||
KDiskDeviceJobQueue *JobQueue() const;
|
||||
|
||||
/**
|
||||
* Gets actual type of the action
|
||||
*/
|
||||
uint32 Type() const;
|
||||
|
||||
|
||||
void SetStatus(uint32 status);
|
||||
uint32 Status() const;
|
||||
|
||||
@@ -54,9 +77,25 @@ public:
|
||||
// triggers a notification
|
||||
float Progress() const;
|
||||
|
||||
|
||||
status_t GetInfo(user_disk_device_job_info *info);
|
||||
status_t GetProgressInfo(disk_device_job_progress_info *info);
|
||||
|
||||
/**
|
||||
* Do the actual work of the job.
|
||||
*
|
||||
* - is supposed to be implemented in descendants
|
||||
* - doesn't have any parameter - every operation needs different ones -> they're passed
|
||||
* to the constructor
|
||||
* - the implementations will
|
||||
* - check the parameters given in constructor (e.g. if given partition exists...)
|
||||
* - check whether the partition has needed disk system (its own or parent - depends
|
||||
* on the operation)
|
||||
* - using the disk system, validate the operation for given params
|
||||
* - finally execute the action
|
||||
*
|
||||
* \return B_OK when everything went OK, some error otherwise
|
||||
*/
|
||||
virtual status_t Do() = 0;
|
||||
|
||||
private:
|
||||
@@ -76,6 +115,29 @@ private:
|
||||
float fProgress;
|
||||
|
||||
static disk_job_id fNextID;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Visitor which checks if every descendant of given partition is busy or descendant-busy
|
||||
*/
|
||||
struct IsNotBusyVisitor : KPartitionVisitor {
|
||||
virtual bool VisitPre(KPartition * partition);
|
||||
};
|
||||
IsNotBusyVisitor fNotBusyVisitor;
|
||||
|
||||
protected:
|
||||
//some stuff useful for all descendants
|
||||
|
||||
/**
|
||||
* Checks if there's any descendant which is not busy/descendant-busy.
|
||||
*
|
||||
* - the condition of busy descendant is common for many disk device operations ->
|
||||
* many jobs can use this
|
||||
*
|
||||
* \param partition the root of checked subtree of the whole partition hieararchy
|
||||
*/
|
||||
bool isPartitionNotBusy( KPartition * partition );
|
||||
|
||||
};
|
||||
|
||||
} // namespace DiskDevice
|
||||
|
||||
Reference in New Issue
Block a user