Added a KPartition listener mechanism and made use of it to keep shadow partitions with the corresponding physical ones in sync.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4848 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-09-28 22:04:13 +00:00
parent 373c8e3751
commit 58bdbab626
6 changed files with 779 additions and 39 deletions

View File

@ -3,10 +3,9 @@
#ifndef _K_DISK_DEVICE_PARTITION_H
#define _K_DISK_DEVICE_PARTITION_H
#include <disk_device_manager.h>
#include <Vector.h>
#include "disk_device_manager.h"
struct user_partition_data;
namespace BPrivate {
@ -16,6 +15,7 @@ class UserDataWriter;
class KDiskDevice;
class KDiskSystem;
class KPartitionListener;
class KPartitionVisitor;
class KPhysicalPartition;
class KShadowPartition;
@ -164,6 +164,11 @@ public:
void SetContentCookie(void *cookie);
void *ContentCookie() const;
// Listener Support
bool AddListener(KPartitionListener *listener);
bool RemoveListener(KPartitionListener *listener);
// Change Tracking
void Changed(uint32 flags, uint32 clearFlags = 0);
@ -181,18 +186,42 @@ public:
virtual void Dump(bool deep, int32 level);
protected:
void FireOffsetChanged(off_t offset);
void FireSizeChanged(off_t size);
void FireContentSizeChanged(off_t size);
void FireBlockSizeChanged(uint32 blockSize);
void FireIndexChanged(int32 index);
void FireStatusChanged(uint32 status);
void FireFlagsChanged(uint32 flags);
void FireNameChanged(const char *name);
void FireContentNameChanged(const char *name);
void FireTypeChanged(const char *type);
void FireIDChanged(partition_id id);
void FireVolumeIDChanged(dev_t volumeID);
void FireMountCookieChanged(void *cookie);
void FireParametersChanged(const char *parameters);
void FireContentParametersChanged(const char *parameters);
void FireChildAdded(KPartition *child, int32 index);
void FireChildRemoved(KPartition *child, int32 index);
void FireDiskSystemChanged(KDiskSystem *diskSystem);
void FireCookieChanged(void *cookie);
void FireContentCookieChanged(void *cookie);
private:
void _UpdateChildIndices(int32 index);
static int32 _NextID();
protected:
typedef Vector<KPartition*> PartitionVector;
struct ListenerSet;
partition_data fPartitionData;
PartitionVector fChildren;
KDiskDevice *fDevice;
KPartition *fParent;
KDiskSystem *fDiskSystem;
ListenerSet *fListeners;
uint32 fChangeFlags;
int32 fChangeCounter;
uint32 fAlgorithmData;

View File

@ -0,0 +1,51 @@
// KPartitionListener.h
#ifndef _K_DISK_DEVICE_PARTITION_LISTENER_H
#define _K_DISK_DEVICE_PARTITION_LISTENER_H
#include "disk_device_manager.h"
namespace BPrivate {
namespace DiskDevice {
class KDiskSystem;
class KPartition;
class KPartitionListener {
public:
KPartitionListener();
virtual ~KPartitionListener();
virtual void OffsetChanged(KPartition *partition, off_t offset);
virtual void SizeChanged(KPartition *partition, off_t size);
virtual void ContentSizeChanged(KPartition *partition, off_t size);
virtual void BlockSizeChanged(KPartition *partition, uint32 blockSize);
virtual void IndexChanged(KPartition *partition, int32 index);
virtual void StatusChanged(KPartition *partition, uint32 status);
virtual void FlagsChanged(KPartition *partition, uint32 flags);
virtual void NameChanged(KPartition *partition, const char *name);
virtual void ContentNameChanged(KPartition *partition, const char *name);
virtual void TypeChanged(KPartition *partition, const char *type);
virtual void IDChanged(KPartition *partition, partition_id id);
virtual void VolumeIDChanged(KPartition *partition, dev_t volumeID);
virtual void MountCookieChanged(KPartition *partition, void *cookie);
virtual void ParametersChanged(KPartition *partition,
const char *parameters);
virtual void ContentParametersChanged(KPartition *partition,
const char *parameters);
virtual void ChildAdded(KPartition *partition, KPartition *child,
int32 index);
virtual void ChildRemoved(KPartition *partition, KPartition *child,
int32 index);
virtual void DiskSystemChanged(KPartition *partition,
KDiskSystem *diskSystem);
virtual void CookieChanged(KPartition *partition, void *cookie);
virtual void ContentCookieChanged(KPartition *partition, void *cookie);
};
} // namespace DiskDevice
} // namespace BPrivate
using BPrivate::DiskDevice::KPartitionListener;
#endif // _K_DISK_DEVICE_PARTITION_LISTENER_H

View File

@ -3,14 +3,15 @@
#ifndef _K_DISK_DEVICE_SHADOW_PARTITION_H
#define _K_DISK_DEVICE_SHADOW_PARTITION_H
#include "KPartition.h"
#include <KPartition.h>
#include <KPartitionListener.h>
namespace BPrivate {
namespace DiskDevice {
class KPhysicalPartition;
class KShadowPartition : public KPartition {
class KShadowPartition : public KPartition, private KPartitionListener {
public:
KShadowPartition(KPhysicalPartition *physicalPartition);
virtual ~KShadowPartition();
@ -34,8 +35,36 @@ public:
virtual void Dump(bool deep, int32 level);
protected:
private:
virtual void OffsetChanged(KPartition *partition, off_t offset);
virtual void SizeChanged(KPartition *partition, off_t size);
virtual void ContentSizeChanged(KPartition *partition, off_t size);
virtual void BlockSizeChanged(KPartition *partition, uint32 blockSize);
virtual void IndexChanged(KPartition *partition, int32 index);
virtual void StatusChanged(KPartition *partition, uint32 status);
virtual void FlagsChanged(KPartition *partition, uint32 flags);
virtual void NameChanged(KPartition *partition, const char *name);
virtual void ContentNameChanged(KPartition *partition, const char *name);
virtual void TypeChanged(KPartition *partition, const char *type);
virtual void IDChanged(KPartition *partition, partition_id id);
virtual void VolumeIDChanged(KPartition *partition, dev_t volumeID);
virtual void MountCookieChanged(KPartition *partition, void *cookie);
virtual void ParametersChanged(KPartition *partition,
const char *parameters);
virtual void ContentParametersChanged(KPartition *partition,
const char *parameters);
virtual void ChildAdded(KPartition *partition, KPartition *child,
int32 index);
virtual void ChildRemoved(KPartition *partition, KPartition *child,
int32 index);
virtual void DiskSystemChanged(KPartition *partition,
KDiskSystem *diskSystem);
virtual void CookieChanged(KPartition *partition, void *cookie);
virtual void ContentCookieChanged(KPartition *partition, void *cookie);
private:
KPhysicalPartition *fPhysicalPartition;
};
} // namespace DiskDevice

View File

@ -10,13 +10,16 @@
#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 "KPartitionVisitor.h"
#include <ddm_userland_interface.h>
#include <KDiskDevice.h>
#include <KDiskDeviceManager.h>
#include <KDiskDeviceUtils.h>
#include <KDiskSystem.h>
#include <KPartition.h>
#include <KPartitionListener.h>
#include <KPartitionVisitor.h>
#include <VectorSet.h>
#include "UserDataWriter.h"
using namespace std;
@ -26,6 +29,9 @@ using namespace std;
#define DBG(x) x
#define OUT printf
// ListenerSet
struct KPartition::ListenerSet : VectorSet<KPartitionListener*> {};
// constructor
KPartition::KPartition(partition_id id)
: fPartitionData(),
@ -33,6 +39,7 @@ KPartition::KPartition(partition_id id)
fDevice(NULL),
fParent(NULL),
fDiskSystem(NULL),
fListeners(NULL),
fChangeFlags(0),
fChangeCounter(0),
fAlgorithmData(0),
@ -63,6 +70,7 @@ KPartition::KPartition(partition_id id)
// destructor
KPartition::~KPartition()
{
delete fListeners;
SetDiskSystem(NULL);
free(fPartitionData.name);
free(fPartitionData.content_name);
@ -234,7 +242,10 @@ KPartition::IsDescendantBusy() const
void
KPartition::SetOffset(off_t offset)
{
fPartitionData.offset = offset;
if (fPartitionData.offset != offset) {
fPartitionData.offset = offset;
FireOffsetChanged(offset);
}
}
// Offset
@ -248,7 +259,10 @@ KPartition::Offset() const
void
KPartition::SetSize(off_t size)
{
fPartitionData.size = size;
if (fPartitionData.size != size) {
fPartitionData.size = size;
FireSizeChanged(size);
}
}
// Size
@ -262,7 +276,10 @@ KPartition::Size() const
void
KPartition::SetContentSize(off_t size)
{
fPartitionData.content_size = size;
if (fPartitionData.content_size != size) {
fPartitionData.content_size = size;
FireContentSizeChanged(size);
}
}
// ContentSize
@ -276,7 +293,10 @@ KPartition::ContentSize() const
void
KPartition::SetBlockSize(uint32 blockSize)
{
fPartitionData.block_size = blockSize;
if (fPartitionData.block_size != blockSize) {
fPartitionData.block_size = blockSize;
FireBlockSizeChanged(blockSize);
}
}
// BlockSize
@ -290,7 +310,10 @@ KPartition::BlockSize() const
void
KPartition::SetIndex(int32 index)
{
fPartitionData.index = index;
if (fPartitionData.index != index) {
fPartitionData.index = index;
FireIndexChanged(index);
}
}
// Index
@ -304,7 +327,10 @@ KPartition::Index() const
void
KPartition::SetStatus(uint32 status)
{
fPartitionData.status = status;
if (fPartitionData.status != status) {
fPartitionData.status = status;
FireStatusChanged(status);
}
}
// Status
@ -325,21 +351,30 @@ KPartition::IsUninitialized() const
void
KPartition::SetFlags(uint32 flags)
{
fPartitionData.flags = flags;
if (fPartitionData.flags != flags) {
fPartitionData.flags = flags;
FireFlagsChanged(flags);
}
}
// AddFlags
void
KPartition::AddFlags(uint32 flags)
{
fPartitionData.flags |= flags;
if (~fPartitionData.flags & flags) {
fPartitionData.flags |= flags;
FireFlagsChanged(fPartitionData.flags);
}
}
// ClearFlags
void
KPartition::ClearFlags(uint32 flags)
{
fPartitionData.flags &= ~flags;
if (fPartitionData.flags & flags) {
fPartitionData.flags &= ~flags;
FireFlagsChanged(fPartitionData.flags);
}
}
// Flags
@ -388,7 +423,9 @@ KPartition::IsDevice() const
status_t
KPartition::SetName(const char *name)
{
return set_string(fPartitionData.name, name);
status_t error = set_string(fPartitionData.name, name);
FireNameChanged(fPartitionData.name);
return error;
}
// Name
@ -402,7 +439,9 @@ KPartition::Name() const
status_t
KPartition::SetContentName(const char *name)
{
return set_string(fPartitionData.content_name, name);
status_t error = set_string(fPartitionData.content_name, name);
FireContentNameChanged(fPartitionData.content_name);
return error;
}
// ContentName
@ -416,7 +455,9 @@ KPartition::ContentName() const
status_t
KPartition::SetType(const char *type)
{
return set_string(fPartitionData.type, type);
status_t error = set_string(fPartitionData.type, type);
FireTypeChanged(fPartitionData.type);
return error;
}
// Type
@ -451,7 +492,10 @@ KPartition::PartitionData() const
void
KPartition::SetID(partition_id id)
{
fPartitionData.id = id;
if (fPartitionData.id != id) {
fPartitionData.id = id;
FireIDChanged(id);
}
}
// ID
@ -497,11 +541,14 @@ KPartition::GetPath(char *path) const
void
KPartition::SetVolumeID(dev_t volumeID)
{
fPartitionData.volume = volumeID;
if (VolumeID() >= 0)
AddFlags(B_PARTITION_MOUNTED);
else
ClearFlags(B_PARTITION_MOUNTED);
if (fPartitionData.volume != volumeID) {
fPartitionData.volume = volumeID;
FireVolumeIDChanged(volumeID);
if (VolumeID() >= 0)
AddFlags(B_PARTITION_MOUNTED);
else
ClearFlags(B_PARTITION_MOUNTED);
}
}
// VolumeID
@ -515,7 +562,10 @@ KPartition::VolumeID() const
void
KPartition::SetMountCookie(void *cookie)
{
fPartitionData.mount_cookie = cookie;
if (fPartitionData.mount_cookie != cookie) {
fPartitionData.mount_cookie = cookie;
FireMountCookieChanged(cookie);
}
}
// MountCookie
@ -545,7 +595,9 @@ KPartition::Unmount()
status_t
KPartition::SetParameters(const char *parameters)
{
return set_string(fPartitionData.parameters, parameters);
status_t error = set_string(fPartitionData.parameters, parameters);
FireParametersChanged(fPartitionData.parameters);
return error;
}
// Parameters
@ -559,7 +611,9 @@ KPartition::Parameters() const
status_t
KPartition::SetContentParameters(const char *parameters)
{
return set_string(fPartitionData.content_parameters, parameters);
status_t error = set_string(fPartitionData.content_parameters, parameters);
FireContentParametersChanged(fPartitionData.content_parameters);
return error;
}
// ContentParameters
@ -625,6 +679,8 @@ KPartition::AddChild(KPartition *partition, int32 index)
fPartitionData.child_count++;
partition->SetParent(this);
partition->SetDevice(Device());
// notify listeners
FireChildAdded(partition, index);
return B_OK;
}
return B_ERROR;
@ -649,6 +705,8 @@ KPartition::RemoveChild(int32 index)
fPartitionData.child_count--;
partition->SetParent(NULL);
partition->SetDevice(NULL);
// notify listeners
FireChildAdded(partition, index);
return true;
}
return false;
@ -757,6 +815,8 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
else
AddFlags(B_PARTITION_PARTITIONING_SYSTEM);
}
// notify listeners
FireDiskSystemChanged(fDiskSystem);
}
// DiskSystem
@ -777,7 +837,10 @@ KPartition::ParentDiskSystem() const
void
KPartition::SetCookie(void *cookie)
{
fPartitionData.cookie = cookie;
if (fPartitionData.cookie != cookie) {
fPartitionData.cookie = cookie;
FireCookieChanged(cookie);
}
}
// Cookie
@ -791,7 +854,10 @@ KPartition::Cookie() const
void
KPartition::SetContentCookie(void *cookie)
{
fPartitionData.content_cookie = cookie;
if (fPartitionData.content_cookie != cookie) {
fPartitionData.content_cookie = cookie;
FireContentCookieChanged(cookie);
}
}
// ContentCookie
@ -801,6 +867,37 @@ KPartition::ContentCookie() const
return fPartitionData.content_cookie;
}
// AddListener
bool
KPartition::AddListener(KPartitionListener *listener)
{
if (!listener)
return false;
// lazy create listeners
if (!fListeners) {
fListeners = new(nothrow) ListenerSet;
if (!fListeners)
return false;
}
// add listener
return (fListeners->Insert(listener) == B_OK);
}
// RemoveListener
bool
KPartition::RemoveListener(KPartitionListener *listener)
{
if (!listener || !fListeners)
return false;
// remove listener and delete the set, if empty now
bool result = (fListeners->Remove(listener) > 0);
if (fListeners->IsEmpty()) {
delete fListeners;
fListeners = NULL;
}
return result;
}
// Changed
void
KPartition::Changed(uint32 flags, uint32 clearFlags)
@ -850,8 +947,6 @@ KPartition::UninitializeContents(bool logChanges)
}
// volume
if (VolumeID() >= 0) {
// TODO: More? Unmounting would be a bit drastical for changes
// only on a shadow partition.
SetVolumeID(-1);
flags |= B_PARTITION_CHANGED_VOLUME;
}
@ -995,6 +1090,246 @@ KPartition::Dump(bool deep, int32 level)
}
}
// FireOffsetChanged
void
KPartition::FireOffsetChanged(off_t offset)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->OffsetChanged(this, offset);
}
}
}
// FireSizeChanged
void
KPartition::FireSizeChanged(off_t size)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->SizeChanged(this, size);
}
}
}
// FireContentSizeChanged
void
KPartition::FireContentSizeChanged(off_t size)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ContentSizeChanged(this, size);
}
}
}
// FireBlockSizeChanged
void
KPartition::FireBlockSizeChanged(uint32 blockSize)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->BlockSizeChanged(this, blockSize);
}
}
}
// FireIndexChanged
void
KPartition::FireIndexChanged(int32 index)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->IndexChanged(this, index);
}
}
}
// FireStatusChanged
void
KPartition::FireStatusChanged(uint32 status)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->StatusChanged(this, status);
}
}
}
// FireFlagsChanged
void
KPartition::FireFlagsChanged(uint32 flags)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->FlagsChanged(this, flags);
}
}
}
// FireNameChanged
void
KPartition::FireNameChanged(const char *name)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->NameChanged(this, name);
}
}
}
// FireContentNameChanged
void
KPartition::FireContentNameChanged(const char *name)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ContentNameChanged(this, name);
}
}
}
// FireTypeChanged
void
KPartition::FireTypeChanged(const char *type)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->TypeChanged(this, type);
}
}
}
// FireIDChanged
void
KPartition::FireIDChanged(partition_id id)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->IDChanged(this, id);
}
}
}
// FireVolumeIDChanged
void
KPartition::FireVolumeIDChanged(dev_t volumeID)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->VolumeIDChanged(this, volumeID);
}
}
}
// FireMountCookieChanged
void
KPartition::FireMountCookieChanged(void *cookie)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->MountCookieChanged(this, cookie);
}
}
}
// FireParametersChanged
void
KPartition::FireParametersChanged(const char *parameters)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ParametersChanged(this, parameters);
}
}
}
// FireContentParametersChanged
void
KPartition::FireContentParametersChanged(const char *parameters)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ContentParametersChanged(this, parameters);
}
}
}
// FireChildAdded
void
KPartition::FireChildAdded(KPartition *child, int32 index)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ChildAdded(this, child, index);
}
}
}
// FireChildRemoved
void
KPartition::FireChildRemoved(KPartition *child, int32 index)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ChildRemoved(this, child, index);
}
}
}
// FireDiskSystemChanged
void
KPartition::FireDiskSystemChanged(KDiskSystem *diskSystem)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->DiskSystemChanged(this, diskSystem);
}
}
}
// FireCookieChanged
void
KPartition::FireCookieChanged(void *cookie)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->CookieChanged(this, cookie);
}
}
}
// FireContentCookieChanged
void
KPartition::FireContentCookieChanged(void *cookie)
{
if (fListeners) {
for (ListenerSet::Iterator it = fListeners->Begin();
it != fListeners->End(); ++it) {
(*it)->ContentCookieChanged(this, cookie);
}
}
}
// _UpdateChildIndices
void
KPartition::_UpdateChildIndices(int32 index)

View File

@ -0,0 +1,139 @@
// KPartitionListener.cpp
#include <KPartitionListener.h>
// constructor
KPartitionListener::KPartitionListener()
{
}
// destructor
KPartitionListener::~KPartitionListener()
{
}
// OffsetChanged
void
KPartitionListener::OffsetChanged(KPartition *partition, off_t offset)
{
}
// SizeChanged
void
KPartitionListener::SizeChanged(KPartition *partition, off_t size)
{
}
// ContentSizeChanged
void
KPartitionListener::ContentSizeChanged(KPartition *partition, off_t size)
{
}
// BlockSizeChanged
void
KPartitionListener::BlockSizeChanged(KPartition *partition, uint32 blockSize)
{
}
// IndexChanged
void
KPartitionListener::IndexChanged(KPartition *partition, int32 index)
{
}
// StatusChanged
void
KPartitionListener::StatusChanged(KPartition *partition, uint32 status)
{
}
// FlagsChanged
void
KPartitionListener::FlagsChanged(KPartition *partition, uint32 flags)
{
}
// NameChanged
void
KPartitionListener::NameChanged(KPartition *partition, const char *name)
{
}
// ContentNameChanged
void
KPartitionListener::ContentNameChanged(KPartition *partition, const char *name)
{
}
// TypeChanged
void
KPartitionListener::TypeChanged(KPartition *partition, const char *type)
{
}
// IDChanged
void
KPartitionListener::IDChanged(KPartition *partition, partition_id id)
{
}
// VolumeIDChanged
void
KPartitionListener::VolumeIDChanged(KPartition *partition, dev_t volumeID)
{
}
// MountCookieChanged
void
KPartitionListener::MountCookieChanged(KPartition *partition, void *cookie)
{
}
// ParametersChanged
void
KPartitionListener::ParametersChanged(KPartition *partition,
const char *parameters)
{
}
// ContentParametersChanged
void
KPartitionListener::ContentParametersChanged(KPartition *partition,
const char *parameters)
{
}
// ChildAdded
void
KPartitionListener::ChildAdded(KPartition *partition, KPartition *child,
int32 index)
{
}
// ChildRemoved
void
KPartitionListener::ChildRemoved(KPartition *partition, KPartition *child,
int32 index)
{
}
// DiskSystemChanged
void
KPartitionListener::DiskSystemChanged(KPartition *partition,
KDiskSystem *diskSystem)
{
}
// CookieChanged
void
KPartitionListener::CookieChanged(KPartition *partition, void *cookie)
{
}
// ContentCookieChanged
void
KPartitionListener::ContentCookieChanged(KPartition *partition, void *cookie)
{
}

View File

@ -26,14 +26,18 @@ using namespace std;
// constructor
KShadowPartition::KShadowPartition(KPhysicalPartition *partition)
: KPartition(),
KPartitionListener(),
fPhysicalPartition(partition)
{
SyncWithPhysicalPartition();
if (fPhysicalPartition)
fPhysicalPartition->AddListener(this);
}
// destructor
KShadowPartition::~KShadowPartition()
{
UnsetPhysicalPartition();
}
// CreateChild
@ -78,7 +82,10 @@ KShadowPartition::ShadowPartition() const
void
KShadowPartition::UnsetPhysicalPartition()
{
fPhysicalPartition = NULL;
if (fPhysicalPartition) {
fPhysicalPartition->RemoveListener(this);
fPhysicalPartition = NULL;
}
}
// PhysicalPartition
@ -108,7 +115,7 @@ KShadowPartition::SyncWithPhysicalPartition()
SetVolumeID(fPhysicalPartition->VolumeID());
SetParameters(fPhysicalPartition->Parameters());
SetContentParameters(fPhysicalPartition->ContentParameters());
// Cookie, ContentCookie, MountCookie?
// TODO: Cookie, ContentCookie, MountCookie?
}
// WriteUserData
@ -132,3 +139,153 @@ KShadowPartition::Dump(bool deep, int32 level)
KPartition::Dump(deep, level);
}
// OffsetChanged
void
KShadowPartition::OffsetChanged(KPartition *partition, off_t offset)
{
SetOffset(offset);
}
// SizeChanged
void
KShadowPartition::SizeChanged(KPartition *partition, off_t size)
{
SetSize(size);
}
// ContentSizeChanged
void
KShadowPartition::ContentSizeChanged(KPartition *partition, off_t size)
{
SetContentSize(size);
}
// BlockSizeChanged
void
KShadowPartition::BlockSizeChanged(KPartition *partition, uint32 blockSize)
{
SetBlockSize(blockSize);
}
// IndexChanged
void
KShadowPartition::IndexChanged(KPartition *partition, int32 index)
{
// should be set automatically
}
// StatusChanged
void
KShadowPartition::StatusChanged(KPartition *partition, uint32 status)
{
SetStatus(status);
}
// FlagsChanged
void
KShadowPartition::FlagsChanged(KPartition *partition, uint32 flags)
{
SetFlags(flags);
}
// NameChanged
void
KShadowPartition::NameChanged(KPartition *partition, const char *name)
{
SetName(name);
}
// ContentNameChanged
void
KShadowPartition::ContentNameChanged(KPartition *partition, const char *name)
{
SetContentName(name);
}
// TypeChanged
void
KShadowPartition::TypeChanged(KPartition *partition, const char *type)
{
SetType(type);
}
// IDChanged
void
KShadowPartition::IDChanged(KPartition *partition, partition_id id)
{
// nothing to do
}
// VolumeIDChanged
void
KShadowPartition::VolumeIDChanged(KPartition *partition, dev_t volumeID)
{
SetVolumeID(volumeID);
}
// MountCookieChanged
void
KShadowPartition::MountCookieChanged(KPartition *partition, void *cookie)
{
// TODO: set the mount cookie?
}
// ParametersChanged
void
KShadowPartition::ParametersChanged(KPartition *partition,
const char *parameters)
{
SetParameters(parameters);
}
// ContentParametersChanged
void
KShadowPartition::ContentParametersChanged(KPartition *partition,
const char *parameters)
{
SetContentParameters(parameters);
}
// ChildAdded
void
KShadowPartition::ChildAdded(KPartition *partition, KPartition *child,
int32 index)
{
// TODO: Mmh, in the CreateShadowPartition() phase, creating and
// adding the shadow partitions is done recursively and we shouldn't
// do that here. But when a new partition is added later?
// Maybe KPhysicalPartition::CreateChild() should create a shadow for
// the new child manually.
}
// ChildRemoved
void
KShadowPartition::ChildRemoved(KPartition *partition, KPartition *child,
int32 index)
{
// TODO: We could remove the corresponding partition, but for consistency
// we should proceed analogously to adding partitions.
}
// DiskSystemChanged
void
KShadowPartition::DiskSystemChanged(KPartition *partition,
KDiskSystem *diskSystem)
{
SetDiskSystem(diskSystem);
}
// CookieChanged
void
KShadowPartition::CookieChanged(KPartition *partition, void *cookie)
{
// TODO: set the cookie?
}
// ContentCookieChanged
void
KShadowPartition::ContentCookieChanged(KPartition *partition, void *cookie)
{
// TODO: set the content cookie?
}