2003-02-01 01:05:09 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This software is part of the OpenBeOS distribution and is covered
|
|
|
|
// by the OpenBeOS license.
|
|
|
|
//---------------------------------------------------------------------
|
2003-02-01 00:17:20 +03:00
|
|
|
|
|
|
|
#ifndef _PARTITION_H
|
|
|
|
#define _PARTITION_H
|
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
#include <DiskDeviceDefs.h>
|
|
|
|
#include <Messenger.h>
|
|
|
|
#include <Mime.h>
|
2003-07-20 00:38:50 +04:00
|
|
|
#include <ObjectList.h>
|
2003-02-01 00:17:20 +03:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
class BBitmap;
|
2003-05-29 01:46:11 +04:00
|
|
|
class BDiskDevice;
|
2003-07-17 04:06:58 +04:00
|
|
|
class BDiskDeviceParameterEditor;
|
2003-07-07 03:11:10 +04:00
|
|
|
class BDiskDeviceVisitor;
|
|
|
|
class BDiskSystem;
|
2003-07-17 04:06:58 +04:00
|
|
|
class BPartitioningInfo;
|
2003-07-07 03:11:10 +04:00
|
|
|
class BVolume;
|
|
|
|
struct user_partition_data;
|
2003-05-29 01:46:11 +04:00
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
class BPartition {
|
|
|
|
public:
|
2003-05-29 01:46:11 +04:00
|
|
|
// Partition Info
|
2003-05-29 01:43:58 +04:00
|
|
|
|
|
|
|
off_t Offset() const; // 0 for devices
|
2003-02-01 00:17:20 +03:00
|
|
|
off_t Size() const;
|
2003-07-30 04:35:05 +04:00
|
|
|
off_t ContentSize() const; // 0 if uninitialized
|
2003-05-29 01:51:24 +04:00
|
|
|
uint32 BlockSize() const;
|
2003-06-10 03:02:16 +04:00
|
|
|
int32 Index() const; // 0 for devices
|
2003-05-29 01:46:11 +04:00
|
|
|
uint32 Status() const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-08 21:38:45 +04:00
|
|
|
bool ContainsFileSystem() const;
|
|
|
|
bool ContainsPartitioningSystem() const;
|
2003-05-29 01:46:11 +04:00
|
|
|
|
|
|
|
bool IsDevice() const;
|
2003-05-29 01:43:58 +04:00
|
|
|
bool IsReadOnly() const;
|
2003-05-29 01:46:11 +04:00
|
|
|
bool IsMounted() const;
|
2003-07-09 03:30:30 +04:00
|
|
|
bool IsBusy() const;
|
2003-07-07 03:11:10 +04:00
|
|
|
|
|
|
|
uint32 Flags() const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
const char *Name() const;
|
|
|
|
const char *ContentName() const;
|
|
|
|
const char *Type() const; // See DiskDeviceTypes.h
|
|
|
|
const char *ContentType() const; // See DiskDeviceTypes.h
|
2003-07-09 03:30:30 +04:00
|
|
|
partition_id ID() const;
|
2003-06-23 03:29:29 +04:00
|
|
|
|
|
|
|
status_t GetDiskSystem(BDiskSystem *diskSystem) const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
virtual status_t GetPath(BPath *path) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t GetVolume(BVolume *volume) const;
|
|
|
|
status_t GetIcon(BBitmap *icon, icon_size which) const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t Mount(uint32 mountFlags = 0, const char *parameters = NULL);
|
|
|
|
status_t Unmount();
|
|
|
|
|
2003-05-29 01:43:58 +04:00
|
|
|
// Hierarchy Info
|
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
BDiskDevice *Device() const;
|
|
|
|
BPartition *Parent() const;
|
|
|
|
BPartition *ChildAt(int32 index) const;
|
|
|
|
int32 CountChildren() const;
|
2003-07-15 05:16:29 +04:00
|
|
|
BPartition *FindDescendant(partition_id id) const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
status_t GetPartitioningInfo(BPartitioningInfo *info) const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
BPartition *VisitEachChild(BDiskDeviceVisitor *visitor);
|
2003-07-08 22:26:15 +04:00
|
|
|
virtual BPartition *VisitEachDescendant(BDiskDeviceVisitor *visitor);
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:46:11 +04:00
|
|
|
// Self Modification
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:47:29 +04:00
|
|
|
bool CanDefragment(bool *whileMounted = NULL) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t Defragment() const;
|
|
|
|
|
2003-07-17 04:06:58 +04:00
|
|
|
bool CanRepair(bool checkOnly, bool *whileMounted = NULL) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t Repair(bool checkOnly) const;
|
|
|
|
|
2003-07-30 04:35:05 +04:00
|
|
|
bool CanResize(bool *canResizeContents = NULL,
|
|
|
|
bool *whileMounted = NULL) const;
|
2003-09-22 01:23:33 +04:00
|
|
|
status_t ValidateResize(off_t *size) const;
|
|
|
|
status_t Resize(off_t size);
|
2003-05-29 01:46:11 +04:00
|
|
|
|
2003-07-30 04:35:05 +04:00
|
|
|
bool CanMove(BObjectList<BPartition> *unmovableDescendants = NULL,
|
|
|
|
BObjectList<BPartition> *movableOnlyIfUnmounted = NULL) const;
|
2003-09-22 01:23:33 +04:00
|
|
|
status_t ValidateMove(off_t *newOffset) const;
|
|
|
|
status_t Move(off_t newOffset);
|
2003-05-29 01:46:11 +04:00
|
|
|
|
2003-07-09 03:30:30 +04:00
|
|
|
bool CanSetName() const;
|
|
|
|
status_t ValidateSetName(char *name) const;
|
|
|
|
// adjusts name to be suitable
|
|
|
|
status_t SetName(const char *name);
|
|
|
|
|
|
|
|
bool CanSetContentName(bool *whileMounted = NULL) const;
|
|
|
|
status_t ValidateSetContentName(char *name) const;
|
|
|
|
// adjusts name to be suitable
|
|
|
|
status_t SetContentName(const char *name);
|
|
|
|
|
|
|
|
bool CanSetType() const;
|
|
|
|
status_t ValidateSetType(const char *type) const;
|
|
|
|
// type must be one the parent disk system's GetNextSupportedType()
|
|
|
|
// returns.
|
|
|
|
status_t SetType(const char *type);
|
|
|
|
|
2003-07-20 00:38:50 +04:00
|
|
|
bool CanEditParameters() const;
|
|
|
|
status_t GetParameterEditor(BDiskDeviceParameterEditor **editor);
|
|
|
|
status_t SetParameters(const char *parameters);
|
|
|
|
|
|
|
|
bool CanEditContentParameters(bool *whileMounted = NULL) const;
|
|
|
|
status_t GetContentParameterEditor(BDiskDeviceParameterEditor **editor);
|
|
|
|
status_t SetContentParameters(const char *parameters);
|
2003-06-10 03:02:16 +04:00
|
|
|
|
2003-05-29 01:47:29 +04:00
|
|
|
bool CanInitialize(const char *diskSystem) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t GetInitializationParameterEditor(const char *system,
|
2003-07-17 04:06:58 +04:00
|
|
|
BDiskDeviceParameterEditor **editor) const;
|
|
|
|
status_t ValidateInitialize(const char *diskSystem, char *name,
|
|
|
|
const char *parameters);
|
|
|
|
status_t Initialize(const char *diskSystem, const char *name,
|
|
|
|
const char *parameters);
|
2003-09-21 23:13:29 +04:00
|
|
|
status_t Uninitialize();
|
2003-05-29 01:46:11 +04:00
|
|
|
|
|
|
|
// Modification of child partitions
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:46:11 +04:00
|
|
|
bool CanCreateChild() const;
|
2003-06-23 03:29:29 +04:00
|
|
|
status_t GetChildCreationParameterEditor(const char *system,
|
2003-07-17 04:06:58 +04:00
|
|
|
BDiskDeviceParameterEditor **editor) const;
|
2003-05-29 01:47:29 +04:00
|
|
|
status_t ValidateCreateChild(off_t *start, off_t *size,
|
2003-06-23 03:29:29 +04:00
|
|
|
const char *type, const char *parameters) const;
|
|
|
|
status_t CreateChild(off_t start, off_t size, const char *type,
|
2003-07-17 04:06:58 +04:00
|
|
|
const char *parameters, BPartition **child = NULL);
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
bool CanDeleteChild(int32 index) const;
|
|
|
|
status_t DeleteChild(int32 index);
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
private:
|
|
|
|
BPartition();
|
2003-07-17 04:06:58 +04:00
|
|
|
BPartition(const BPartition &);
|
2003-07-07 03:11:10 +04:00
|
|
|
virtual ~BPartition();
|
2003-07-17 04:06:58 +04:00
|
|
|
BPartition & operator=(const BPartition &);
|
2003-05-29 01:51:24 +04:00
|
|
|
|
2003-07-08 22:26:15 +04:00
|
|
|
status_t _SetTo(BDiskDevice *device, BPartition *parent,
|
|
|
|
user_partition_data *data);
|
|
|
|
void _Unset();
|
2003-07-22 04:19:23 +04:00
|
|
|
status_t _RemoveObsoleteDescendants(user_partition_data *data,
|
|
|
|
bool *updated);
|
|
|
|
status_t _Update(user_partition_data *data, bool *updated);
|
|
|
|
void _RemoveChild(int32 index);
|
2003-07-08 22:26:15 +04:00
|
|
|
|
2003-07-15 05:16:29 +04:00
|
|
|
bool _IsShadow() const;
|
2003-07-16 01:44:23 +04:00
|
|
|
partition_id _ShadowID() const;
|
|
|
|
disk_system_id _DiskSystem() const;
|
2003-07-22 04:19:23 +04:00
|
|
|
int32 _ChangeCounter() const;
|
2003-07-15 05:16:29 +04:00
|
|
|
|
2003-07-20 00:38:50 +04:00
|
|
|
int32 _CountDescendants() const;
|
2003-07-08 22:26:15 +04:00
|
|
|
int32 _Level() const;
|
|
|
|
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
|
|
|
BPartition *_VisitEachDescendant(BDiskDeviceVisitor *visitor,
|
|
|
|
int32 level = -1);
|
2003-05-29 01:51:24 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
friend class BDiskDevice;
|
2003-07-16 01:44:23 +04:00
|
|
|
friend class BDiskSystem;
|
2003-05-29 01:51:24 +04:00
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
BDiskDevice *fDevice;
|
|
|
|
BPartition *fParent;
|
|
|
|
user_partition_data *fPartitionData;
|
|
|
|
};
|
2003-02-01 00:17:20 +03:00
|
|
|
|
|
|
|
#endif // _PARTITION_H
|