1 // KDiskSystem.h 2 3 #ifndef _K_DISK_DEVICE_SYSTEM_H 4 #define _K_DISK_DEVICE_SYSTEM_H 5 6 #include "disk_device_manager.h" 7 8 struct user_disk_system_info; 9 10 namespace BPrivate { 11 namespace DiskDevice { 12 13 class KDiskDeviceJob; 14 class KPartition; 15 16 class KDiskSystem { 17 public: 18 KDiskSystem(const char *name); 19 virtual ~KDiskSystem(); 20 21 virtual status_t Init(); 22 23 // void SetID(disk_system_id id); 24 disk_system_id ID() const; 25 const char *Name() const; 26 const char *PrettyName(); 27 uint32 Flags() const; 28 29 bool IsFileSystem() const; 30 bool IsPartitioningSystem() const; 31 32 void GetInfo(user_disk_system_info *info); 33 34 // manager will be locked 35 status_t Load(); // load/unload -- can be nested 36 void Unload(); // 37 bool IsLoaded() const; 38 39 // Scanning 40 // Device must be write locked. 41 42 virtual float Identify(KPartition *partition, void **cookie); 43 virtual status_t Scan(KPartition *partition, void *cookie); 44 virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); 45 virtual void FreeCookie(KPartition *partition); 46 virtual void FreeContentCookie(KPartition *partition); 47 48 // Querying 49 // Device must be read locked. 50 51 virtual bool SupportsDefragmenting(KPartition *partition, 52 bool *whileMounted); 53 virtual bool SupportsRepairing(KPartition *partition, bool checkOnly, 54 bool *whileMounted); 55 virtual bool SupportsResizing(KPartition *partition, bool *whileMounted); 56 virtual bool SupportsResizingChild(KPartition *child); 57 virtual bool SupportsMoving(KPartition *partition, bool *isNoOp); 58 virtual bool SupportsMovingChild(KPartition *child); 59 virtual bool SupportsSettingName(KPartition *partition); 60 virtual bool SupportsSettingContentName(KPartition *partition, 61 bool *whileMounted); 62 virtual bool SupportsSettingType(KPartition *partition); 63 virtual bool SupportsSettingParameters(KPartition *partition); 64 virtual bool SupportsSettingContentParameters(KPartition *partition, 65 bool *whileMounted); 66 virtual bool SupportsInitializing(KPartition *partition); 67 virtual bool SupportsInitializingChild(KPartition *child, 68 const char *diskSystem); 69 virtual bool SupportsCreatingChild(KPartition *partition); 70 virtual bool SupportsDeletingChild(KPartition *child); 71 virtual bool IsSubSystemFor(KPartition *partition); 72 73 virtual bool ValidateResize(KPartition *partition, off_t *size); 74 virtual bool ValidateResizeChild(KPartition *child, off_t *size); 75 virtual bool ValidateMove(KPartition *partition, off_t *start); 76 virtual bool ValidateMoveChild(KPartition *child, off_t *start); 77 virtual bool ValidateSetName(KPartition *partition, char *name); 78 virtual bool ValidateSetContentName(KPartition *partition, char *name); 79 virtual bool ValidateSetType(KPartition *partition, const char *type); 80 virtual bool ValidateSetParameters(KPartition *partition, 81 const char *parameters); 82 virtual bool ValidateSetContentParameters(KPartition *parameters, 83 const char *parameters); 84 virtual bool ValidateInitialize(KPartition *partition, char *name, 85 const char *parameters); 86 virtual bool ValidateCreateChild(KPartition *partition, off_t *start, 87 off_t *size, const char *type, 88 const char *parameters, int32 *index); 89 virtual int32 CountPartitionableSpaces(KPartition *partition); 90 virtual status_t GetPartitionableSpaces(KPartition *partition, 91 partitionable_space_data *buffer, 92 int32 count, 93 int32 *actualCount = NULL); 94 95 virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie, 96 char *type); 97 virtual status_t GetTypeForContentType(const char *contentType, 98 char *type); 99 100 // Shadow partition modification 101 // Device must be write locked. 102 103 virtual status_t ShadowPartitionChanged(KPartition *partition, 104 uint32 operation); 105 106 // Writing 107 // Device should not be locked. 108 109 virtual status_t Defragment(KPartition *partition, KDiskDeviceJob *job); 110 virtual status_t Repair(KPartition *partition, bool checkOnly, 111 KDiskDeviceJob *job); 112 virtual status_t Resize(KPartition *partition, off_t size, 113 KDiskDeviceJob *job); 114 virtual status_t ResizeChild(KPartition *child, off_t size, 115 KDiskDeviceJob *job); 116 virtual status_t Move(KPartition *partition, off_t offset, 117 KDiskDeviceJob *job); 118 virtual status_t MoveChild(KPartition *child, off_t offset, 119 KDiskDeviceJob *job); 120 virtual status_t SetName(KPartition *partition, char *name, 121 KDiskDeviceJob *job); 122 virtual status_t SetContentName(KPartition *partition, char *name, 123 KDiskDeviceJob *job); 124 virtual status_t SetType(KPartition *partition, char *type, 125 KDiskDeviceJob *job); 126 virtual status_t SetParameters(KPartition *partition, 127 const char *parameters, 128 KDiskDeviceJob *job); 129 virtual status_t SetContentParameters(KPartition *partition, 130 const char *parameters, 131 KDiskDeviceJob *job); 132 virtual status_t Initialize(KPartition *partition, const char *name, 133 const char *parameters, KDiskDeviceJob *job); 134 virtual status_t CreateChild(KPartition *partition, off_t offset, 135 off_t size, const char *type, 136 const char *parameters, KDiskDeviceJob *job, 137 KPartition **child = NULL, 138 partition_id childID = -1); 139 virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); 140 // The KPartition* parameters for the writing methods are a bit `volatile', 141 // since the device will not be locked, when they are called. The KPartition 142 // is registered though, so that it is at least guaranteed that the object 143 // won't go away. 144 145 protected: 146 virtual status_t LoadModule(); 147 virtual void UnloadModule(); 148 149 status_t SetPrettyName(const char *name); 150 void SetFlags(uint32 flags); 151 152 static int32 _NextID(); 153 154 private: 155 disk_system_id fID; 156 char *fName; 157 char *fPrettyName; 158 uint32 fFlags; 159 int32 fLoadCounter; 160 161 static int32 fNextID; 162 }; 163 164 } // namespace DiskDevice 165 } // namespace BPrivate 166 167 using BPrivate::DiskDevice::KDiskSystem; 168 169 #endif // _K_DISK_DEVICE_SYSTEM_H 170