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
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace DiskDevice {
|
||||
class KDiskDeviceJob;
|
||||
class KPartition;
|
||||
|
||||
/// \brief Common ancestor for disk system add-on wrappers
|
||||
class KDiskSystem {
|
||||
public:
|
||||
KDiskSystem(const char *name);
|
||||
|
||||
@@ -13,6 +13,7 @@ struct file_system_module_info;
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
/// \brief Wrapper for the C interface of a filesystem add-on.
|
||||
class KFileSystem : public KDiskSystem {
|
||||
public:
|
||||
KFileSystem(const char *name);
|
||||
|
||||
@@ -21,6 +21,7 @@ class KPath;
|
||||
class KPhysicalPartition;
|
||||
class KShadowPartition;
|
||||
|
||||
/// \brief Class representing a single partition.
|
||||
class KPartition {
|
||||
public:
|
||||
KPartition(partition_id id = -1);
|
||||
|
||||
@@ -10,6 +10,11 @@ struct partition_module_info;
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
/**
|
||||
* \brief Wrapper for the C interface of a partitioning system add-on.
|
||||
*
|
||||
* See \ref ddm_modules.h for better description of the interface.
|
||||
*/
|
||||
class KPartitioningSystem : public KDiskSystem {
|
||||
public:
|
||||
KPartitioningSystem(const char *name);
|
||||
@@ -19,7 +24,9 @@ public:
|
||||
|
||||
// Scanning
|
||||
|
||||
/// Try to identify a given partition
|
||||
virtual float Identify(KPartition *partition, void **cookie);
|
||||
/// Scan the partition
|
||||
virtual status_t Scan(KPartition *partition, void *cookie);
|
||||
virtual void FreeIdentifyCookie(KPartition *partition, void *cookie);
|
||||
virtual void FreeCookie(KPartition *partition);
|
||||
@@ -27,88 +34,132 @@ public:
|
||||
|
||||
// Querying
|
||||
|
||||
/// Check whether the add-on supports repairing this partition.
|
||||
virtual bool SupportsRepairing(KPartition *partition, bool checkOnly,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports resizing this partition.
|
||||
virtual bool SupportsResizing(KPartition *partition, bool *whileMounted);
|
||||
/// Check whether the add-on supports resizing children of this partition.
|
||||
virtual bool SupportsResizingChild(KPartition *child);
|
||||
/// Check whether the add-on supports moving this partition.
|
||||
virtual bool SupportsMoving(KPartition *partition, bool *isNoOp);
|
||||
/// Check whether the add-on supports moving children of this partition.
|
||||
virtual bool SupportsMovingChild(KPartition *child);
|
||||
/// Check whether the add-on supports setting name of this partition.
|
||||
virtual bool SupportsSettingName(KPartition *partition);
|
||||
/// Check whether the add-on supports setting name to content of this partition.
|
||||
virtual bool SupportsSettingContentName(KPartition *partition,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports setting type of this partition.
|
||||
virtual bool SupportsSettingType(KPartition *partition);
|
||||
/// Check whether the add-on supports setting parameters of this partition.
|
||||
virtual bool SupportsSettingParameters(KPartition *partition);
|
||||
/// Check whether the add-on supports setting parameters to content of this partition.
|
||||
virtual bool SupportsSettingContentParameters(KPartition *partition,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports initializing this partition.
|
||||
virtual bool SupportsInitializing(KPartition *partition);
|
||||
/// Check whether the add-on supports initializing a child of this partition.
|
||||
virtual bool SupportsInitializingChild(KPartition *child,
|
||||
const char *diskSystem);
|
||||
/// Check whether the add-on supports creating children of this partition.
|
||||
virtual bool SupportsCreatingChild(KPartition *partition);
|
||||
/// Check whether the add-on supports deleting children of this partition.
|
||||
virtual bool SupportsDeletingChild(KPartition *child);
|
||||
/// Check whether the add-on is a subsystem for a given partition.
|
||||
virtual bool IsSubSystemFor(KPartition *partition);
|
||||
|
||||
/// Validates parameters for resizing a partition
|
||||
virtual bool ValidateResize(KPartition *partition, off_t *size);
|
||||
/// Validates parameters for resizing a child partition
|
||||
virtual bool ValidateResizeChild(KPartition *child, off_t *size);
|
||||
/// Validates parameters for moving a partition
|
||||
virtual bool ValidateMove(KPartition *partition, off_t *start);
|
||||
/// Validates parameters for moving a child partition
|
||||
virtual bool ValidateMoveChild(KPartition *child, off_t *start);
|
||||
/// Validates parameters for setting name of a partition
|
||||
virtual bool ValidateSetName(KPartition *partition, char *name);
|
||||
/// Validates parameters for setting name to content of a partition
|
||||
virtual bool ValidateSetContentName(KPartition *partition, char *name);
|
||||
/// Validates parameters for setting type of a partition
|
||||
virtual bool ValidateSetType(KPartition *partition, const char *type);
|
||||
/// Validates parameters for setting parameters of a partition
|
||||
virtual bool ValidateSetParameters(KPartition *partition,
|
||||
const char *parameters);
|
||||
/// Validates parameters for setting parameters to content of a partition
|
||||
virtual bool ValidateSetContentParameters(KPartition *parameters,
|
||||
const char *parameters);
|
||||
/// Validates parameters for initializing a partition
|
||||
virtual bool ValidateInitialize(KPartition *partition, char *name,
|
||||
const char *parameters);
|
||||
/// Validates parameters for creating child of a partition
|
||||
virtual bool ValidateCreateChild(KPartition *partition, off_t *start,
|
||||
off_t *size, const char *type,
|
||||
const char *parameters, int32 *index);
|
||||
/// Counts partitionable spaces on a partition
|
||||
virtual int32 CountPartitionableSpaces(KPartition *partition);
|
||||
/// Retrieves a list of partitionable spaces on a partition
|
||||
virtual status_t GetPartitionableSpaces(KPartition *partition,
|
||||
partitionable_space_data *buffer,
|
||||
int32 count,
|
||||
int32 *actualCount = NULL);
|
||||
|
||||
/// Iterates through supported partition types
|
||||
virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie,
|
||||
char *type);
|
||||
/// Translates the "pretty" content type to an internal type
|
||||
virtual status_t GetTypeForContentType(const char *contentType,
|
||||
char *type);
|
||||
|
||||
// Shadow partition modification
|
||||
|
||||
/// Calls for additional modifications when shadow partition is changed
|
||||
virtual status_t ShadowPartitionChanged(KPartition *partition,
|
||||
uint32 operation);
|
||||
|
||||
// Writing
|
||||
|
||||
/// Repairs a partition
|
||||
virtual status_t Repair(KPartition *partition, bool checkOnly,
|
||||
KDiskDeviceJob *job);
|
||||
/// Resizes a partition
|
||||
virtual status_t Resize(KPartition *partition, off_t size,
|
||||
KDiskDeviceJob *job);
|
||||
/// Resizes child of a partition
|
||||
virtual status_t ResizeChild(KPartition *child, off_t size,
|
||||
KDiskDeviceJob *job);
|
||||
/// Moves a partition
|
||||
virtual status_t Move(KPartition *partition, off_t offset,
|
||||
KDiskDeviceJob *job);
|
||||
/// Moves child of a partition
|
||||
virtual status_t MoveChild(KPartition *child, off_t offset,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets name to a partition
|
||||
virtual status_t SetName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets name to content of a partition
|
||||
virtual status_t SetContentName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets type of a partition
|
||||
virtual status_t SetType(KPartition *partition, char *type,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets parameters of a partition
|
||||
virtual status_t SetParameters(KPartition *partition,
|
||||
const char *parameters,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets parameters to content of a partition
|
||||
virtual status_t SetContentParameters(KPartition *partition,
|
||||
const char *parameters,
|
||||
KDiskDeviceJob *job);
|
||||
/// Creates a child partition
|
||||
virtual status_t CreateChild(KPartition *partition, off_t offset,
|
||||
off_t size, const char *type,
|
||||
const char *parameters, KDiskDeviceJob *job,
|
||||
KPartition **child = NULL,
|
||||
partition_id childID = -1);
|
||||
/// Deletes a child partition
|
||||
virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job);
|
||||
/// Initializes a partition with this partitioning system
|
||||
virtual status_t Initialize(KPartition *partition, const char *name,
|
||||
const char *parameters, KDiskDeviceJob *job);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class KDiskDevice;
|
||||
class KDiskSystem;
|
||||
class KShadowPartition;
|
||||
|
||||
/// \brief Class representing an existing partition.
|
||||
class KPhysicalPartition : public KPartition {
|
||||
public:
|
||||
KPhysicalPartition(partition_id id = -1);
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace DiskDevice {
|
||||
|
||||
class KPhysicalPartition;
|
||||
|
||||
/// \brief Class representing a shadow of an existing partition.
|
||||
///
|
||||
/// See \ref path_kernel_structures for more information.
|
||||
class KShadowPartition : public KPartition, private KPartitionListener {
|
||||
public:
|
||||
KShadowPartition(KPhysicalPartition *physicalPartition);
|
||||
|
||||
Reference in New Issue
Block a user