Made KPartition abstract and derived two classes, KPhysicalPartition

and KShadowPartition from it. KPhysicalPartition represents a partition
that exists on-disk, while KShadowPartition is a partition edited by the
API user, but not yet written to disk. Related changes in other classes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3851 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2003-07-04 23:45:26 +00:00
parent 904c699d7f
commit a162af3b0e
13 changed files with 481 additions and 112 deletions
@@ -5,7 +5,7 @@
#include <OS.h>
#include "KPartition.h"
#include "KPhysicalPartition.h"
#include "RWLocker.h"
// disk device flags
@@ -18,7 +18,7 @@ enum {
namespace BPrivate {
namespace DiskDevice {
class KDiskDevice : public KPartition {
class KDiskDevice : public KPhysicalPartition {
public:
KDiskDevice(partition_id id = -1);
virtual ~KDiskDevice();
@@ -66,8 +66,6 @@ public:
disk_device_data *DeviceData();
const disk_device_data *DeviceData() const;
virtual KPartition *CreateShadowPartition();
void SetShadowOwner(team_id team);
team_id ShadowOwner() const;
@@ -37,20 +37,18 @@ public:
// Disk Device / Partition Management
// manager must be locked
KDiskDevice *FindDevice(const char *path, bool noShadow = true);
KDiskDevice *FindDevice(partition_id id, bool noShadow = true);
KPartition *FindPartition(const char *path, bool noShadow = true);
KPartition *FindPartition(partition_id id, bool noShadow = true);
KFileDiskDevice *FindFileDevice(const char *filePath,
bool noShadow = true);
KDiskDevice *FindDevice(const char *path);
KDiskDevice *FindDevice(partition_id id);
KPartition *FindPartition(const char *path, bool noShadow = false);
KPartition *FindPartition(partition_id id, bool noShadow = false);
KFileDiskDevice *FindFileDevice(const char *filePath);
KDiskDevice *RegisterDevice(const char *path, bool noShadow = true);
KDiskDevice *RegisterDevice(partition_id id, bool noShadow = true);
KDiskDevice *RegisterDevice(const char *path);
KDiskDevice *RegisterDevice(partition_id id);
KDiskDevice *RegisterNextDevice(int32 *cookie);
KPartition *RegisterPartition(const char *path, bool noShadow = true);
KPartition *RegisterPartition(partition_id id, bool noShadow = true);
KFileDiskDevice *RegisterFileDevice(const char *filePath,
bool noShadow = true);
KPartition *RegisterPartition(const char *path, bool noShadow = false);
KPartition *RegisterPartition(partition_id id, bool noShadow = false);
KFileDiskDevice *RegisterFileDevice(const char *filePath);
status_t CreateFileDevice(const char *filePath, partition_id *device = 0);
status_t DeleteFileDevice(const char *filePath);
@@ -22,8 +22,6 @@ public:
const char *FilePath() const;
virtual KPartition *CreateShadowPartition();
// virtual void Dump(bool deep = true, int32 level = 0);
private:
@@ -24,6 +24,8 @@ namespace DiskDevice {
class KDiskDevice;
class KDiskSystem;
class KPhysicalPartition;
class KShadowPartition;
class KPartition {
public:
@@ -44,7 +46,7 @@ public:
virtual bool PrepareForRemoval();
virtual bool PrepareForDeletion();
status_t Open(int flags, int *fd);
virtual status_t Open(int flags, int *fd);
virtual status_t PublishDevice();
virtual status_t UnpublishDevice();
@@ -55,7 +57,7 @@ public:
bool IsDescendantBusy() const;
// == jobs which may affect a descendant of this partition are
// scheduled/in progress; IsBusy() => IsDescendantBusy()
// In the userland API, both can probably mapped to one flag.
// In the userland API, both can probably be mapped to one flag.
void SetOffset(off_t offset);
off_t Offset() const; // 0 for devices
@@ -108,8 +110,8 @@ public:
void SetVolumeID(dev_t volumeID);
dev_t VolumeID() const;
status_t Mount(uint32 mountFlags, const char *parameters);
status_t Unmount();
virtual status_t Mount(uint32 mountFlags, const char *parameters);
virtual status_t Unmount();
// Parameters
@@ -128,8 +130,8 @@ public:
KPartition *Parent() const;
status_t AddChild(KPartition *partition, int32 index = -1);
status_t CreateChild(partition_id id, int32 index,
KPartition **child = NULL);
virtual status_t CreateChild(partition_id id, int32 index,
KPartition **child = NULL) = 0;
bool RemoveChild(int32 index);
bool RemoveChild(KPartition *child);
bool RemoveAllChildren();
@@ -138,10 +140,11 @@ public:
// Shadow Partition
virtual KPartition *CreateShadowPartition(); // creates a complete tree
void DeleteShadowPartition(); // deletes ...
KPartition *ShadowPartition() const;
bool IsShadowPartition() const;
virtual status_t CreateShadowPartition(); // creates a complete tree
virtual void DeleteShadowPartition(); // deletes ...
virtual KShadowPartition *ShadowPartition() = 0;
virtual bool IsShadowPartition() const = 0;
virtual KPhysicalPartition *PhysicalPartition() = 0;
// DiskSystem
@@ -0,0 +1,55 @@
// KPartition.h
#ifndef _K_DISK_DEVICE_PHYSICAL_PARTITION_H
#define _K_DISK_DEVICE_PHYSICAL_PARTITION_H
#include <KPartition.h>
namespace BPrivate {
namespace DiskDevice {
class KDiskDevice;
class KDiskSystem;
class KShadowPartition;
class KPhysicalPartition : public KPartition {
public:
KPhysicalPartition(partition_id id = -1);
virtual ~KPhysicalPartition();
virtual bool PrepareForRemoval();
virtual status_t Open(int flags, int *fd);
virtual status_t PublishDevice();
virtual status_t UnpublishDevice();
virtual status_t Mount(uint32 mountFlags, const char *parameters);
virtual status_t Unmount();
// Hierarchy
virtual status_t CreateChild(partition_id id, int32 index,
KPartition **child = NULL);
// Shadow Partition
virtual status_t CreateShadowPartition(); // creates a complete tree
virtual void DeleteShadowPartition(); // deletes ...
virtual KShadowPartition *ShadowPartition();
virtual bool IsShadowPartition() const;
virtual KPhysicalPartition *PhysicalPartition();
// DiskSystem
virtual void Dump(bool deep, int32 level);
protected:
KShadowPartition *fShadowPartition;
};
} // namespace DiskDevice
} // namespace BPrivate
using BPrivate::DiskDevice::KPhysicalPartition;
#endif // _K_DISK_DEVICE_PHYSICAL_PARTITION_H
@@ -0,0 +1,41 @@
// KPartition.h
#ifndef _K_DISK_DEVICE_SHADOW_PARTITION_H
#define _K_DISK_DEVICE_SHADOW_PARTITION_H
#include "KPartition.h"
namespace BPrivate {
namespace DiskDevice {
class KPhysicalPartition;
class KShadowPartition : public KPartition {
public:
KShadowPartition(KPhysicalPartition *physicalPartition);
virtual ~KShadowPartition();
// Hierarchy
virtual status_t CreateChild(partition_id id, int32 index,
KPartition **child = NULL);
// Shadow Partition
virtual KShadowPartition *ShadowPartition();
virtual bool IsShadowPartition() const;
void SetPhysicalPartition(KPhysicalPartition *partition);
virtual KPhysicalPartition *PhysicalPartition();
virtual void Dump(bool deep, int32 level);
protected:
KPhysicalPartition *fPhysicalPartition;
};
} // namespace DiskDevice
} // namespace BPrivate
using BPrivate::DiskDevice::KShadowPartition;
#endif // _K_DISK_DEVICE_SHADOW_PARTITION_H