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
|
|
|
|
|
|
|
|
#include <ObjectList.h>
|
|
|
|
|
2003-05-29 01:46:11 +04:00
|
|
|
class BDiskDevice;
|
|
|
|
|
|
|
|
// partition statuses
|
|
|
|
enum {
|
|
|
|
B_PARTITION_VALID,
|
|
|
|
B_PARTITION_CORRUPT,
|
|
|
|
B_PARTITION_UNRECOGNIZED,
|
|
|
|
}
|
|
|
|
|
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-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-05-29 01:46:11 +04:00
|
|
|
bool IsMountable() const;
|
|
|
|
bool IsPartitionable() const;
|
|
|
|
|
|
|
|
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-05-29 01:43:58 +04:00
|
|
|
|
|
|
|
const char* Name() const;
|
2003-06-10 03:02:16 +04:00
|
|
|
const char* ContentName() const;
|
2003-06-23 03:29:29 +04:00
|
|
|
const char* Type() const; // See DiskDeviceTypes.h
|
2003-05-29 01:47:29 +04:00
|
|
|
const char* ContentType() const; // See DiskDeviceTypes.h
|
2003-06-10 03:02:16 +04:00
|
|
|
partition_id UniqueID() const;
|
2003-05-29 01:46:11 +04:00
|
|
|
uint32 Flags() const;
|
2003-06-23 03:29:29 +04:00
|
|
|
|
|
|
|
status_t GetDiskSystem(BDiskSystem *diskSystem) const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t GetPath(BPath *path) const;
|
|
|
|
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-05-29 01:43:58 +04:00
|
|
|
|
2003-05-29 01:51:24 +04:00
|
|
|
BPartitioningInfo* GetPartitioningInfo() const;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
|
|
|
BPartition* VisitEachChild(BDiskDeviceVisitor *visitor);
|
2003-05-29 01:47:29 +04:00
|
|
|
BPartition* VisitEachDescendent(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:46:11 +04:00
|
|
|
bool IsLocked() const;
|
|
|
|
status_t Lock(); // to be non-blocking
|
|
|
|
status_t Unlock();
|
|
|
|
|
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-05-29 01:47:29 +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-05-29 01:47:29 +04:00
|
|
|
bool CanResize(bool *whileMounted = NULL) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t ValidateResize(off_t*) const;
|
|
|
|
status_t Resize(off_t);
|
|
|
|
|
2003-05-29 01:47:29 +04:00
|
|
|
bool CanMove(bool *whileMounted = NULL) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t ValidateMove(off_t*) const;
|
|
|
|
status_t Move(off_t);
|
|
|
|
|
2003-05-29 01:47:29 +04:00
|
|
|
bool CanEditParameters(bool *whileMounted = NULL) const;
|
2003-05-29 01:46:11 +04:00
|
|
|
status_t GetParameterEditor(
|
2003-05-29 01:47:29 +04:00
|
|
|
BDiskScannerParameterEditor **editor,
|
|
|
|
BDiskScannerParameterEditor **contentEditor);
|
2003-05-29 01:51:24 +04:00
|
|
|
status_t SetParameters(const char *parameters, const char *contentParameters);
|
2003-05-29 01:46:11 +04:00
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
// TODO: Add name/content name editing methods, Also in BDiskSystem.
|
|
|
|
|
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,
|
|
|
|
BDiskScannerParameterEditor **editor) const;
|
2003-06-23 03:29:29 +04:00
|
|
|
status_t Initialize(const char *diskSystem, const char *parameters);
|
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-05-29 01:47:29 +04:00
|
|
|
BDiskScannerParameterEditor **editor) const;
|
|
|
|
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,
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
off_t fOffset;
|
|
|
|
off_t fSize;
|
2003-05-29 01:51:24 +04:00
|
|
|
uint32 fBlockSize;
|
2003-06-10 03:02:16 +04:00
|
|
|
int32 fIndex;
|
2003-05-29 01:51:24 +04:00
|
|
|
uint32 fStatus;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
|
|
|
bool fIsMountable;
|
2003-05-29 01:51:24 +04:00
|
|
|
bool fIsPartitionable;
|
|
|
|
|
2003-05-29 01:43:58 +04:00
|
|
|
bool fIsDevice;
|
|
|
|
bool fIsReadOnly;
|
2003-05-29 01:51:24 +04:00
|
|
|
bool fIsMounted;
|
2003-05-29 01:43:58 +04:00
|
|
|
|
|
|
|
char fName[B_FILE_NAME_LENGTH];
|
|
|
|
char fType[B_FILE_NAME_LENGTH];
|
2003-05-29 01:51:24 +04:00
|
|
|
char fContentType[B_FILE_NAME_LENGTH];
|
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
partition_id fUniqueID;
|
2003-05-29 01:51:24 +04:00
|
|
|
uint32 fFlags;
|
|
|
|
|
|
|
|
BObjectList<BPartition> fChildren;
|
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
int32 fChangeCounter;
|
2003-05-29 01:43:58 +04:00
|
|
|
}
|
2003-02-01 00:17:20 +03:00
|
|
|
|
|
|
|
#endif // _PARTITION_H
|