Beginning of Disk Device API:
* Made all headers parsable. Also some smaller changes. * Added empty source files for new classes. * Changed obsolete implementations of existing classes, so that we now have basic functionality for BDiskDevice[Roster] and BPartition. Iterating through disk devices works and the data we get doesn't look too bad for the beginning. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3883 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,8 +6,15 @@
|
||||
#ifndef _DISK_DEVICE_H
|
||||
#define _DISK_DEVICE_H
|
||||
|
||||
#include <Partition.h>
|
||||
|
||||
struct user_disk_device_data;
|
||||
|
||||
class BDiskDevice : public BPartition {
|
||||
public:
|
||||
BDiskDevice();
|
||||
virtual ~BDiskDevice();
|
||||
|
||||
bool IsRemovable() const;
|
||||
bool HasMedia() const;
|
||||
|
||||
@@ -15,21 +22,26 @@ public:
|
||||
|
||||
status_t Update(bool *updated = NULL);
|
||||
void Unset();
|
||||
|
||||
virtual status_t GetPath(BPath *path) const;
|
||||
|
||||
virtual BPartition *VisitEachDescendent(BDiskDeviceVisitor *visitor);
|
||||
|
||||
bool IsModified() const;
|
||||
status_t PrepareModifications();
|
||||
status_t CommitModifications(bool synchronously = true,
|
||||
BMessenger progressMessenger = BMessenger(),
|
||||
bool receiveCompleteProgressUpdates = true,
|
||||
BMessage *template = NULL);
|
||||
bool receiveCompleteProgressUpdates = true);
|
||||
status_t CancelModifications();
|
||||
|
||||
private:
|
||||
friend class BDiskDeviceList;
|
||||
friend class BDiskDeviceRoster;
|
||||
|
||||
char fDeviceType[B_FILE_NAME_LENGTH];
|
||||
char fPath[B_FILE_NAME_LENGTH];
|
||||
status_t SetTo(partition_id id, size_t neededSize = 0);
|
||||
status_t SetTo(user_disk_device_data *data);
|
||||
|
||||
bool fIsRemovable;
|
||||
status_t fMediaStatus;
|
||||
}
|
||||
user_disk_device_data *fDeviceData;
|
||||
};
|
||||
|
||||
#endif // _DISK_DEVICE_H
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef _DISK_DEVICE_JOB_H
|
||||
#define _DISK_DEVICE_JOB_H
|
||||
|
||||
#include <DiskDeviceDefs.h>
|
||||
#include <String.h>
|
||||
|
||||
// disk device job types
|
||||
@@ -42,21 +43,24 @@ enum {
|
||||
B_DISK_DEVICE_JOB_CAN_CANCEL = 0x01,
|
||||
B_DISK_DEVICE_JOB_STOP_ON_CANCEL = 0x02,
|
||||
B_DISK_DEVICE_JOB_REVERSE_ON_CANCEL = 0x04,
|
||||
B_DISK_DEVICE_JOB_CAN_PAUSE = 0x08,
|
||||
};
|
||||
|
||||
class BDiskDeviceJob {
|
||||
public:
|
||||
disk_job_id ID() const;
|
||||
uint32 Type() const;
|
||||
partition_id PartitionID() const;
|
||||
|
||||
float Progress() const; // [0.0, 1.0]
|
||||
uint32 Status() const;
|
||||
const char *Description() const;
|
||||
status_t GetProgressInfo(disk_devive_progress_info *info) const;
|
||||
uint32 CancelProperties() const;
|
||||
// TODO: Add Cancel() and Pause(), SupportsPause().
|
||||
|
||||
partition_id PartitionID() const;
|
||||
status_t GetProgressInfo(disk_device_progress_info *info) const;
|
||||
uint32 InterruptProperties() const;
|
||||
|
||||
status_t Cancel();
|
||||
status_t Pause();
|
||||
|
||||
private:
|
||||
disk_job_id fJobID;
|
||||
uint32 fType;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#ifndef _DISK_DEVICE_PRIVATE_H
|
||||
#define _DISK_DEVICE_PRIVATE_H
|
||||
|
||||
#include <DiskDeviceDefs.h>
|
||||
#include <DiskDeviceVisitor.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BMessenger;
|
||||
|
||||
@@ -45,13 +45,10 @@ private:
|
||||
partition_id fID;
|
||||
};
|
||||
|
||||
status_t get_disk_device_messenger(BMessenger *messenger);
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::PartitionFilter;
|
||||
using BPrivate::PartitionFilterVisitor;
|
||||
using BPrivate::IDFinderVisitor;
|
||||
using BPrivate::get_disk_device_messenger;
|
||||
|
||||
#endif // _DISK_DEVICE_PRIVATE_H
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
|
||||
#include <image.h>
|
||||
|
||||
#include <DiskDeviceVisitor.h>
|
||||
#include <DiskDeviceDefs.h>
|
||||
#include <Messenger.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BDirectory;
|
||||
class BDiskDevice;
|
||||
class BDiskDeviceJob;
|
||||
class BDiskDeviceVisitor;
|
||||
class BDiskScannerPartitionAddOn;
|
||||
class BDiskSystem;
|
||||
class BPartition;
|
||||
class BSession;
|
||||
|
||||
namespace BPrivate {
|
||||
class AddOnImage;
|
||||
@@ -98,10 +98,10 @@ public:
|
||||
status_t GetNextActiveJob(BDiskDeviceJob *job);
|
||||
status_t RewindActiveJobs();
|
||||
|
||||
partition_id RegisterDeviceFile(const char *filename);
|
||||
partition_id RegisterFileDevice(const char *filename);
|
||||
// publishes: /dev/disk/virtual/files/<disk device ID>/raw
|
||||
status_t UnregisterDeviceFile(const char *filename);
|
||||
status_t UnregisterDeviceFile(partition_id device);
|
||||
status_t UnregisterFileDevice(const char *filename);
|
||||
status_t UnregisterFileDevice(partition_id device);
|
||||
// TODO: Add the respective syscalls. Also for Get{Device,Partition}ForPath()
|
||||
|
||||
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
|
||||
@@ -138,9 +138,11 @@ public:
|
||||
uint32 eventMask = B_DEVICE_REQUEST_ALL);
|
||||
status_t StartWatchingJob(BDiskDeviceJob *job, BMessenger target,
|
||||
uint32 eventMask = B_DEVICE_REQUEST_JOB_COMPLETE_PROGRESS);
|
||||
// TODO: Maybe better a BDiskDeviceJob::{Start,Stop}Watching()?
|
||||
status_t StopWatching(BMessenger target);
|
||||
|
||||
private:
|
||||
#if 0
|
||||
status_t _GetObjectWithID(const char *fieldName, partition_id id,
|
||||
BDiskDevice *device) const;
|
||||
|
||||
@@ -159,14 +161,13 @@ private:
|
||||
static status_t _LoadPartitionAddOn(const char *partitioningSystem,
|
||||
BPrivate::AddOnImage *image,
|
||||
BDiskScannerPartitionAddOn **addOn);
|
||||
|
||||
#endif // 0
|
||||
private:
|
||||
BMessenger fManager;
|
||||
int32 fCookie;
|
||||
BDirectory *fPartitionAddOnDir;
|
||||
BDirectory *fFSAddOnDir;
|
||||
int32 fPartitionAddOnDirIndex;
|
||||
int32 fFSAddOnDirIndex;
|
||||
// BDirectory *fPartitionAddOnDir;
|
||||
// BDirectory *fFSAddOnDir;
|
||||
// int32 fPartitionAddOnDirIndex;
|
||||
// int32 fFSAddOnDirIndex;
|
||||
};
|
||||
|
||||
#endif // _DISK_DEVICE_ROSTER_H
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#ifndef _DISK_SYSTEM_H
|
||||
#define _DISK_SYSTEM_H
|
||||
|
||||
#include <DiskDeviceDefs.h>
|
||||
|
||||
class BPartition;
|
||||
|
||||
class BDiskSystem {
|
||||
public:
|
||||
const char *Name() const;
|
||||
@@ -18,9 +22,9 @@ public:
|
||||
bool SupportsMoving(BPartition *partition, bool *whileMounted) const;
|
||||
bool SupportsMovingChild(BPartition *child) const;
|
||||
bool SupportsCreatingChild(BPartition *partition) const;
|
||||
bool SupportsParentSystem(KPartition *child, const char *system) const;
|
||||
bool SupportsParentSystem(BPartition *child, const char *system) const;
|
||||
// True in most cases. NULL == raw device.
|
||||
bool SupportsChildSystem(KPartition *child, const char *system) const;
|
||||
bool SupportsChildSystem(BPartition *child, const char *system) const;
|
||||
// False for most file systems, true for most partitioning
|
||||
// systems.
|
||||
|
||||
|
||||
@@ -6,16 +6,25 @@
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
|
||||
#include <ObjectList.h>
|
||||
#include <DiskDeviceDefs.h>
|
||||
#include <Messenger.h>
|
||||
#include <Mime.h>
|
||||
|
||||
class BBitmap;
|
||||
class BDiskDevice;
|
||||
class BDiskDeviceVisitor;
|
||||
class BPartitioningInfo;
|
||||
class BDiskScannerParameterEditor; // TODO: Rename!
|
||||
class BDiskSystem;
|
||||
class BVolume;
|
||||
struct user_partition_data;
|
||||
|
||||
// partition statuses
|
||||
enum {
|
||||
B_PARTITION_VALID,
|
||||
B_PARTITION_CORRUPT,
|
||||
B_PARTITION_UNRECOGNIZED,
|
||||
}
|
||||
};
|
||||
|
||||
class BPartition {
|
||||
public:
|
||||
@@ -33,17 +42,19 @@ public:
|
||||
bool IsDevice() const;
|
||||
bool IsReadOnly() const;
|
||||
bool IsMounted() const;
|
||||
|
||||
const char* Name() const;
|
||||
const char* ContentName() const;
|
||||
const char* Type() const; // See DiskDeviceTypes.h
|
||||
const char* ContentType() const; // See DiskDeviceTypes.h
|
||||
partition_id UniqueID() const;
|
||||
|
||||
uint32 Flags() const;
|
||||
|
||||
const char *Name() const;
|
||||
const char *ContentName() const;
|
||||
const char *Type() const; // See DiskDeviceTypes.h
|
||||
const char *ContentType() const; // See DiskDeviceTypes.h
|
||||
partition_id UniqueID() const;
|
||||
// TODO: just ID() ?
|
||||
|
||||
status_t GetDiskSystem(BDiskSystem *diskSystem) const;
|
||||
|
||||
status_t GetPath(BPath *path) const;
|
||||
virtual status_t GetPath(BPath *path) const;
|
||||
status_t GetVolume(BVolume *volume) const;
|
||||
status_t GetIcon(BBitmap *icon, icon_size which) const;
|
||||
|
||||
@@ -57,17 +68,13 @@ public:
|
||||
BPartition *ChildAt(int32 index) const;
|
||||
int32 CountChildren() const;
|
||||
|
||||
BPartitioningInfo* GetPartitioningInfo() const;
|
||||
status_t GetPartitioningInfo(BPartitioningInfo *info) const;
|
||||
|
||||
BPartition* VisitEachChild(BDiskDeviceVisitor *visitor);
|
||||
BPartition* VisitEachDescendent(BDiskDeviceVisitor *visitor);
|
||||
BPartition *VisitEachChild(BDiskDeviceVisitor *visitor);
|
||||
virtual BPartition *VisitEachDescendent(BDiskDeviceVisitor *visitor);
|
||||
|
||||
// Self Modification
|
||||
|
||||
bool IsLocked() const;
|
||||
status_t Lock(); // to be non-blocking
|
||||
status_t Unlock();
|
||||
|
||||
bool CanDefragment(bool *whileMounted = NULL) const;
|
||||
status_t Defragment() const;
|
||||
|
||||
@@ -108,30 +115,20 @@ public:
|
||||
bool CanDeleteChild(int32 index) const;
|
||||
status_t DeleteChild(int32 index);
|
||||
|
||||
protected:
|
||||
off_t fOffset;
|
||||
off_t fSize;
|
||||
uint32 fBlockSize;
|
||||
int32 fIndex;
|
||||
uint32 fStatus;
|
||||
private:
|
||||
BPartition();
|
||||
BPartition(const Partition &);
|
||||
virtual ~BPartition();
|
||||
|
||||
bool fIsMountable;
|
||||
bool fIsPartitionable;
|
||||
status_t SetTo(BDiskDevice *device, BPartition *parent,
|
||||
user_partition_data *data);
|
||||
void Unset();
|
||||
|
||||
bool fIsDevice;
|
||||
bool fIsReadOnly;
|
||||
bool fIsMounted;
|
||||
|
||||
char fName[B_FILE_NAME_LENGTH];
|
||||
char fType[B_FILE_NAME_LENGTH];
|
||||
char fContentType[B_FILE_NAME_LENGTH];
|
||||
friend class BDiskDevice;
|
||||
|
||||
partition_id fUniqueID;
|
||||
uint32 fFlags;
|
||||
|
||||
BObjectList<BPartition> fChildren;
|
||||
|
||||
int32 fChangeCounter;
|
||||
}
|
||||
BDiskDevice *fDevice;
|
||||
BPartition *fParent;
|
||||
user_partition_data *fPartitionData;
|
||||
};
|
||||
|
||||
#endif // _PARTITION_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef _PARTITIONING_INFO_H
|
||||
#define _PARTITIONING_INFO_H
|
||||
|
||||
class BPartition;
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BPartitioningInfo {
|
||||
public:
|
||||
@@ -14,11 +14,9 @@ public:
|
||||
off_t *size) const;
|
||||
int32 CountPartitionableSpaces() const;
|
||||
|
||||
BPartition *Parent() const; // needed?
|
||||
|
||||
private:
|
||||
off_t *fOffsetArray;
|
||||
off_t *fSizeArray;
|
||||
off_t *fOffsets;
|
||||
off_t *fSizes;
|
||||
int32 fCount;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user