* More shadow partition support.
* Writing disk device/partition data into userland buffer added. * Migration of some definitions into <DiskDeviceDefs.h> header. * Small bug fixes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3882 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,16 +8,11 @@
|
||||
#include "KPhysicalPartition.h"
|
||||
#include "RWLocker.h"
|
||||
|
||||
// disk device flags
|
||||
// TODO: move to another header (must be accessible from userland API impl.)
|
||||
enum {
|
||||
B_DISK_DEVICE_REMOVABLE = 0x01,
|
||||
B_DISK_DEVICE_HAS_MEDIA = 0x02,
|
||||
};
|
||||
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
class UserDataWriter;
|
||||
|
||||
class KDiskDevice : public KPhysicalPartition {
|
||||
public:
|
||||
KDiskDevice(partition_id id = -1);
|
||||
@@ -69,6 +64,8 @@ public:
|
||||
void SetShadowOwner(team_id team);
|
||||
team_id ShadowOwner() const;
|
||||
|
||||
void WriteUserData(UserDataWriter &writer, bool shadow);
|
||||
|
||||
virtual void Dump(bool deep = true, int32 level = 0);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -7,21 +7,13 @@
|
||||
|
||||
#include "disk_device_manager.h"
|
||||
|
||||
// partition flags
|
||||
// TODO: move to another header (must be accessible from userland API impl.)
|
||||
enum {
|
||||
B_PARTITION_IS_DEVICE = 0x01,
|
||||
B_PARTITION_MOUNTABLE = 0x02,
|
||||
B_PARTITION_PARTITIONABLE = 0x04,
|
||||
B_PARTITION_READ_ONLY = 0x08,
|
||||
B_PARTITION_MOUNTED = 0x10, // needed?
|
||||
B_PARTITION_BUSY = 0x20,
|
||||
B_PARTITION_DESCENDANT_BUSY = 0x40,
|
||||
};
|
||||
struct user_partition_data;
|
||||
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
class UserDataWriter;
|
||||
|
||||
class KDiskDevice;
|
||||
class KDiskSystem;
|
||||
class KPhysicalPartition;
|
||||
@@ -142,9 +134,9 @@ public:
|
||||
|
||||
virtual status_t CreateShadowPartition(); // creates a complete tree
|
||||
virtual void DeleteShadowPartition(); // deletes ...
|
||||
virtual KShadowPartition *ShadowPartition() = 0;
|
||||
virtual KShadowPartition *ShadowPartition() const = 0;
|
||||
virtual bool IsShadowPartition() const = 0;
|
||||
virtual KPhysicalPartition *PhysicalPartition() = 0;
|
||||
virtual KPhysicalPartition *PhysicalPartition() const = 0;
|
||||
|
||||
// DiskSystem
|
||||
|
||||
@@ -161,6 +153,8 @@ public:
|
||||
void SetContentCookie(void *cookie);
|
||||
void *ContentCookie() const;
|
||||
|
||||
void WriteUserData(UserDataWriter &writer, user_partition_data *data);
|
||||
|
||||
virtual void Dump(bool deep, int32 level);
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,9 +35,9 @@ public:
|
||||
|
||||
virtual status_t CreateShadowPartition(); // creates a complete tree
|
||||
virtual void DeleteShadowPartition(); // deletes ...
|
||||
virtual KShadowPartition *ShadowPartition();
|
||||
virtual KShadowPartition *ShadowPartition() const;
|
||||
virtual bool IsShadowPartition() const;
|
||||
virtual KPhysicalPartition *PhysicalPartition();
|
||||
virtual KPhysicalPartition *PhysicalPartition() const;
|
||||
|
||||
// DiskSystem
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ public:
|
||||
|
||||
// Shadow Partition
|
||||
|
||||
virtual KShadowPartition *ShadowPartition();
|
||||
virtual KShadowPartition *ShadowPartition() const;
|
||||
virtual bool IsShadowPartition() const;
|
||||
void SetPhysicalPartition(KPhysicalPartition *partition);
|
||||
virtual KPhysicalPartition *PhysicalPartition();
|
||||
void UnsetPhysicalPartition();
|
||||
virtual KPhysicalPartition *PhysicalPartition() const;
|
||||
|
||||
void SyncWithPhysicalPartition();
|
||||
|
||||
virtual void Dump(bool deep, int32 level);
|
||||
|
||||
|
||||
@@ -7,20 +7,13 @@
|
||||
#ifndef _DISK_DEVICE_MANAGER_H
|
||||
#define _DISK_DEVICE_MANAGER_H
|
||||
|
||||
#include <DiskDeviceDefs.h>
|
||||
#include <Drivers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO: These don't belong here. partition_id and disk_job_id are
|
||||
// public (exposed by the userland API), while disk_system_id is at least
|
||||
// known to the userland API, but probably exposed as well, as type of a
|
||||
// private member variable of BDiskSystem.
|
||||
typedef int32 partition_id;
|
||||
typedef int32 disk_system_id;
|
||||
typedef int32 disk_job_id;
|
||||
|
||||
// C API partition representation
|
||||
typedef struct partition_data {
|
||||
partition_id id;
|
||||
|
||||
@@ -6,11 +6,12 @@ SEARCH_SOURCE += [ FDirName $(OBOS_TOP) src kits storage ] ;
|
||||
|
||||
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
|
||||
UsePrivateHeaders [ FDirName kernel util ] ;
|
||||
UsePrivateHeaders [ FDirName shared ] ;
|
||||
UsePrivateHeaders [ FDirName storage ] ;
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders storage ;
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src tests kits storage virtualdrive ] ;
|
||||
|
||||
SharedLibrary disk_device_manager :
|
||||
ddm_user_interface.cpp
|
||||
disk_device_manager.cpp
|
||||
KDiskDevice.cpp
|
||||
KDiskDeviceJob.cpp
|
||||
@@ -24,6 +25,7 @@ SharedLibrary disk_device_manager :
|
||||
KPartitioningSystem.cpp
|
||||
KPhysicalPartition.cpp
|
||||
KShadowPartition.cpp
|
||||
UserDataWriter.cpp
|
||||
|
||||
# jobs
|
||||
KCreateChildJob.cpp
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
|
||||
#include <Drivers.h>
|
||||
|
||||
#include "ddm_userland_interface.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KShadowPartition.h"
|
||||
#include "UserDataWriter.h"
|
||||
|
||||
// debugging
|
||||
//#define DBG(x)
|
||||
@@ -262,6 +265,24 @@ KDiskDevice::ShadowOwner() const
|
||||
return fShadowOwner;
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KDiskDevice::WriteUserData(UserDataWriter &writer, bool shadow)
|
||||
{
|
||||
KPartition *partition = (shadow ? ShadowPartition() : this);
|
||||
if (!partition)
|
||||
partition = this;
|
||||
user_disk_device_data *data
|
||||
= writer.AllocateDeviceData(partition->CountChildren());
|
||||
char *path = writer.PlaceString(Path());
|
||||
if (data) {
|
||||
data->device_flags = DeviceFlags();
|
||||
data->path = path;
|
||||
partition->WriteUserData(writer, &data->device_partition_data);
|
||||
} else
|
||||
partition->WriteUserData(writer, NULL);
|
||||
}
|
||||
|
||||
// Dump
|
||||
void
|
||||
KDiskDevice::Dump(bool deep, int32 level)
|
||||
@@ -302,5 +323,6 @@ KDiskDevice::_InitPartitionData()
|
||||
* fDeviceData.geometry.sectors_per_track
|
||||
* fDeviceData.geometry.cylinder_count
|
||||
* fDeviceData.geometry.head_count;
|
||||
fPartitionData.flags |= B_PARTITION_IS_DEVICE;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
#include <Drivers.h>
|
||||
#include <Errors.h>
|
||||
|
||||
#include "ddm_userland_interface.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceManager.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KDiskSystem.h"
|
||||
#include "KPartition.h"
|
||||
#include "UserDataWriter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -714,6 +716,47 @@ KPartition::ContentCookie() const
|
||||
return fPartitionData.content_cookie;
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KPartition::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
||||
{
|
||||
// allocate
|
||||
char *name = writer.PlaceString(Name());
|
||||
char *contentName = writer.PlaceString(ContentName());
|
||||
char *type = writer.PlaceString(Type());
|
||||
char *contentType = writer.PlaceString(ContentType());
|
||||
char *parameters = writer.PlaceString(Parameters());
|
||||
char *contentParameters = writer.PlaceString(ContentParameters());
|
||||
// fill in data
|
||||
if (data) {
|
||||
data->id = ID();
|
||||
data->offset = Offset();
|
||||
data->size = Size();
|
||||
data->block_size = BlockSize();
|
||||
data->status = Status();
|
||||
data->flags = Flags();
|
||||
data->volume = VolumeID();
|
||||
data->index = Index();
|
||||
data->change_counter = ChangeCounter();
|
||||
data->disk_system = (DiskSystem() ? DiskSystem()->ID() : -1);
|
||||
data->name = name;
|
||||
data->content_name = contentName;
|
||||
data->type = type;
|
||||
data->content_type = contentType;
|
||||
data->parameters = parameters;
|
||||
data->content_parameters = contentParameters;
|
||||
data->child_count = CountChildren();
|
||||
}
|
||||
// children
|
||||
for (int32 i = 0; KPartition *child = ChildAt(i); i++) {
|
||||
user_partition_data *childData
|
||||
= writer.AllocatePartitionData(child->CountChildren());
|
||||
if (data)
|
||||
data->children[i] = childData;
|
||||
child->WriteUserData(writer, childData);
|
||||
}
|
||||
}
|
||||
|
||||
// Dump
|
||||
void
|
||||
KPartition::Dump(bool deep, int32 level)
|
||||
|
||||
@@ -199,7 +199,7 @@ KPhysicalPartition::DeleteShadowPartition()
|
||||
// delete the thing
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (ManagerLocker locker = manager) {
|
||||
fShadowPartition->SetPhysicalPartition(NULL);
|
||||
fShadowPartition->UnsetPhysicalPartition();
|
||||
PartitionRegistrar _(fShadowPartition);
|
||||
manager->PartitionRemoved(fShadowPartition);
|
||||
fShadowPartition = NULL;
|
||||
@@ -208,7 +208,7 @@ KPhysicalPartition::DeleteShadowPartition()
|
||||
|
||||
// ShadowPartition
|
||||
KShadowPartition *
|
||||
KPhysicalPartition::ShadowPartition()
|
||||
KPhysicalPartition::ShadowPartition() const
|
||||
{
|
||||
return fShadowPartition;
|
||||
}
|
||||
@@ -222,9 +222,9 @@ KPhysicalPartition::IsShadowPartition() const
|
||||
|
||||
// PhysicalPartition
|
||||
KPhysicalPartition *
|
||||
KPhysicalPartition::PhysicalPartition()
|
||||
KPhysicalPartition::PhysicalPartition() const
|
||||
{
|
||||
return this;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Dump
|
||||
|
||||
@@ -25,9 +25,9 @@ using namespace std;
|
||||
// constructor
|
||||
KShadowPartition::KShadowPartition(KPhysicalPartition *partition)
|
||||
: KPartition(),
|
||||
fPhysicalPartition(NULL)
|
||||
fPhysicalPartition(partition)
|
||||
{
|
||||
SetPhysicalPartition(partition);
|
||||
SyncWithPhysicalPartition();
|
||||
}
|
||||
|
||||
// destructor
|
||||
@@ -68,26 +68,45 @@ KShadowPartition::IsShadowPartition() const
|
||||
|
||||
// ShadowPartition
|
||||
KShadowPartition*
|
||||
KShadowPartition::ShadowPartition()
|
||||
KShadowPartition::ShadowPartition() const
|
||||
{
|
||||
return this;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// SetPhysicalPartition
|
||||
// UnsetPhysicalPartition
|
||||
void
|
||||
KShadowPartition::SetPhysicalPartition(KPhysicalPartition *partition)
|
||||
KShadowPartition::UnsetPhysicalPartition()
|
||||
{
|
||||
fPhysicalPartition = partition;
|
||||
// TODO: clone the data of the physical partition.
|
||||
fPhysicalPartition = NULL;
|
||||
}
|
||||
|
||||
// PhysicalPartition
|
||||
KPhysicalPartition*
|
||||
KShadowPartition::PhysicalPartition()
|
||||
KShadowPartition::PhysicalPartition() const
|
||||
{
|
||||
return fPhysicalPartition;
|
||||
}
|
||||
|
||||
// SyncWithPhysicalPartition
|
||||
void
|
||||
KShadowPartition::SyncWithPhysicalPartition()
|
||||
{
|
||||
if (!fPhysicalPartition)
|
||||
return;
|
||||
SetDevice(fPhysicalPartition->Device());
|
||||
SetDiskSystem(fPhysicalPartition->DiskSystem());
|
||||
SetOffset(fPhysicalPartition->Offset());
|
||||
SetSize(fPhysicalPartition->Size());
|
||||
SetBlockSize(fPhysicalPartition->BlockSize());
|
||||
SetStatus(fPhysicalPartition->Status());
|
||||
SetFlags(fPhysicalPartition->Flags());
|
||||
SetVolumeID(fPhysicalPartition->VolumeID());
|
||||
SetName(fPhysicalPartition->Name());
|
||||
SetContentName(fPhysicalPartition->ContentName());
|
||||
SetParameters(fPhysicalPartition->Parameters());
|
||||
SetContentParameters(fPhysicalPartition->ContentParameters());
|
||||
}
|
||||
|
||||
// Dump
|
||||
void
|
||||
KShadowPartition::Dump(bool deep, int32 level)
|
||||
|
||||
Reference in New Issue
Block a user