DiskDevice API v2.0
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3374 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,77 +6,28 @@
|
||||
#ifndef _DISK_DEVICE_H
|
||||
#define _DISK_DEVICE_H
|
||||
|
||||
#include <DiskDeviceVisitor.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
class BPartition;
|
||||
class BSession;
|
||||
|
||||
class BDiskDevice {
|
||||
class BDiskDevice : public BPartition {
|
||||
public:
|
||||
BDiskDevice();
|
||||
~BDiskDevice();
|
||||
void Unset(); // What is this for?
|
||||
|
||||
char* DeviceType() const;
|
||||
virtual char* Path() const;
|
||||
|
||||
void Unset();
|
||||
|
||||
off_t Size() const;
|
||||
int32 BlockSize() const;
|
||||
|
||||
int32 CountSessions() const;
|
||||
BSession *SessionAt(int32 index) const;
|
||||
|
||||
int32 CountPartitions() const;
|
||||
|
||||
const char *Path() const;
|
||||
status_t GetName(BString *name, bool includeBusID = true,
|
||||
bool includeLUN = false) const;
|
||||
status_t GetName(char *name, bool includeBusID = true,
|
||||
bool includeLUN = false) const;
|
||||
|
||||
bool IsReadOnly() const;
|
||||
bool IsRemovable() const;
|
||||
bool HasMedia() const;
|
||||
bool IsFloppy() const;
|
||||
uint8 Type() const;
|
||||
|
||||
int32 UniqueID() const;
|
||||
|
||||
status_t Eject(bool update = false);
|
||||
status_t LowLevelFormat(); // TODO: remove?
|
||||
|
||||
status_t Update(bool *updated = NULL);
|
||||
|
||||
BSession *VisitEachSession(BDiskDeviceVisitor *visitor);
|
||||
BPartition *VisitEachPartition(BDiskDeviceVisitor *visitor);
|
||||
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||
|
||||
BSession *SessionWithID(int32 id);
|
||||
BPartition *PartitionWithID(int32 id);
|
||||
|
||||
private:
|
||||
BDiskDevice(const BDiskDevice &);
|
||||
BDiskDevice &operator=(const BDiskDevice &);
|
||||
|
||||
status_t _Unarchive(BMessage *archive);
|
||||
status_t _Update(BMessage *archive);
|
||||
|
||||
bool _AddSession(BSession *session);
|
||||
|
||||
private:
|
||||
friend class BDiskDeviceList;
|
||||
friend class BDiskDeviceRoster;
|
||||
|
||||
BObjectList<BSession> fSessions;
|
||||
int32 fUniqueID;
|
||||
int32 fChangeCounter;
|
||||
status_t fMediaStatus;
|
||||
off_t fSize;
|
||||
int32 fBlockSize;
|
||||
uint8 fType;
|
||||
bool fReadOnly;
|
||||
bool fRemovable;
|
||||
// bool fIsFloppy;
|
||||
char fPath[B_FILE_NAME_LENGTH];
|
||||
};
|
||||
char fDeviceType[B_FILE_NAME_LENGTH];
|
||||
char fPath[B_FILE_NAME_LENGTH];
|
||||
|
||||
bool fIsRemovable;
|
||||
status_t fMediaStatus;
|
||||
}
|
||||
|
||||
#endif // _DISK_DEVICE_H
|
||||
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
BDiskDevice *DeviceAt(int32 index) const;
|
||||
|
||||
BDiskDevice *VisitEachDevice(BDiskDeviceVisitor *visitor);
|
||||
BSession *VisitEachSession(BDiskDeviceVisitor *visitor);
|
||||
BPartition *VisitEachPartition(BDiskDeviceVisitor *visitor);
|
||||
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||
|
||||
@@ -41,7 +40,6 @@ public:
|
||||
BPartition *VisitEachInitializablePartition(BDiskDeviceVisitor *visitor);
|
||||
|
||||
BDiskDevice *DeviceWithID(int32 id) const;
|
||||
BSession *SessionWithID(int32 id) const;
|
||||
BPartition *PartitionWithID(int32 id) const;
|
||||
|
||||
virtual void MountPointMoved(BPartition *partition);
|
||||
@@ -50,8 +48,6 @@ public:
|
||||
virtual void PartitionChanged(BPartition *partition);
|
||||
virtual void PartitionAdded(BPartition *partition);
|
||||
virtual void PartitionRemoved(BPartition *partition);
|
||||
virtual void SessionAdded(BSession *session);
|
||||
virtual void SessionRemoved(BSession *session);
|
||||
virtual void MediaChanged(BDiskDevice *device);
|
||||
virtual void DeviceAdded(BDiskDevice *device);
|
||||
virtual void DeviceRemoved(BDiskDevice *device);
|
||||
@@ -63,14 +59,11 @@ private:
|
||||
void _PartitionChanged(BMessage *message);
|
||||
void _PartitionAdded(BMessage *message);
|
||||
void _PartitionRemoved(BMessage *message);
|
||||
void _SessionAdded(BMessage *message);
|
||||
void _SessionRemoved(BMessage *message);
|
||||
void _MediaChanged(BMessage *message);
|
||||
void _DeviceAdded(BMessage *message);
|
||||
void _DeviceRemoved(BMessage *message);
|
||||
|
||||
BDiskDevice *_FindDevice(BMessage *message);
|
||||
BSession *_FindSession(BMessage *message);
|
||||
BPartition *_FindPartition(BMessage *message);
|
||||
|
||||
BDiskDevice *_UpdateDevice(BMessage *message);
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace BPrivate {
|
||||
enum {
|
||||
B_DEVICE_REQUEST_MOUNT_POINT = 0x01, // mount point changes
|
||||
B_DEVICE_REQUEST_MOUNTING = 0x02, // mounting/unmounting
|
||||
B_DEVICE_REQUEST_PARTITION = 0x04, // partition changes (initial.)
|
||||
B_DEVICE_REQUEST_SESSION = 0x08, // session changes (partitioning)
|
||||
B_DEVICE_REQUEST_PARTITION = 0x04, // partition changes
|
||||
B_DEVICE_REQUEST_DEVICE = 0x10, // device changes (media changes)
|
||||
B_DEVICE_REQUEST_DEVICE_LIST = 0x20, // device additions/removals
|
||||
B_DEVICE_REQUEST_ALL = 0xff, // all events
|
||||
@@ -45,11 +44,9 @@ enum {
|
||||
B_DEVICE_PARTITION_MOUNTED, // partition mounted
|
||||
B_DEVICE_PARTITION_UNMOUNTED, // partition unmounted
|
||||
B_DEVICE_PARTITION_CHANGED, // partition changed, e.g. initialized
|
||||
// or resized
|
||||
// or resized or moved
|
||||
B_DEVICE_PARTITION_ADDED, // partition added
|
||||
B_DEVICE_PARTITION_REMOVED, // partition removed
|
||||
B_DEVICE_SESSION_ADDED, // session added
|
||||
B_DEVICE_SESSION_REMOVED, // session removed
|
||||
B_DEVICE_MEDIA_CHANGED, // media changed
|
||||
B_DEVICE_ADDED, // device added
|
||||
B_DEVICE_REMOVED // device removed
|
||||
@@ -78,9 +75,6 @@ public:
|
||||
|
||||
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL);
|
||||
bool VisitEachSession(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BSession **session = NULL);
|
||||
bool VisitEachPartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BPartition **partition = NULL);
|
||||
@@ -95,11 +89,12 @@ public:
|
||||
bool VisitEachInitializablePartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BPartition **partition = NULL);
|
||||
bool VisitEachPartitionablePartition(BDiskDeviceVisitor *visitor,
|
||||
BDiskDevice *device = NULL,
|
||||
BPartition **partition = NULL);
|
||||
|
||||
|
||||
status_t GetDeviceWithID(int32 id, BDiskDevice *device) const;
|
||||
status_t GetSessionWithID(int32 id, BDiskDevice *device,
|
||||
BSession **session) const;
|
||||
status_t GetPartitionWithID(int32 id, BDiskDevice *device,
|
||||
BPartition **partition) const;
|
||||
|
||||
@@ -134,8 +129,6 @@ private:
|
||||
BDiskScannerPartitionAddOn **addOn);
|
||||
|
||||
private:
|
||||
friend class BSession;
|
||||
|
||||
BMessenger fManager;
|
||||
int32 fCookie;
|
||||
BDirectory *fPartitionAddOnDir;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#ifndef _DISK_DEVICE_TYPES_H
|
||||
#define _DISK_DEVICE_TYPES_H
|
||||
|
||||
// Device Types
|
||||
|
||||
#define B_DEVICE_TYPE_FLOPPY_DISK "Floppy Disk Media";
|
||||
#define B_DEVICE_TYPE_HARD_DISK "Hard Disk Media";
|
||||
#define B_DEVICE_TYPE_CD "CD-ROM Media";
|
||||
#define B_DEVICE_TYPE_DVD "DVD-ROM Media";
|
||||
|
||||
// Partition types
|
||||
|
||||
#define B_PARTITION_TYPE_UNFORMATTED "Unformatted";
|
||||
|
||||
#define B_PARTITION_TYPE_MULTISESSION "Multisession Storage Device";
|
||||
|
||||
#define B_PARTITION_TYPE_CD_AUDIO "Compact Disc Audio Session";
|
||||
|
||||
#define B_PARTITION_TYPE_APPLE "Apple Partition Map";
|
||||
#define B_PARTITION_TYPE_INTEL "Intel Partition Map";
|
||||
#define B_PARTITION_TYPE_INTEL_EXTENDED "Intel Extended Partition";
|
||||
|
||||
#define B_PARTITION_TYPE_BFS "BFS Filesystem";
|
||||
#define B_PARTITION_TYPE_EXT2 "EXT2 Filesystem";
|
||||
#define B_PARTITION_TYPE_EXT3 "EXT3 Filesystem";
|
||||
#define B_PARTITION_TYPE_FAT12 "FAT12 Filesystem";
|
||||
#define B_PARTITION_TYPE_FAT32 "FAT32 Filesystem";
|
||||
#define B_PARTITION_TYPE_ISO9660 "ISO9660 Filesystem";
|
||||
#define B_PARTITION_TYPE_REISER "Reiser Filesystem";
|
||||
#define B_PARTITION_TYPE_UDF "UDF Filesystem";
|
||||
|
||||
#endif // _DISK_DEVICE_TYPES_H
|
||||
@@ -6,88 +6,96 @@
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
|
||||
#include <disk_scanner.h>
|
||||
#include <Mime.h>
|
||||
#include <ObjectList.h>
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
|
||||
class BDiskDevice;
|
||||
class BSession;
|
||||
class BVolume;
|
||||
|
||||
class BPartition {
|
||||
public:
|
||||
~BPartition();
|
||||
|
||||
BSession *Session() const;
|
||||
BDiskDevice *Device() const;
|
||||
|
||||
off_t Offset() const;
|
||||
// General Info
|
||||
|
||||
off_t Offset() const; // 0 for devices
|
||||
off_t Size() const;
|
||||
int32 BlockSize() const;
|
||||
int32 Index() const;
|
||||
|
||||
uint32 Flags() const;
|
||||
bool IsHidden() const;
|
||||
bool IsVirtual() const;
|
||||
bool IsEmpty() const;
|
||||
bool ContainsFileSystem() const;
|
||||
|
||||
const char *Name() const;
|
||||
const char *Type() const;
|
||||
const char *FileSystemShortName() const;
|
||||
const char *FileSystemLongName() const;
|
||||
const char *VolumeName() const;
|
||||
|
||||
uint32 FileSystemFlags() const;
|
||||
|
||||
bool IsMounted() const;
|
||||
|
||||
int32 Index() const; // 0 for devices
|
||||
|
||||
bool IsMountable();
|
||||
bool IsPartitionable();
|
||||
bool IsDevice();
|
||||
bool IsReadOnly() const;
|
||||
|
||||
const char* Name() const;
|
||||
const char* Type() const; // See DiskDeviceTypes.h
|
||||
int32 UniqueID() const;
|
||||
virtual char* Path() const; // Recursively obtained down to the parent device
|
||||
|
||||
uint32 Flags() const; // not sure if this is really necessary anymore
|
||||
|
||||
|
||||
status_t GetVolume(BVolume *volume) const;
|
||||
// Hierarchy Info
|
||||
|
||||
status_t GetIcon(BBitmap *icon, icon_size which) const;
|
||||
|
||||
status_t Mount(uint32 mountFlags = 0, const char *parameters = NULL);
|
||||
status_t Unmount();
|
||||
const BPartition* Parent();
|
||||
BPartition* PartitionAt(int32 index) const;
|
||||
BPartition* PartitionWithID(int32 id);
|
||||
|
||||
status_t GetInitializationParameters(const char *fileSystem,
|
||||
BString *volumeName,
|
||||
BString *parameters,
|
||||
BRect dialogCenter = BRect(),
|
||||
bool *cancelled = NULL);
|
||||
status_t Initialize(const char *fileSystem, const char *volumeName,
|
||||
const char *parameters);
|
||||
status_t Initialize(const char *fileSystem = "bfs",
|
||||
BRect dialogCenter = BRect(),
|
||||
bool *cancelled = NULL);
|
||||
int32 CountChildren() const; // Immediate descendents
|
||||
int32 CountDescendents() const; // All descendents
|
||||
|
||||
BPartition* VisitEachChild(BDiskDeviceVisitor *visitor);
|
||||
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||
|
||||
private:
|
||||
BPartition();
|
||||
BPartition(const BPartition &);
|
||||
|
||||
BPartition &operator=(const BPartition &);
|
||||
// Functions relevant to manipulating *this* partition
|
||||
|
||||
void _Unset();
|
||||
status_t _Unarchive(BMessage *archive);
|
||||
off_t MinimumSize();
|
||||
off_t MaximumSize();
|
||||
// Both based on information obtained from the system used for the
|
||||
// partition and the partitioning system used for its parent
|
||||
|
||||
void _SetSession(BSession *session);
|
||||
int32 MoveTo(off_t start, BMessenger progressMessenger);
|
||||
int32 Resize(off_t size, BMessenger progressMessenger);
|
||||
|
||||
status_t GetParameterEditor(BDiskScannerParameterEditor **editor,
|
||||
BDiskScannerParameterEditor **parentEditor);
|
||||
// For changing parameters of the partition after it's been initialized,
|
||||
// i.e. file system block size, volume name, etc. "editor" is an editor
|
||||
// for the system with which this partition is initialized, "parentEditor"
|
||||
// is an editor for any settings the parent partitioning system may
|
||||
// allow to be edited ("*parentEditor" will be set to NULL if not
|
||||
// applicable).
|
||||
|
||||
private:
|
||||
friend class BDiskDeviceList;
|
||||
friend class BSession;
|
||||
status_t GetInitializationParameterEditor(const char *system,
|
||||
BDiskScannerParameterEditor **editor);
|
||||
int32 Initialize(const char *system,
|
||||
const char *parameters,
|
||||
BMessenger progressMessenger);
|
||||
// Initialization is used to set up a partition with either
|
||||
// an empty file system or an empty partitioning system
|
||||
|
||||
BSession *fSession;
|
||||
|
||||
// Functions relevant to manipluating *child* partitions
|
||||
|
||||
status_t GetPartitionCreationParameterEditor(BDiskScannerParameterEditor **editor);
|
||||
int32 CreateChildPartition(off_t start,
|
||||
off_t length,
|
||||
const char *parameters,
|
||||
BMessenger progressMessenger);
|
||||
int32 DeleteChildPartition(int32 index,
|
||||
BMessenger progressMessenger);
|
||||
|
||||
protected:
|
||||
BObjectList<BPartition> fChildren;
|
||||
int32 fUniqueID;
|
||||
int32 fChangeCounter;
|
||||
off_t fOffset;
|
||||
off_t fSize;
|
||||
int32 fBlockSize;
|
||||
int32 fIndex;
|
||||
// TODO: Also contains the device name, which we can get from Device() anyway.
|
||||
// We could either remove it from extended_partition_info or list
|
||||
// the individual fields here.
|
||||
extended_partition_info fInfo;
|
||||
dev_t fVolumeID;
|
||||
};
|
||||
|
||||
bool fIsMountable;
|
||||
bool fIsDevice;
|
||||
bool fIsReadOnly;
|
||||
|
||||
char fName[B_FILE_NAME_LENGTH];
|
||||
char fType[B_FILE_NAME_LENGTH];
|
||||
}
|
||||
|
||||
#endif // _PARTITION_H
|
||||
|
||||
Reference in New Issue
Block a user