DiskDevice API v2.2.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3375 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,17 +8,19 @@
|
||||
|
||||
class BDiskDevice : public BPartition {
|
||||
public:
|
||||
void Unset(); // What is this for?
|
||||
|
||||
char* DeviceType() const;
|
||||
virtual char* Path() const;
|
||||
|
||||
bool IsRemovable() const;
|
||||
bool HasMedia() const;
|
||||
|
||||
status_t Eject(bool update = false);
|
||||
|
||||
status_t Update(bool *updated = NULL);
|
||||
void Unset();
|
||||
|
||||
bool IsModified() const;
|
||||
int32 CommitModifications(bool synchronously = true,
|
||||
BMessenger progressMessenger = BMessenger(),
|
||||
BMessage *template = NULL);
|
||||
private:
|
||||
friend class BDiskDeviceList;
|
||||
friend class BDiskDeviceRoster;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#ifndef _DISK_DEVICE_JOB_H
|
||||
#define _DISK_DEVICE_JOB_H
|
||||
|
||||
// disk device job types
|
||||
enum {
|
||||
B_DISK_DEVICE_JOB_CREATE,
|
||||
B_DISK_DEVICE_JOB_DELETE,
|
||||
B_DISK_DEVICE_JOB_INITIALIZE,
|
||||
B_DISK_DEVICE_JOB_RESIZE,
|
||||
B_DISK_DEVICE_JOB_MOVE,
|
||||
B_DISK_DEVICE_JOB_DEFRAGMENT,
|
||||
B_DISK_DEVICE_JOB_REPAIR,
|
||||
}
|
||||
|
||||
class BDiskDeviceJob {
|
||||
public:
|
||||
int32 ID() const;
|
||||
uint32 Type() const;
|
||||
uint8 Progress() const; // 0 to 100
|
||||
bool Finished() const;
|
||||
const char *Description() const;
|
||||
|
||||
BPartition* Partition() const;
|
||||
private:
|
||||
int32 fPartitionID;
|
||||
int32 fJobID;
|
||||
};
|
||||
|
||||
#endif // _DISK_DEVICE_JOB_H
|
||||
@@ -45,9 +45,12 @@ public:
|
||||
virtual void MountPointMoved(BPartition *partition);
|
||||
virtual void PartitionMounted(BPartition *partition);
|
||||
virtual void PartitionUnmounted(BPartition *partition);
|
||||
virtual void PartitionChanged(BPartition *partition);
|
||||
virtual void PartitionAdded(BPartition *partition);
|
||||
virtual void PartitionRemoved(BPartition *partition);
|
||||
virtual void PartitionResized(BPartition *partition);
|
||||
virtual void PartitionMoved(BPartition *partition);
|
||||
virtual void PartitionCreated(BPartition *partition);
|
||||
virtual void PartitionDeleted(BPartition *partition);
|
||||
virtual void PartitionDefragmented(BPartition *partition);
|
||||
virtual void PartitionRepaired(BPartition *partition);
|
||||
virtual void MediaChanged(BDiskDevice *device);
|
||||
virtual void DeviceAdded(BDiskDevice *device);
|
||||
virtual void DeviceRemoved(BDiskDevice *device);
|
||||
@@ -56,9 +59,13 @@ private:
|
||||
void _MountPointMoved(BMessage *message);
|
||||
void _PartitionMounted(BMessage *message);
|
||||
void _PartitionUnmounted(BMessage *message);
|
||||
void _PartitionChanged(BMessage *message);
|
||||
void _PartitionAdded(BMessage *message);
|
||||
void _PartitionRemoved(BMessage *message);
|
||||
void _PartitionInitialized(BMessage *message);
|
||||
void _PartitionResized(BMessage *message);
|
||||
void _PartitionMoved(BMessage *message);
|
||||
void _PartitionCreated(BMessage *message);
|
||||
void _PartitionDeleted(BMessage *message);
|
||||
void _PartitionDefragmented(BMessage *message);
|
||||
void _PartitionRepaired(BMessage *message);
|
||||
void _MediaChanged(BMessage *message);
|
||||
void _DeviceAdded(BMessage *message);
|
||||
void _DeviceRemoved(BMessage *message);
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
|
||||
class BDirectory;
|
||||
class BDiskDevice;
|
||||
class BDiskDeviceJob;
|
||||
class BDiskScannerPartitionAddOn;
|
||||
class BDiskSystem;
|
||||
class BPartition;
|
||||
class BSession;
|
||||
|
||||
@@ -29,6 +31,7 @@ enum {
|
||||
B_DEVICE_REQUEST_PARTITION = 0x04, // partition changes
|
||||
B_DEVICE_REQUEST_DEVICE = 0x10, // device changes (media changes)
|
||||
B_DEVICE_REQUEST_DEVICE_LIST = 0x20, // device additions/removals
|
||||
B_DEVICE_REQUEST_JOBS = 0x40, // job addition/initiation/completion
|
||||
B_DEVICE_REQUEST_ALL = 0xff, // all events
|
||||
};
|
||||
|
||||
@@ -43,22 +46,28 @@ enum {
|
||||
B_DEVICE_MOUNT_POINT_MOVED, // mount point moved/renamed
|
||||
B_DEVICE_PARTITION_MOUNTED, // partition mounted
|
||||
B_DEVICE_PARTITION_UNMOUNTED, // partition unmounted
|
||||
B_DEVICE_PARTITION_CHANGED, // partition changed, e.g. initialized
|
||||
// or resized or moved
|
||||
B_DEVICE_PARTITION_ADDED, // partition added
|
||||
B_DEVICE_PARTITION_REMOVED, // partition removed
|
||||
B_DEVICE_PARTITION_INITIALIZED, // partition initialized
|
||||
B_DEVICE_PARTITION_RESIZED, // partition resized
|
||||
B_DEVICE_PARTITION_MOVED, // partition moved
|
||||
B_DEVICE_PARTITION_CREATED, // partition created
|
||||
B_DEVICE_PARTITION_DELETED, // partition deleted
|
||||
B_DEVICE_PARTITION_DEFRAGMENTED, // partition defragmented
|
||||
B_DEVICE_PARTITION_REPAIRED, // partition repaired
|
||||
B_DEVICE_MEDIA_CHANGED, // media changed
|
||||
B_DEVICE_ADDED, // device added
|
||||
B_DEVICE_REMOVED // device removed
|
||||
B_DEVICE_REMOVED, // device removed
|
||||
B_DEVICE_JOB_ADDED, // job added
|
||||
B_DEVICE_JOB_INITIATED, // job initiated
|
||||
B_DEVICE_JOB_FINISHED, // job finished
|
||||
};
|
||||
|
||||
// notification message "cause" field values
|
||||
enum {
|
||||
// helpful causes
|
||||
B_DEVICE_CAUSE_MEDIA_CHANGED,
|
||||
B_DEVICE_CAUSE_FORMATTED,
|
||||
B_DEVICE_CAUSE_PARTITIONED,
|
||||
B_DEVICE_CAUSE_INITIALIZED,
|
||||
B_DEVICE_CAUSE_FORMATTED, // is this still applicable?
|
||||
B_DEVICE_CAUSE_PARTITIONED, // is this still applicable?
|
||||
B_DEVICE_CAUSE_INITIALIZED, // is this still applicable?
|
||||
// unknown cause
|
||||
B_DEVICE_CAUSE_UNKNOWN,
|
||||
// for internal use only (e.g.: partition added, because device added)
|
||||
@@ -69,16 +78,22 @@ class BDiskDeviceRoster {
|
||||
public:
|
||||
BDiskDeviceRoster();
|
||||
~BDiskDeviceRoster();
|
||||
|
||||
|
||||
status_t GetNextDevice(BDiskDevice *device);
|
||||
status_t Rewind();
|
||||
status_t RewindDevices();
|
||||
|
||||
status_t GetNextDiskSystem(BDiskSystem *system);
|
||||
status_t RewindDiskSystems();
|
||||
|
||||
status_t GetNextActiveJob(BDiskDeviceJob *job);
|
||||
status_t RewindActiveJobs();
|
||||
|
||||
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL);
|
||||
bool VisitEachPartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BPartition **partition = NULL);
|
||||
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||
bool VisitAll(BDiskDeviceVisitor *visitor);
|
||||
|
||||
bool VisitEachMountedPartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
@@ -92,7 +107,8 @@ public:
|
||||
bool VisitEachPartitionablePartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BPartition **partition = NULL);
|
||||
|
||||
|
||||
// Do we want visit functions for disk systems and/or jobs?
|
||||
|
||||
status_t GetDeviceWithID(int32 id, BDiskDevice *device) const;
|
||||
status_t GetPartitionWithID(int32 id, BDiskDevice *device,
|
||||
@@ -102,12 +118,6 @@ public:
|
||||
uint32 eventMask = B_DEVICE_REQUEST_ALL);
|
||||
status_t StopWatching(BMessenger target);
|
||||
|
||||
// partition and FS add-ons
|
||||
status_t GetNextPartitioningSystem(char *shortName, char *longName = NULL);
|
||||
status_t GetNextFileSystem(char *shortName, char *longName = NULL);
|
||||
status_t RewindPartitiningSystems();
|
||||
status_t RewindFileSystems();
|
||||
|
||||
private:
|
||||
status_t _GetObjectWithID(const char *fieldName, int32 id,
|
||||
BDiskDevice *device) const;
|
||||
|
||||
@@ -8,30 +8,31 @@
|
||||
|
||||
// Device Types
|
||||
|
||||
#define B_DEVICE_TYPE_FLOPPY_DISK "Floppy Disk Media";
|
||||
#define B_DEVICE_TYPE_HARD_DISK "Hard Disk Media";
|
||||
#define B_DEVICE_TYPE_CD "CD-ROM Media";
|
||||
#define B_DEVICE_TYPE_DVD "DVD-ROM Media";
|
||||
const char *kDeviceTypeFloppyDisk = "Floppy Disk Media";
|
||||
const char *kDeviceTypeHardDisk = "Hard Disk Media";
|
||||
const char *kDeviceTypeOptical = "Optical Media";
|
||||
|
||||
// Partition types
|
||||
|
||||
#define B_PARTITION_TYPE_UNFORMATTED "Unformatted";
|
||||
const char *kPartitionTypeUnrecognized = "Unrecognized";
|
||||
|
||||
#define B_PARTITION_TYPE_MULTISESSION "Multisession Storage Device";
|
||||
const char *kPartitionTypeMultisession = "Multisession Storage Device";
|
||||
|
||||
#define B_PARTITION_TYPE_CD_AUDIO "Compact Disc Audio Session";
|
||||
const char *kPartitionTypeCDDA = "Compact Disc Audio Session";
|
||||
|
||||
#define B_PARTITION_TYPE_APPLE "Apple Partition Map";
|
||||
#define B_PARTITION_TYPE_INTEL "Intel Partition Map";
|
||||
#define B_PARTITION_TYPE_INTEL_EXTENDED "Intel Extended Partition";
|
||||
const char *kPartitionTypeAmiga = "Amiga Partition Map";
|
||||
const char *kPartitionTypeApple = "Apple Partition Map";
|
||||
const char *kPartitionTypeIntel = "Intel Partition Map";
|
||||
const char *kPartitionTypeIntelExtended = "Intel Extended Partition";
|
||||
|
||||
#define B_PARTITION_TYPE_BFS "BFS Filesystem";
|
||||
#define B_PARTITION_TYPE_EXT2 "EXT2 Filesystem";
|
||||
#define B_PARTITION_TYPE_EXT3 "EXT3 Filesystem";
|
||||
#define B_PARTITION_TYPE_FAT12 "FAT12 Filesystem";
|
||||
#define B_PARTITION_TYPE_FAT32 "FAT32 Filesystem";
|
||||
#define B_PARTITION_TYPE_ISO9660 "ISO9660 Filesystem";
|
||||
#define B_PARTITION_TYPE_REISER "Reiser Filesystem";
|
||||
#define B_PARTITION_TYPE_UDF "UDF Filesystem";
|
||||
const char *kPartitionTypeAmigaFFS = "AmigaFFS Filesystem";
|
||||
const char *kPartitionTypeBFS = "BFS Filesystem";
|
||||
const char *kPartitionTypeEXT2 = "EXT2 Filesystem";
|
||||
const char *kPartitionTypeEXT3 = "EXT3 Filesystem";
|
||||
const char *kPartitionTypeFAT12 = "FAT12 Filesystem";
|
||||
const char *kPartitionTypeFAT32 = "FAT32 Filesystem";
|
||||
const char *kPartitionTypeISO9660 = "ISO9660 Filesystem";
|
||||
const char *kPartitionTypeReiser = "Reiser Filesystem";
|
||||
const char *kPartitionTypeUDF = "UDF Filesystem";
|
||||
|
||||
#endif // _DISK_DEVICE_TYPES_H
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
class BDiskDevice;
|
||||
class BPartition;
|
||||
class BSession;
|
||||
|
||||
// BDiskDeviceVisitor
|
||||
class BDiskDeviceVisitor {
|
||||
@@ -18,7 +17,6 @@ public:
|
||||
|
||||
// return true to abort iteration
|
||||
virtual bool Visit(BDiskDevice *device);
|
||||
virtual bool Visit(BSession *session);
|
||||
virtual bool Visit(BPartition *partition);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#ifndef _DISK_SYSTEM_H
|
||||
#define _DISK_SYSTEM_H
|
||||
|
||||
class BDiskSystem {
|
||||
public:
|
||||
const char *Name() const;
|
||||
|
||||
bool SupportsDefragmenting(BPartition *partition) const;
|
||||
bool SupportsRepairing(BPartition *partition, bool checkOnly) const;
|
||||
bool SupportsResizing(BPartition *partition) const;
|
||||
bool SupportsResizingChild(BPartition *child) const;
|
||||
bool SupportsMoving(BPartition *partition) const;
|
||||
bool SupportsMovingChild(BPartition *child) const;
|
||||
bool SupportsParentSystem(const char *system) const;
|
||||
// True in most cases. NULL == raw device.
|
||||
bool SupportsChildSystem(const char *system) const;
|
||||
// False for most file systems, true for most partitioning
|
||||
// systems.
|
||||
|
||||
bool ValidateResize(BPartition *partition, off_t *size) const;
|
||||
bool ValidateMove(BPartition *partition, off_t *start) const;
|
||||
bool ValidateResizeChild(BPartition *partition, off_t *size) const;
|
||||
bool ValidateMoveChild(BPartition *partition, off_t *start) const;
|
||||
bool ValidateCreateChild(BPartition *partition, off_t *start, off_t *size) const;
|
||||
bool ValidateInitialize(BPartition *partition) const;
|
||||
|
||||
bool IsPartitioningSystem() const;
|
||||
bool IsFileSystem() const;
|
||||
};
|
||||
|
||||
#endif // _DISK_SYSTEM_H
|
||||
@@ -8,78 +8,102 @@
|
||||
|
||||
#include <ObjectList.h>
|
||||
|
||||
class BDiskDevice;
|
||||
|
||||
// partition statuses
|
||||
enum {
|
||||
B_PARTITION_VALID,
|
||||
B_PARTITION_CORRUPT,
|
||||
B_PARTITION_UNRECOGNIZED,
|
||||
}
|
||||
|
||||
class BPartition {
|
||||
public:
|
||||
// General Info
|
||||
// Partition Info
|
||||
|
||||
off_t Offset() const; // 0 for devices
|
||||
off_t Size() const;
|
||||
int32 BlockSize() const;
|
||||
int32 Index() const; // 0 for devices
|
||||
uint32 Status() const;
|
||||
|
||||
bool IsMountable();
|
||||
bool IsPartitionable();
|
||||
bool IsDevice();
|
||||
bool IsMountable() const;
|
||||
bool IsPartitionable() const;
|
||||
|
||||
bool IsDevice() const;
|
||||
bool IsReadOnly() const;
|
||||
bool IsMounted() const;
|
||||
|
||||
const char* Name() const;
|
||||
const char* Type() const; // See DiskDeviceTypes.h
|
||||
int32 UniqueID() const;
|
||||
virtual char* Path() const; // Recursively obtained down to the parent device
|
||||
|
||||
uint32 Flags() const; // not sure if this is really necessary anymore
|
||||
uint32 Flags() const;
|
||||
|
||||
status_t GetPath(BPath *path) const;
|
||||
status_t GetVolume(BVolume *volume) const;
|
||||
status_t GetIcon(BBitmap *icon, icon_size which) const;
|
||||
|
||||
status_t Mount(uint32 mountFlags = 0, const char *parameters = NULL);
|
||||
status_t Unmount();
|
||||
|
||||
// Hierarchy Info
|
||||
|
||||
const BPartition* Parent();
|
||||
BPartition* PartitionAt(int32 index) const;
|
||||
BPartition* PartitionWithID(int32 id);
|
||||
BDiskDevice* Device() const;
|
||||
BPartition* Parent() const;
|
||||
BPartition* ChildAt(int32 index) const;
|
||||
int32 CountChildren() const;
|
||||
|
||||
int32 CountChildren() const; // Immediate descendents
|
||||
int32 CountDescendents() const; // All descendents
|
||||
BPartitionableSpace* PartitionableSpaceAt(int32 index) const;
|
||||
int32 CountPartitionableSpaces() const;
|
||||
|
||||
BPartition* VisitEachChild(BDiskDeviceVisitor *visitor);
|
||||
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||
BPartition* VisitSubtree(BDiskDeviceVisitor *visitor);
|
||||
|
||||
// Self Modification
|
||||
|
||||
// Functions relevant to manipulating *this* partition
|
||||
|
||||
off_t MinimumSize();
|
||||
off_t MaximumSize();
|
||||
// Both based on information obtained from the system used for the
|
||||
// partition and the partitioning system used for its parent
|
||||
|
||||
int32 MoveTo(off_t start, BMessenger progressMessenger);
|
||||
int32 Resize(off_t size, BMessenger progressMessenger);
|
||||
bool IsLocked() const;
|
||||
status_t Lock(); // to be non-blocking
|
||||
status_t Unlock();
|
||||
|
||||
status_t GetParameterEditor(BDiskScannerParameterEditor **editor,
|
||||
BDiskScannerParameterEditor **parentEditor);
|
||||
// For changing parameters of the partition after it's been initialized,
|
||||
// i.e. file system block size, volume name, etc. "editor" is an editor
|
||||
// for the system with which this partition is initialized, "parentEditor"
|
||||
// is an editor for any settings the parent partitioning system may
|
||||
// allow to be edited ("*parentEditor" will be set to NULL if not
|
||||
// applicable).
|
||||
bool CanDefragment() const;
|
||||
status_t Defragment() const;
|
||||
|
||||
bool CanRepair(bool checkOnly) const;
|
||||
status_t Repair(bool checkOnly) const;
|
||||
|
||||
status_t GetInitializationParameterEditor(const char *system,
|
||||
BDiskScannerParameterEditor **editor);
|
||||
int32 Initialize(const char *system,
|
||||
const char *parameters,
|
||||
BMessenger progressMessenger);
|
||||
// Initialization is used to set up a partition with either
|
||||
// an empty file system or an empty partitioning system
|
||||
bool CanResize() const;
|
||||
bool CanResizeWhileMounted() const;
|
||||
status_t ValidateResize(off_t*) const;
|
||||
status_t Resize(off_t);
|
||||
|
||||
bool CanMove() const;
|
||||
status_t ValidateMove(off_t*) const;
|
||||
status_t Move(off_t);
|
||||
|
||||
// Functions relevant to manipluating *child* partitions
|
||||
bool CanEditParameters() const;
|
||||
status_t GetParameterEditor(
|
||||
BDiskScannerParameterEditor **editor,
|
||||
BDiskScannerParameterEditor **parentEditor);
|
||||
status_t ValidateSetParameters(const char **parameters) const;
|
||||
status_t SetParameters(const char *parameters);
|
||||
|
||||
status_t GetPartitionCreationParameterEditor(BDiskScannerParameterEditor **editor);
|
||||
int32 CreateChildPartition(off_t start,
|
||||
off_t length,
|
||||
const char *parameters,
|
||||
BMessenger progressMessenger);
|
||||
int32 DeleteChildPartition(int32 index,
|
||||
BMessenger progressMessenger);
|
||||
bool CanInitialize() const;
|
||||
status_t GetInitializationParameterEditor(const char *system,
|
||||
BDiskScannerParameterEditor **editor) const;
|
||||
status_t ValidateInitialize(const char *diskSystem, const char **parameters) const;
|
||||
status_t Initialize(const char *diskSystem,
|
||||
const char *parameters);
|
||||
|
||||
// Modification of child partitions
|
||||
|
||||
bool CanCreateChild() const;
|
||||
status_t ValidateCreateChild(
|
||||
off_t *start,
|
||||
off_t *size) const;
|
||||
status_t CreateChild(off_t start, off_t size);
|
||||
|
||||
bool CanDeleteChild(int32 index) const;
|
||||
status_t DeleteChild();
|
||||
|
||||
protected:
|
||||
BObjectList<BPartition> fChildren;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#ifndef _PARTITIONABLE_SPACE_H
|
||||
#define _PARTITIONABLE_SPACE_H
|
||||
|
||||
class BPartition;
|
||||
|
||||
class BPartitionableSpace {
|
||||
public:
|
||||
off_t Offset() const;
|
||||
off_t Size() const;
|
||||
int32 Index() const;
|
||||
|
||||
BPartition* Parent() const;
|
||||
};
|
||||
|
||||
#endif // _PARTITIONABLE_SPACE_H
|
||||
Reference in New Issue
Block a user