2 * Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2003, Tyler Akidau, haiku@akidau.net.
4 * Distributed under the terms of the MIT License.
11 #include <DiskDeviceDefs.h>
12 #include <Messenger.h>
18 class BPartitionParameterEditor
;
19 class BDiskDeviceVisitor
;
21 class BMutablePartition
;
22 template <class T
> class BObjectList
;
23 class BPartitioningInfo
;
26 struct user_partition_data
;
30 class DiskDeviceJobGenerator
;
37 off_t
Offset() const; // 0 for devices
39 off_t
ContentSize() const; // 0 if uninitialized
40 uint32
BlockSize() const;
41 int32
Index() const; // 0 for devices
42 uint32
Status() const;
44 bool ContainsFileSystem() const;
45 bool ContainsPartitioningSystem() const;
47 bool IsDevice() const;
48 bool IsReadOnly() const;
49 bool IsMounted() const;
54 const char* Name() const;
55 const char* ContentName() const;
56 const char* Type() const; // See DiskDeviceTypes.h
57 const char* ContentType() const; // See DiskDeviceTypes.h
58 partition_id
ID() const;
59 const char* Parameters() const;
60 const char* ContentParameters() const;
62 status_t
GetDiskSystem(BDiskSystem
* diskSystem
) const;
64 virtual status_t
GetPath(BPath
* path
) const;
65 status_t
GetVolume(BVolume
* volume
) const;
66 status_t
GetIcon(BBitmap
* icon
, icon_size which
) const;
67 status_t
GetIcon(uint8
** _data
, size_t* _size
,
68 type_code
* _type
) const;
69 status_t
GetMountPoint(BPath
* mountPoint
) const;
71 status_t
Mount(const char* mountPoint
= NULL
,
72 uint32 mountFlags
= 0,
73 const char* parameters
= NULL
);
74 status_t
Unmount(uint32 unmountFlags
= 0);
78 BDiskDevice
* Device() const;
79 BPartition
* Parent() const;
80 BPartition
* ChildAt(int32 index
) const;
81 int32
CountChildren() const;
82 int32
CountDescendants() const;
83 BPartition
* FindDescendant(partition_id id
) const;
85 status_t
GetPartitioningInfo(
86 BPartitioningInfo
* info
) const;
88 BPartition
* VisitEachChild(BDiskDeviceVisitor
* visitor
)
90 virtual BPartition
* VisitEachDescendant(
91 BDiskDeviceVisitor
* visitor
) const;
95 bool CanDefragment(bool* whileMounted
= NULL
) const;
96 status_t
Defragment() const;
98 bool CanRepair(bool checkOnly
,
99 bool* whileMounted
= NULL
) const;
100 status_t
Repair(bool checkOnly
) const;
102 bool CanResize(bool* canResizeContents
= NULL
,
103 bool* whileMounted
= NULL
) const;
104 status_t
ValidateResize(off_t
* size
) const;
105 status_t
Resize(off_t size
);
107 bool CanMove(BObjectList
<BPartition
>*
108 unmovableDescendants
= NULL
,
109 BObjectList
<BPartition
>*
110 movableOnlyIfUnmounted
= NULL
) const;
111 status_t
ValidateMove(off_t
* newOffset
) const;
112 status_t
Move(off_t newOffset
);
114 bool CanSetName() const;
115 status_t
ValidateSetName(BString
* name
) const;
116 // adjusts name to be suitable
117 status_t
SetName(const char* name
);
119 bool CanSetContentName(
120 bool* whileMounted
= NULL
) const;
121 status_t
ValidateSetContentName(BString
* name
) const;
122 // adjusts name to be suitable
123 status_t
SetContentName(const char* name
);
125 bool CanSetType() const;
126 status_t
ValidateSetType(const char* type
) const;
127 // type must be one the parent disk system's
128 // GetNextSupportedType() returns.
129 status_t
SetType(const char* type
);
131 bool CanEditParameters() const;
132 status_t
GetParameterEditor(
133 B_PARAMETER_EDITOR_TYPE type
,
134 BPartitionParameterEditor
** editor
);
135 status_t
SetParameters(const char* parameters
);
137 bool CanEditContentParameters(
138 bool* whileMounted
= NULL
) const;
139 status_t
SetContentParameters(const char* parameters
);
141 status_t
GetNextSupportedType(int32
*cookie
,
142 BString
* type
) const;
143 // Returns all partition types for this
144 // partition supported by the parent disk
146 status_t
GetNextSupportedChildType(int32
*cookie
,
147 BString
* type
) const;
148 // Returns all partition types for a child
149 // of this partition supported by its disk
151 bool IsSubSystem(const char* diskSystem
) const;
153 bool CanInitialize(const char* diskSystem
) const;
154 status_t
ValidateInitialize(const char* diskSystem
,
155 BString
* name
, const char* parameters
);
156 status_t
Initialize(const char* diskSystem
,
157 const char* name
, const char* parameters
);
158 status_t
Uninitialize();
160 // Modification of child partitions
162 bool CanCreateChild() const;
163 status_t
ValidateCreateChild(off_t
* start
, off_t
* size
,
164 const char* type
, BString
* name
,
165 const char* parameters
) const;
166 status_t
CreateChild(off_t start
, off_t size
,
167 const char* type
, const char* name
,
168 const char* parameters
,
169 BPartition
** child
= NULL
);
171 bool CanDeleteChild(int32 index
) const;
172 status_t
DeleteChild(int32 index
);
174 bool SupportsChildName() const;
180 BPartition(const BPartition
&);
181 virtual ~BPartition();
183 BPartition
& operator=(const BPartition
&);
185 status_t
_SetTo(BDiskDevice
* device
, BPartition
* parent
,
186 user_partition_data
* data
);
188 status_t
_RemoveObsoleteDescendants(
189 user_partition_data
* data
, bool* updated
);
190 status_t
_Update(user_partition_data
* data
,
192 void _RemoveChild(int32 index
);
194 BPartition
* _ChildAt(int32 index
) const;
195 int32
_CountChildren() const;
196 int32
_CountDescendants() const;
198 int32
_Level() const;
199 virtual bool _AcceptVisitor(BDiskDeviceVisitor
* visitor
,
201 BPartition
* _VisitEachDescendant(
202 BDiskDeviceVisitor
* visitor
,
205 const user_partition_data
* _PartitionData() const;
207 bool _HasContent() const;
208 bool _SupportsOperation(uint32 flag
,
209 uint32 whileMountedFlag
,
210 bool* whileMounted
) const;
211 bool _SupportsChildOperation(const BPartition
* child
,
214 status_t
_CreateDelegates();
215 status_t
_InitDelegates();
216 void _DeleteDelegates();
217 bool _IsModified() const;
219 friend class BDiskDevice
;
220 friend class BDiskSystem
;
221 friend class BMutablePartition
;
222 friend class BPrivate::DiskDeviceJobGenerator
;
224 BDiskDevice
* fDevice
;
226 user_partition_data
* fPartitionData
;
231 #endif // _PARTITION_H