From 5b3f1d0cda7d0ad73a0e01fbc8432e14fb79be22 Mon Sep 17 00:00:00 2001 From: Tyler Dauwalder Date: Wed, 28 May 2003 21:51:24 +0000 Subject: [PATCH] DiskDevice API v2.4 git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3378 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/storage/DiskDevice.h | 2 +- headers/private/storage/DiskDeviceJob.h | 13 ++++--- headers/private/storage/DiskDeviceList.h | 8 ++--- headers/private/storage/DiskDevicePrivate.h | 6 ++-- headers/private/storage/DiskDeviceRoster.h | 18 +++++----- headers/private/storage/DiskSystem.h | 1 - headers/private/storage/Partition.h | 40 ++++++++++++--------- headers/private/storage/PartitioningInfo.h | 23 ++++++++++++ 8 files changed, 72 insertions(+), 39 deletions(-) create mode 100644 headers/private/storage/PartitioningInfo.h diff --git a/headers/private/storage/DiskDevice.h b/headers/private/storage/DiskDevice.h index 053f9ad8ee..caebcc8f04 100644 --- a/headers/private/storage/DiskDevice.h +++ b/headers/private/storage/DiskDevice.h @@ -17,7 +17,7 @@ public: void Unset(); bool IsModified() const; - int32 CommitModifications(bool synchronously = true, + uint32 CommitModifications(bool synchronously = true, BMessenger progressMessenger = BMessenger(), bool receiveCompleteProgressUpdates = true, BMessage *template = NULL); diff --git a/headers/private/storage/DiskDeviceJob.h b/headers/private/storage/DiskDeviceJob.h index f7f10f5c67..b08be618b5 100644 --- a/headers/private/storage/DiskDeviceJob.h +++ b/headers/private/storage/DiskDeviceJob.h @@ -6,6 +6,8 @@ #ifndef _DISK_DEVICE_JOB_H #define _DISK_DEVICE_JOB_H +#include + // disk device job types enum { B_DISK_DEVICE_JOB_CREATE, @@ -29,16 +31,19 @@ enum { class BDiskDeviceJob { public: - int32 ID() const; + uint32 ID() const; uint32 Type() const; - uint8 Progress() const; // 0 to 100 + float Progress() const; // [0.0, 1.0] uint32 Status() const; const char *Description() const; BPartition* Partition() const; private: - int32 fPartitionID; - int32 fJobID; + uint32 fJobID; + uint32 fType; + uint32 fPartitionID; + uint32 fStatus; + BString fDescription; }; #endif // _DISK_DEVICE_JOB_H diff --git a/headers/private/storage/DiskDeviceList.h b/headers/private/storage/DiskDeviceList.h index cdca22e056..c105f983bf 100644 --- a/headers/private/storage/DiskDeviceList.h +++ b/headers/private/storage/DiskDeviceList.h @@ -28,8 +28,8 @@ public: bool Lock(); void Unlock(); - int32 CountDevices() const; - BDiskDevice *DeviceAt(int32 index) const; + uint32 CountDevices() const; + BDiskDevice *DeviceAt(uint32 index) const; BDiskDevice *VisitEachDevice(BDiskDeviceVisitor *visitor); BPartition *VisitEachPartition(BDiskDeviceVisitor *visitor); @@ -39,8 +39,8 @@ public: BPartition *VisitEachMountablePartition(BDiskDeviceVisitor *visitor); BPartition *VisitEachInitializablePartition(BDiskDeviceVisitor *visitor); - BDiskDevice *DeviceWithID(int32 id) const; - BPartition *PartitionWithID(int32 id) const; + BDiskDevice *DeviceWithID(uint32 id) const; + BPartition *PartitionWithID(uint32 id) const; virtual void MountPointMoved(BPartition *partition); virtual void PartitionMounted(BPartition *partition); diff --git a/headers/private/storage/DiskDevicePrivate.h b/headers/private/storage/DiskDevicePrivate.h index bf3616a638..5a8b45e122 100644 --- a/headers/private/storage/DiskDevicePrivate.h +++ b/headers/private/storage/DiskDevicePrivate.h @@ -26,7 +26,6 @@ public: PartitionFilter *filter); virtual bool Visit(BDiskDevice *device); - virtual bool Visit(BSession *session); virtual bool Visit(BPartition *partition); private: @@ -37,14 +36,13 @@ private: // IDFinderVisitor class IDFinderVisitor : public BDiskDeviceVisitor { public: - IDFinderVisitor(int32 id); + IDFinderVisitor(uint32 id); virtual bool Visit(BDiskDevice *device); - virtual bool Visit(BSession *session); virtual bool Visit(BPartition *partition); private: - int32 fID; + uint32 fID; }; status_t get_disk_device_messenger(BMessenger *messenger); diff --git a/headers/private/storage/DiskDeviceRoster.h b/headers/private/storage/DiskDeviceRoster.h index 15d840619a..2929ca6693 100644 --- a/headers/private/storage/DiskDeviceRoster.h +++ b/headers/private/storage/DiskDeviceRoster.h @@ -118,8 +118,8 @@ public: BDiskDevice *device = NULL, BPartition **partition = NULL); - status_t GetDeviceWithID(int32 id, BDiskDevice *device) const; - status_t GetPartitionWithID(int32 id, BDiskDevice *device, + status_t GetDeviceWithID(uint32 id, BDiskDevice *device) const; + status_t GetPartitionWithID(uint32 id, BDiskDevice *device, BPartition **partition) const; status_t StartWatching(BMessenger target, @@ -129,19 +129,19 @@ public: status_t StopWatching(BMessenger target); private: - status_t _GetObjectWithID(const char *fieldName, int32 id, + status_t _GetObjectWithID(const char *fieldName, uint32 id, BDiskDevice *device) const; // TODO: Introduce iterators instead of these functions. - static status_t _GetNextAddOn(BDirectory **directory, int32 *index, + static status_t _GetNextAddOn(BDirectory **directory, uint32 *index, const char *subdir, BPrivate::AddOnImage *image); static status_t _GetNextAddOn(BDirectory *directory, BPrivate::AddOnImage *image); - static status_t _GetNextAddOnDir(BPath *path, int32 *index, + static status_t _GetNextAddOnDir(BPath *path, uint32 *index, const char *subdir); - static status_t _GetNextAddOnDir(BDirectory **directory, int32 *index, + static status_t _GetNextAddOnDir(BDirectory **directory, uint32 *index, const char *subdir); static status_t _LoadPartitionAddOn(const char *partitioningSystem, @@ -150,11 +150,11 @@ private: private: BMessenger fManager; - int32 fCookie; + uint32 fCookie; BDirectory *fPartitionAddOnDir; BDirectory *fFSAddOnDir; - int32 fPartitionAddOnDirIndex; - int32 fFSAddOnDirIndex; + uint32 fPartitionAddOnDirIndex; + uint32 fFSAddOnDirIndex; }; #endif // _DISK_DEVICE_ROSTER_H diff --git a/headers/private/storage/DiskSystem.h b/headers/private/storage/DiskSystem.h index 368ae3e5c5..1775f87df9 100644 --- a/headers/private/storage/DiskSystem.h +++ b/headers/private/storage/DiskSystem.h @@ -28,7 +28,6 @@ public: 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 char *parameters) const; - bool ValidateInitialize(BPartition *partition) const; bool IsPartitioningSystem() const; bool IsFileSystem() const; diff --git a/headers/private/storage/Partition.h b/headers/private/storage/Partition.h index 63fec86207..9e7dd11d8d 100644 --- a/headers/private/storage/Partition.h +++ b/headers/private/storage/Partition.h @@ -23,8 +23,8 @@ public: off_t Offset() const; // 0 for devices off_t Size() const; - int32 BlockSize() const; - int32 Index() const; // 0 for devices + uint32 BlockSize() const; + uint32 Index() const; // 0 for devices uint32 Status() const; bool IsMountable() const; @@ -37,7 +37,7 @@ public: const char* Name() const; const char* Type() const; // See DiskDeviceTypes.h const char* ContentType() const; // See DiskDeviceTypes.h - int32 UniqueID() const; + uint32 UniqueID() const; uint32 Flags() const; status_t GetPath(BPath *path) const; @@ -51,11 +51,10 @@ public: BDiskDevice* Device() const; BPartition* Parent() const; - BPartition* ChildAt(int32 index) const; - int32 CountChildren() const; + BPartition* ChildAt(uint32 index) const; + uint32 CountChildren() const; - BPartitionableSpace* PartitionableSpaceAt(int32 index) const; - int32 CountPartitionableSpaces() const; + BPartitioningInfo* GetPartitioningInfo() const; BPartition* VisitEachChild(BDiskDeviceVisitor *visitor); BPartition* VisitEachDescendent(BDiskDeviceVisitor *visitor); @@ -84,7 +83,7 @@ public: status_t GetParameterEditor( BDiskScannerParameterEditor **editor, BDiskScannerParameterEditor **contentEditor); - status_t SetParameters(const char *parameters, const char **contentParameters); + status_t SetParameters(const char *parameters, const char *contentParameters); bool CanInitialize(const char *diskSystem) const; status_t GetInitializationParameterEditor(const char *system, @@ -100,26 +99,35 @@ public: status_t ValidateCreateChild(off_t *start, off_t *size, const char *parameters) const; status_t CreateChild(off_t start, off_t size, const char *parameters, - **BPartition child = NULL); + BPartition** child = NULL); - bool CanDeleteChild(int32 index) const; - status_t DeleteChild(int32 index); + bool CanDeleteChild(uint32 index) const; + status_t DeleteChild(uint32 index); protected: - BObjectList fChildren; - int32 fUniqueID; - int32 fChangeCounter; off_t fOffset; off_t fSize; - int32 fBlockSize; - int32 fIndex; + uint32 fBlockSize; + uint32 fIndex; + uint32 fStatus; bool fIsMountable; + bool fIsPartitionable; + bool fIsDevice; bool fIsReadOnly; + bool fIsMounted; char fName[B_FILE_NAME_LENGTH]; char fType[B_FILE_NAME_LENGTH]; + char fContentType[B_FILE_NAME_LENGTH]; + + uint32 fUniqueID; + uint32 fFlags; + + BObjectList fChildren; + + uint32 fChangeCounter; } #endif // _PARTITION_H diff --git a/headers/private/storage/PartitioningInfo.h b/headers/private/storage/PartitioningInfo.h new file mode 100644 index 0000000000..f38361c329 --- /dev/null +++ b/headers/private/storage/PartitioningInfo.h @@ -0,0 +1,23 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- + +#ifndef _PARTITIONING_INFO_H +#define _PARTITIONING_INFO_H + +class BPartition; + +class BPartitioningInfo { +public: + status_t GetPartitionableSpaceAt(uint32 index, off_t *Offset, off_t *Size) const; + uint32 CountPartitionableSpaces() const; + + BPartition* Parent() const; +private: + off_t *fOffsetArray; + off_t *fSizeArray; + uint32 fCount; +}; + +#endif // _PARTITIONING_INFO_H