Folded KPhysicalPartition into KPartition. Removed the notion of shadow
partitions from the disk device manager. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22800 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -97,7 +97,6 @@ int32 find_partition(const char *path);
|
||||
// disk device/partition read access
|
||||
// (read lock required)
|
||||
disk_device_data *get_disk_device(partition_id partitionID);
|
||||
partition_data *get_physical_partition(partition_id partitionID);
|
||||
partition_data *get_partition(partition_id partitionID);
|
||||
partition_data *get_parent_partition(partition_id partitionID);
|
||||
partition_data *get_child_partition(partition_id partitionID, int32 index);
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include "KPhysicalPartition.h"
|
||||
#include "KPartition.h"
|
||||
#include "RWLocker.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
|
||||
class UserDataWriter;
|
||||
|
||||
class KDiskDevice : public KPhysicalPartition {
|
||||
|
||||
class KDiskDevice : public KPartition {
|
||||
public:
|
||||
KDiskDevice(partition_id id = -1);
|
||||
virtual ~KDiskDevice();
|
||||
@@ -38,8 +41,6 @@ public:
|
||||
void WriteUnlock();
|
||||
bool IsWriteLocked();
|
||||
|
||||
virtual bool PrepareForRemoval();
|
||||
|
||||
virtual void SetID(partition_id id);
|
||||
|
||||
virtual status_t PublishDevice();
|
||||
@@ -70,14 +71,9 @@ public:
|
||||
disk_device_data *DeviceData();
|
||||
const disk_device_data *DeviceData() const;
|
||||
|
||||
status_t CreateShadowDevice(team_id team);
|
||||
status_t DeleteShadowDevice();
|
||||
void SetShadowOwner(team_id team);
|
||||
team_id ShadowOwner() const;
|
||||
|
||||
virtual void WriteUserData(UserDataWriter &writer,
|
||||
user_partition_data *data);
|
||||
void WriteUserData(UserDataWriter &writer, bool shadow);
|
||||
void WriteUserData(UserDataWriter &writer);
|
||||
|
||||
virtual void Dump(bool deep = true, int32 level = 0);
|
||||
|
||||
@@ -92,9 +88,9 @@ private:
|
||||
RWLocker fLocker;
|
||||
int fFD;
|
||||
status_t fMediaStatus;
|
||||
team_id fShadowOwner;
|
||||
};
|
||||
|
||||
|
||||
} // namespace DiskDevice
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ public:
|
||||
// manager must be locked
|
||||
KDiskDevice *FindDevice(const char *path);
|
||||
KDiskDevice *FindDevice(partition_id id, bool deviceOnly = true);
|
||||
KPartition *FindPartition(const char *path, bool noShadow = false);
|
||||
KPartition *FindPartition(partition_id id, bool noShadow = false);
|
||||
KPartition *FindPartition(const char *path);
|
||||
KPartition *FindPartition(partition_id id);
|
||||
KFileDiskDevice *FindFileDevice(const char *filePath);
|
||||
|
||||
KDiskDevice *RegisterDevice(const char *path);
|
||||
KDiskDevice *RegisterDevice(partition_id id, bool deviceOnly = true);
|
||||
KDiskDevice *RegisterNextDevice(int32 *cookie);
|
||||
KPartition *RegisterPartition(const char *path, bool noShadow = false);
|
||||
KPartition *RegisterPartition(partition_id id, bool noShadow = false);
|
||||
KPartition *RegisterPartition(const char *path);
|
||||
KPartition *RegisterPartition(partition_id id);
|
||||
KFileDiskDevice *RegisterFileDevice(const char *filePath);
|
||||
|
||||
KDiskDevice *ReadLockDevice(partition_id id, bool deviceOnly = true);
|
||||
|
||||
@@ -24,7 +24,6 @@ class KPartitionListener;
|
||||
class KPartitionVisitor;
|
||||
class KPath;
|
||||
class KPhysicalPartition;
|
||||
class KShadowPartition;
|
||||
|
||||
//! \brief Class representing a single partition.
|
||||
class KPartition {
|
||||
@@ -139,7 +138,7 @@ public:
|
||||
|
||||
status_t AddChild(KPartition *partition, int32 index = -1);
|
||||
virtual status_t CreateChild(partition_id id, int32 index,
|
||||
KPartition **child = NULL) = 0;
|
||||
KPartition **child = NULL);
|
||||
bool RemoveChild(int32 index);
|
||||
bool RemoveChild(KPartition *child);
|
||||
bool RemoveAllChildren();
|
||||
@@ -149,14 +148,6 @@ public:
|
||||
|
||||
KPartition *VisitEachDescendant(KPartitionVisitor *visitor);
|
||||
|
||||
// Shadow Partition
|
||||
|
||||
virtual status_t CreateShadowPartition(); // creates a complete tree
|
||||
virtual void UnsetShadowPartition(bool doDelete);
|
||||
virtual KShadowPartition *ShadowPartition() const = 0;
|
||||
virtual bool IsShadowPartition() const = 0;
|
||||
virtual KPhysicalPartition *PhysicalPartition() const = 0;
|
||||
|
||||
// DiskSystem
|
||||
|
||||
void SetDiskSystem(KDiskSystem *diskSystem);
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#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;
|
||||
|
||||
//! \brief Class representing an existing partition.
|
||||
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 UnsetShadowPartition(bool doDelete);
|
||||
virtual KShadowPartition *ShadowPartition() const;
|
||||
virtual bool IsShadowPartition() const;
|
||||
virtual KPhysicalPartition *PhysicalPartition() const;
|
||||
|
||||
// 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
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_SHADOW_PARTITION_H
|
||||
#define _K_DISK_DEVICE_SHADOW_PARTITION_H
|
||||
|
||||
#include <KPartition.h>
|
||||
#include <KPartitionListener.h>
|
||||
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
class KPhysicalPartition;
|
||||
|
||||
/*! \brief Class representing a shadow of an existing partition.
|
||||
|
||||
See \ref path_kernel_structures for more information.
|
||||
*/
|
||||
class KShadowPartition : public KPartition, private KPartitionListener {
|
||||
public:
|
||||
KShadowPartition(KPhysicalPartition *physicalPartition);
|
||||
virtual ~KShadowPartition();
|
||||
|
||||
// Hierarchy
|
||||
|
||||
virtual status_t CreateChild(partition_id id, int32 index,
|
||||
KPartition **child = NULL);
|
||||
|
||||
// Shadow Partition
|
||||
|
||||
virtual KShadowPartition *ShadowPartition() const;
|
||||
virtual bool IsShadowPartition() const;
|
||||
void UnsetPhysicalPartition();
|
||||
virtual KPhysicalPartition *PhysicalPartition() const;
|
||||
|
||||
void SyncWithPhysicalPartition();
|
||||
|
||||
virtual void WriteUserData(UserDataWriter &writer,
|
||||
user_partition_data *data);
|
||||
|
||||
virtual void Dump(bool deep, int32 level);
|
||||
|
||||
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
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::DiskDevice::KShadowPartition;
|
||||
|
||||
#endif // _K_DISK_DEVICE_SHADOW_PARTITION_H
|
||||
@@ -17,7 +17,6 @@ extern "C" {
|
||||
typedef struct user_partition_data user_partition_data;
|
||||
struct user_partition_data {
|
||||
partition_id id;
|
||||
partition_id shadow_id;
|
||||
off_t offset;
|
||||
off_t size;
|
||||
off_t content_size;
|
||||
@@ -70,8 +69,8 @@ partition_id _user_get_next_disk_device_id(int32 *cookie, size_t *neededSize);
|
||||
partition_id _user_find_disk_device(const char *filename, size_t *neededSize);
|
||||
partition_id _user_find_partition(const char *filename, size_t *neededSize);
|
||||
status_t _user_get_disk_device_data(partition_id deviceID, bool deviceOnly,
|
||||
bool shadow, user_disk_device_data *buffer,
|
||||
size_t bufferSize, size_t *neededSize);
|
||||
user_disk_device_data *buffer, size_t bufferSize,
|
||||
size_t *neededSize);
|
||||
|
||||
partition_id _user_register_file_device(const char *filename);
|
||||
status_t _user_unregister_file_device(partition_id deviceID,
|
||||
|
||||
@@ -324,8 +324,8 @@ extern status_t _kern_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu);
|
||||
extern partition_id _kern_get_next_disk_device_id(int32 *cookie, size_t *neededSize);
|
||||
extern partition_id _kern_find_disk_device(const char *filename, size_t *neededSize);
|
||||
extern partition_id _kern_find_partition(const char *filename, size_t *neededSize);
|
||||
extern status_t _kern_get_disk_device_data(partition_id deviceID, bool deviceOnly,
|
||||
bool shadow, struct user_disk_device_data *buffer,
|
||||
extern status_t _kern_get_disk_device_data(partition_id deviceID,
|
||||
bool deviceOnly, struct user_disk_device_data *buffer,
|
||||
size_t bufferSize, size_t *neededSize);
|
||||
extern partition_id _kern_register_file_device(const char *filename);
|
||||
extern status_t _kern_unregister_file_device(partition_id deviceID,
|
||||
|
||||
@@ -740,7 +740,7 @@ pm_shadow_changed(partition_data *partition, partition_data *child,
|
||||
case B_PARTITION_SHADOW:
|
||||
{
|
||||
// get the physical partition
|
||||
partition_data* physicalPartition = get_physical_partition(
|
||||
partition_data* physicalPartition = get_partition(
|
||||
partition->id);
|
||||
if (!physicalPartition) {
|
||||
dprintf("intel: pm_shadow_changed(B_PARTITION_SHADOW): no "
|
||||
@@ -774,7 +774,7 @@ pm_shadow_changed(partition_data *partition, partition_data *child,
|
||||
case B_PARTITION_SHADOW_CHILD:
|
||||
{
|
||||
// get the physical child partition
|
||||
partition_data* physical = get_physical_partition(child->id);
|
||||
partition_data* physical = get_partition(child->id);
|
||||
if (!physical) {
|
||||
dprintf("intel: pm_shadow_changed(B_PARTITION_SHADOW_CHILD): "
|
||||
"no physical partition with ID %ld\n", child->id);
|
||||
|
||||
@@ -366,7 +366,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, size_t neededSize,
|
||||
|
||||
status_t error = B_OK;
|
||||
do {
|
||||
error = _kern_get_disk_device_data(id, deviceOnly, false,
|
||||
error = _kern_get_disk_device_data(id, deviceOnly,
|
||||
(user_disk_device_data*)buffer, bufferSize, &neededSize);
|
||||
if (error == B_BUFFER_OVERFLOW) {
|
||||
// buffer to small re-allocate it
|
||||
|
||||
@@ -24,8 +24,6 @@ KernelMergeObject kernel_disk_device_manager.o :
|
||||
KPartitioningSystem.cpp
|
||||
KPartitionListener.cpp
|
||||
KPartitionVisitor.cpp
|
||||
KPhysicalPartition.cpp
|
||||
KShadowPartition.cpp
|
||||
UserDataWriter.cpp
|
||||
|
||||
# utilities
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "ddm_userland_interface.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KShadowPartition.h"
|
||||
#include "KPath.h"
|
||||
#include "UserDataWriter.h"
|
||||
|
||||
@@ -22,12 +21,11 @@
|
||||
|
||||
// constructor
|
||||
KDiskDevice::KDiskDevice(partition_id id)
|
||||
: KPhysicalPartition(id),
|
||||
: KPartition(id),
|
||||
fDeviceData(),
|
||||
fLocker("diskdevice"),
|
||||
fFD(-1),
|
||||
fMediaStatus(B_ERROR),
|
||||
fShadowOwner(-1)
|
||||
fMediaStatus(B_ERROR)
|
||||
{
|
||||
Unset();
|
||||
fDevice = this;
|
||||
@@ -98,7 +96,6 @@ KDiskDevice::Unset()
|
||||
fFD = -1;
|
||||
}
|
||||
fMediaStatus = B_ERROR;
|
||||
fShadowOwner = -1;
|
||||
fDeviceData.id = -1;
|
||||
fDeviceData.flags = 0;
|
||||
if (fDeviceData.path) {
|
||||
@@ -164,20 +161,12 @@ KDiskDevice::IsWriteLocked()
|
||||
return fLocker.IsWriteLocked();
|
||||
}
|
||||
|
||||
// PrepareForRemoval
|
||||
bool
|
||||
KDiskDevice::PrepareForRemoval()
|
||||
{
|
||||
if (ShadowOwner() >= 0)
|
||||
DeleteShadowDevice();
|
||||
return KPhysicalPartition::PrepareForRemoval();
|
||||
}
|
||||
|
||||
// SetID
|
||||
void
|
||||
KDiskDevice::SetID(partition_id id)
|
||||
{
|
||||
KPhysicalPartition::SetID(id);
|
||||
KPartition::SetID(id);
|
||||
fDeviceData.id = id;
|
||||
}
|
||||
|
||||
@@ -312,58 +301,19 @@ KDiskDevice::DeviceData() const
|
||||
return &fDeviceData;
|
||||
}
|
||||
|
||||
// CreateShadowDevice
|
||||
status_t
|
||||
KDiskDevice::CreateShadowDevice(team_id team)
|
||||
{
|
||||
if (fShadowOwner >= 0 || team < 0 || !HasMedia())
|
||||
return B_BAD_VALUE;
|
||||
// create the shadow partitions
|
||||
status_t error = CreateShadowPartition();
|
||||
if (error == B_OK)
|
||||
SetShadowOwner(team);
|
||||
return error;
|
||||
}
|
||||
|
||||
// DeleteShadowDevice
|
||||
status_t
|
||||
KDiskDevice::DeleteShadowDevice()
|
||||
{
|
||||
if (fShadowOwner < 0)
|
||||
return B_BAD_VALUE;
|
||||
UnsetShadowPartition(true);
|
||||
SetShadowOwner(-1);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// SetShadowOwner
|
||||
void
|
||||
KDiskDevice::SetShadowOwner(team_id team)
|
||||
{
|
||||
fShadowOwner = team;
|
||||
}
|
||||
|
||||
// ShadowOwner
|
||||
team_id
|
||||
KDiskDevice::ShadowOwner() const
|
||||
{
|
||||
return fShadowOwner;
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KDiskDevice::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
||||
{
|
||||
return KPhysicalPartition::WriteUserData(writer, data);
|
||||
return KPartition::WriteUserData(writer, data);
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KDiskDevice::WriteUserData(UserDataWriter &writer, bool shadow)
|
||||
KDiskDevice::WriteUserData(UserDataWriter &writer)
|
||||
{
|
||||
KPartition *partition = shadow ? ShadowPartition() : static_cast<KPartition *>(this);
|
||||
if (!partition)
|
||||
partition = this;
|
||||
KPartition *partition = this;
|
||||
user_disk_device_data *data
|
||||
= writer.AllocateDeviceData(partition->CountChildren());
|
||||
char *path = writer.PlaceString(Path());
|
||||
@@ -384,7 +334,7 @@ KDiskDevice::Dump(bool deep, int32 level)
|
||||
OUT(" media status: %s\n", strerror(fMediaStatus));
|
||||
OUT(" device flags: %lx\n", DeviceFlags());
|
||||
if (fMediaStatus == B_OK)
|
||||
KPhysicalPartition::Dump(deep, 0);
|
||||
KPartition::Dump(deep, 0);
|
||||
}
|
||||
|
||||
// GetMediaStatus
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "KPartitioningSystem.h"
|
||||
#include "KPartitionVisitor.h"
|
||||
#include "KPath.h"
|
||||
#include "KShadowPartition.h"
|
||||
|
||||
#include <VectorMap.h>
|
||||
#include <VectorSet.h>
|
||||
@@ -252,36 +251,34 @@ KDiskDeviceManager::FindDevice(partition_id id, bool deviceOnly)
|
||||
|
||||
// FindPartition
|
||||
KPartition *
|
||||
KDiskDeviceManager::FindPartition(const char *path, bool noShadow)
|
||||
KDiskDeviceManager::FindPartition(const char *path)
|
||||
{
|
||||
// TODO: Optimize!
|
||||
KPath partitionPath;
|
||||
if (partitionPath.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
|
||||
for (PartitionMap::Iterator it = fPartitions->Begin();
|
||||
it != fPartitions->End();
|
||||
++it) {
|
||||
KPartition *partition = it->Value();
|
||||
if (partition->GetPath(&partitionPath) == B_OK
|
||||
&& partitionPath == path) {
|
||||
if (noShadow && partition->IsShadowPartition())
|
||||
return partition->PhysicalPartition();
|
||||
return partition;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindPartition
|
||||
KPartition *
|
||||
KDiskDeviceManager::FindPartition(partition_id id, bool noShadow)
|
||||
KDiskDeviceManager::FindPartition(partition_id id)
|
||||
{
|
||||
PartitionMap::Iterator it = fPartitions->Find(id);
|
||||
if (it != fPartitions->End()) {
|
||||
if (noShadow && it->Value()->IsShadowPartition())
|
||||
return it->Value()->PhysicalPartition();
|
||||
if (it != fPartitions->End())
|
||||
return it->Value();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -342,10 +339,10 @@ KDiskDeviceManager::RegisterNextDevice(int32 *cookie)
|
||||
|
||||
// RegisterPartition
|
||||
KPartition *
|
||||
KDiskDeviceManager::RegisterPartition(const char *path, bool noShadow)
|
||||
KDiskDeviceManager::RegisterPartition(const char *path)
|
||||
{
|
||||
if (ManagerLocker locker = this) {
|
||||
if (KPartition *partition = FindPartition(path, noShadow)) {
|
||||
if (KPartition *partition = FindPartition(path)) {
|
||||
partition->Register();
|
||||
return partition;
|
||||
}
|
||||
@@ -355,10 +352,10 @@ KDiskDeviceManager::RegisterPartition(const char *path, bool noShadow)
|
||||
|
||||
// RegisterPartition
|
||||
KPartition *
|
||||
KDiskDeviceManager::RegisterPartition(partition_id id, bool noShadow)
|
||||
KDiskDeviceManager::RegisterPartition(partition_id id)
|
||||
{
|
||||
if (ManagerLocker locker = this) {
|
||||
if (KPartition *partition = FindPartition(id, noShadow)) {
|
||||
if (KPartition *partition = FindPartition(id)) {
|
||||
partition->Register();
|
||||
return partition;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
#include <ddm_userland_interface.h>
|
||||
#include <fs/devfs.h>
|
||||
#include <KDiskDevice.h>
|
||||
#include <KDiskDeviceManager.h>
|
||||
#include <KDiskDeviceUtils.h>
|
||||
@@ -147,22 +148,75 @@ KPartition::PrepareForDeletion()
|
||||
status_t
|
||||
KPartition::Open(int flags, int *fd)
|
||||
{
|
||||
return B_BAD_VALUE;
|
||||
if (!fd)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// open the device
|
||||
*fd = open(path.Path(), flags);
|
||||
if (*fd < 0)
|
||||
return errno;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// PublishDevice
|
||||
status_t
|
||||
KPartition::PublishDevice()
|
||||
{
|
||||
// we're just a stupid base class, what do we know?
|
||||
return B_ERROR;
|
||||
if (fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// prepare a partition_info
|
||||
partition_info info;
|
||||
info.offset = Offset();
|
||||
info.size = Size();
|
||||
info.logical_block_size = BlockSize();
|
||||
info.session = 0;
|
||||
info.partition = ID();
|
||||
if (strlcpy(info.device, Device()->Path(), B_PATH_NAME_LENGTH)
|
||||
>= B_PATH_NAME_LENGTH) {
|
||||
return B_NAME_TOO_LONG;
|
||||
}
|
||||
|
||||
error = devfs_publish_partition(path.Path() + 5, &info);
|
||||
// we need to remove the "/dev/" part from the path
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = true;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// UnpublishDevice
|
||||
status_t
|
||||
KPartition::UnpublishDevice()
|
||||
{
|
||||
return B_ERROR;
|
||||
if (!fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = false;
|
||||
|
||||
return devfs_unpublish_partition(path.Path() + 5);
|
||||
// we need to remove the "/dev/" part from the path
|
||||
}
|
||||
|
||||
|
||||
@@ -660,6 +714,35 @@ KPartition::AddChild(KPartition *partition, int32 index)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
// CreateChild
|
||||
status_t
|
||||
KPartition::CreateChild(partition_id id, int32 index, KPartition **_child)
|
||||
{
|
||||
// check parameters
|
||||
int32 count = fPartitionData.child_count;
|
||||
if (index == -1)
|
||||
index = count;
|
||||
if (index < 0 || index > count)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// create and add partition
|
||||
KPartition *child = new(nothrow) KPartition(id);
|
||||
if (!child)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
status_t error = AddChild(child, index);
|
||||
|
||||
// cleanup / set result
|
||||
if (error != B_OK)
|
||||
delete child;
|
||||
else if (_child)
|
||||
*_child = child;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
// RemoveChild
|
||||
bool
|
||||
KPartition::RemoveChild(int32 index)
|
||||
@@ -752,20 +835,6 @@ KPartition::VisitEachDescendant(KPartitionVisitor *visitor)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// CreateShadowPartition
|
||||
status_t
|
||||
KPartition::CreateShadowPartition()
|
||||
{
|
||||
// implemented by derived classes
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// UnsetShadowPartition
|
||||
void
|
||||
KPartition::UnsetShadowPartition(bool doDelete)
|
||||
{
|
||||
// implemented by derived classes
|
||||
}
|
||||
|
||||
// SetDiskSystem
|
||||
void
|
||||
@@ -991,7 +1060,6 @@ KPartition::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
||||
// fill in data
|
||||
if (data) {
|
||||
data->id = ID();
|
||||
data->shadow_id = -1;
|
||||
data->offset = Offset();
|
||||
data->size = Size();
|
||||
data->content_size = ContentSize();
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
// KPhysicalPartition.cpp
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Drivers.h>
|
||||
#include <Errors.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
#include <devfs.h>
|
||||
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceManager.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KPath.h"
|
||||
#include "KPhysicalPartition.h"
|
||||
#include "KShadowPartition.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// debugging
|
||||
//#define DBG(x)
|
||||
#define DBG(x) x
|
||||
#define OUT dprintf
|
||||
|
||||
// constructor
|
||||
KPhysicalPartition::KPhysicalPartition(partition_id id)
|
||||
: KPartition(id),
|
||||
fShadowPartition(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
KPhysicalPartition::~KPhysicalPartition()
|
||||
{
|
||||
}
|
||||
|
||||
// PrepareForRemoval
|
||||
bool
|
||||
KPhysicalPartition::PrepareForRemoval()
|
||||
{
|
||||
bool result = KPartition::PrepareForRemoval();
|
||||
if (result) {
|
||||
UnsetShadowPartition(false);
|
||||
UnpublishDevice();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Open
|
||||
status_t
|
||||
KPhysicalPartition::Open(int flags, int *fd)
|
||||
{
|
||||
if (!fd)
|
||||
return B_BAD_VALUE;
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
// open the device
|
||||
*fd = open(path.Path(), flags);
|
||||
if (*fd < 0)
|
||||
return errno;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// PublishDevice
|
||||
status_t
|
||||
KPhysicalPartition::PublishDevice()
|
||||
{
|
||||
if (fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// prepare a partition_info
|
||||
partition_info info;
|
||||
info.offset = Offset();
|
||||
info.size = Size();
|
||||
info.logical_block_size = BlockSize();
|
||||
info.session = 0;
|
||||
info.partition = ID();
|
||||
if (strlcpy(info.device, Device()->Path(), B_PATH_NAME_LENGTH)
|
||||
>= B_PATH_NAME_LENGTH) {
|
||||
return B_NAME_TOO_LONG;
|
||||
}
|
||||
|
||||
error = devfs_publish_partition(path.Path() + 5, &info);
|
||||
// we need to remove the "/dev/" part from the path
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = true;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// UnpublishDevice
|
||||
status_t
|
||||
KPhysicalPartition::UnpublishDevice()
|
||||
{
|
||||
if (!fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = false;
|
||||
|
||||
return devfs_unpublish_partition(path.Path() + 5);
|
||||
// we need to remove the "/dev/" part from the path
|
||||
}
|
||||
|
||||
// Mount
|
||||
status_t
|
||||
KPhysicalPartition::Mount(uint32 mountFlags, const char *parameters)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// Unmount
|
||||
status_t
|
||||
KPhysicalPartition::Unmount()
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// CreateChild
|
||||
status_t
|
||||
KPhysicalPartition::CreateChild(partition_id id, int32 index,
|
||||
KPartition **_child)
|
||||
{
|
||||
// check parameters
|
||||
int32 count = fPartitionData.child_count;
|
||||
if (index == -1)
|
||||
index = count;
|
||||
if (index < 0 || index > count)
|
||||
return B_BAD_VALUE;
|
||||
// create and add partition
|
||||
KPhysicalPartition *child = new(nothrow) KPhysicalPartition(id);
|
||||
if (!child)
|
||||
return B_NO_MEMORY;
|
||||
status_t error = AddChild(child, index);
|
||||
// cleanup / set result
|
||||
if (error != B_OK)
|
||||
delete child;
|
||||
else if (_child)
|
||||
*_child = child;
|
||||
return error;
|
||||
}
|
||||
|
||||
// CreateShadowPartition
|
||||
status_t
|
||||
KPhysicalPartition::CreateShadowPartition()
|
||||
{
|
||||
if (fShadowPartition)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (ManagerLocker locker = manager) {
|
||||
// create shadow partition
|
||||
fShadowPartition = new(nothrow) KShadowPartition(this);
|
||||
if (!fShadowPartition)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// make it known to the manager
|
||||
if (!manager->PartitionAdded(fShadowPartition)) {
|
||||
delete fShadowPartition;
|
||||
fShadowPartition = NULL;
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// notify the disk systems
|
||||
// parent disk system
|
||||
status_t error;
|
||||
if (Parent()) {
|
||||
error = Parent()->DiskSystem()->ShadowPartitionChanged(
|
||||
Parent()->ShadowPartition(), fShadowPartition,
|
||||
B_PARTITION_SHADOW_CHILD);
|
||||
if (error != B_OK) {
|
||||
UnsetShadowPartition(true);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// this partition's disk system
|
||||
if (fShadowPartition->DiskSystem()) {
|
||||
error = fShadowPartition->DiskSystem()->ShadowPartitionChanged(
|
||||
fShadowPartition, NULL, B_PARTITION_SHADOW);
|
||||
if (error != B_OK) {
|
||||
UnsetShadowPartition(true);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
// create shadows for children
|
||||
for (int32 i = 0; KPartition *child = ChildAt(i); i++) {
|
||||
status_t error = child->CreateShadowPartition();
|
||||
if (error == B_OK)
|
||||
error = fShadowPartition->AddChild(child->ShadowPartition(), i);
|
||||
|
||||
// cleanup on error
|
||||
if (error != B_OK) {
|
||||
for (int32 k = 0; k <= i; k++)
|
||||
ChildAt(k)->UnsetShadowPartition(true);
|
||||
UnsetShadowPartition(true);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// UnsetShadowPartition
|
||||
void
|
||||
KPhysicalPartition::UnsetShadowPartition(bool doDelete)
|
||||
{
|
||||
if (!fShadowPartition)
|
||||
return;
|
||||
// unset children's shadows
|
||||
for (int32 i = 0; KPartition *child = ChildAt(i); i++)
|
||||
child->UnsetShadowPartition(false);
|
||||
// unset the thing
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (ManagerLocker locker = manager) {
|
||||
fShadowPartition->UnsetPhysicalPartition();
|
||||
if (doDelete) {
|
||||
PartitionRegistrar _(fShadowPartition);
|
||||
manager->PartitionRemoved(fShadowPartition);
|
||||
}
|
||||
fShadowPartition = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// ShadowPartition
|
||||
KShadowPartition *
|
||||
KPhysicalPartition::ShadowPartition() const
|
||||
{
|
||||
return fShadowPartition;
|
||||
}
|
||||
|
||||
// IsShadowPartition
|
||||
bool
|
||||
KPhysicalPartition::IsShadowPartition() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// PhysicalPartition
|
||||
KPhysicalPartition *
|
||||
KPhysicalPartition::PhysicalPartition() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Dump
|
||||
void
|
||||
KPhysicalPartition::Dump(bool deep, int32 level)
|
||||
{
|
||||
KPartition::Dump(deep, level);
|
||||
}
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
// KShadowPartition.cpp
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Drivers.h>
|
||||
#include <Errors.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
#include "ddm_userland_interface.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceManager.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KShadowPartition.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// debugging
|
||||
//#define DBG(x)
|
||||
#define DBG(x) x
|
||||
#define OUT dprintf
|
||||
|
||||
// constructor
|
||||
KShadowPartition::KShadowPartition(KPhysicalPartition *partition)
|
||||
: KPartition(),
|
||||
KPartitionListener(),
|
||||
fPhysicalPartition(partition)
|
||||
{
|
||||
SyncWithPhysicalPartition();
|
||||
if (fPhysicalPartition)
|
||||
fPhysicalPartition->AddListener(this);
|
||||
}
|
||||
|
||||
// destructor
|
||||
KShadowPartition::~KShadowPartition()
|
||||
{
|
||||
UnsetPhysicalPartition();
|
||||
}
|
||||
|
||||
// CreateChild
|
||||
status_t
|
||||
KShadowPartition::CreateChild(partition_id id, int32 index,
|
||||
KPartition **_child)
|
||||
{
|
||||
// check parameters
|
||||
int32 count = fPartitionData.child_count;
|
||||
if (index == -1)
|
||||
index = count;
|
||||
if (index < 0 || index > count)
|
||||
return B_BAD_VALUE;
|
||||
// create and add partition
|
||||
KShadowPartition *child = new(nothrow) KShadowPartition(NULL);
|
||||
if (!child)
|
||||
return B_NO_MEMORY;
|
||||
status_t error = AddChild(child, index);
|
||||
// cleanup / set result
|
||||
if (error != B_OK)
|
||||
delete child;
|
||||
else if (_child)
|
||||
*_child = child;
|
||||
return error;
|
||||
}
|
||||
|
||||
// IsShadowPartition
|
||||
bool
|
||||
KShadowPartition::IsShadowPartition() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ShadowPartition
|
||||
KShadowPartition*
|
||||
KShadowPartition::ShadowPartition() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// UnsetPhysicalPartition
|
||||
void
|
||||
KShadowPartition::UnsetPhysicalPartition()
|
||||
{
|
||||
if (fPhysicalPartition) {
|
||||
fPhysicalPartition->RemoveListener(this);
|
||||
fPhysicalPartition = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// PhysicalPartition
|
||||
KPhysicalPartition*
|
||||
KShadowPartition::PhysicalPartition() const
|
||||
{
|
||||
return fPhysicalPartition;
|
||||
}
|
||||
|
||||
// SyncWithPhysicalPartition
|
||||
void
|
||||
KShadowPartition::SyncWithPhysicalPartition()
|
||||
{
|
||||
if (!fPhysicalPartition)
|
||||
return;
|
||||
SetDevice(fPhysicalPartition->Device());
|
||||
SetDiskSystem(fPhysicalPartition->DiskSystem());
|
||||
SetOffset(fPhysicalPartition->Offset());
|
||||
SetSize(fPhysicalPartition->Size());
|
||||
SetContentSize(fPhysicalPartition->ContentSize());
|
||||
SetBlockSize(fPhysicalPartition->BlockSize());
|
||||
SetStatus(fPhysicalPartition->Status());
|
||||
SetFlags(fPhysicalPartition->Flags());
|
||||
SetName(fPhysicalPartition->Name());
|
||||
SetContentName(fPhysicalPartition->ContentName());
|
||||
SetType(fPhysicalPartition->Type());
|
||||
SetVolumeID(fPhysicalPartition->VolumeID());
|
||||
SetParameters(fPhysicalPartition->Parameters());
|
||||
SetContentParameters(fPhysicalPartition->ContentParameters());
|
||||
// TODO: Cookie, ContentCookie, MountCookie?
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KShadowPartition::WriteUserData(UserDataWriter &writer,
|
||||
user_partition_data *data)
|
||||
{
|
||||
KPartition::WriteUserData(writer, data);
|
||||
// fix the ID in the user data
|
||||
if (data) {
|
||||
if (fPhysicalPartition)
|
||||
data->id = fPhysicalPartition->ID();
|
||||
data->shadow_id = ID();
|
||||
}
|
||||
}
|
||||
|
||||
// Dump
|
||||
void
|
||||
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?
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <KDiskDeviceUtils.h>
|
||||
#include <KDiskSystem.h>
|
||||
#include <KFileDiskDevice.h>
|
||||
#include <KShadowPartition.h>
|
||||
#include <syscall_args.h>
|
||||
|
||||
#include "UserDataWriter.h"
|
||||
@@ -105,7 +104,7 @@ _user_get_next_disk_device_id(int32 *_cookie, size_t *neededSize)
|
||||
if (DeviceReadLocker locker = device) {
|
||||
// get the needed size
|
||||
UserDataWriter writer;
|
||||
device->WriteUserData(writer, false);
|
||||
device->WriteUserData(writer);
|
||||
*neededSize = writer.AllocatedSize();
|
||||
} else {
|
||||
id = B_ERROR;
|
||||
@@ -139,7 +138,7 @@ _user_find_disk_device(const char *_filename, size_t *neededSize)
|
||||
if (DeviceReadLocker locker = device) {
|
||||
// get the needed size
|
||||
UserDataWriter writer;
|
||||
device->WriteUserData(writer, false);
|
||||
device->WriteUserData(writer);
|
||||
*neededSize = writer.AllocatedSize();
|
||||
} else
|
||||
return B_ERROR;
|
||||
@@ -176,7 +175,7 @@ _user_find_partition(const char *_filename, size_t *neededSize)
|
||||
if (DeviceReadLocker locker = device) {
|
||||
// get the needed size
|
||||
UserDataWriter writer;
|
||||
device->WriteUserData(writer, false);
|
||||
device->WriteUserData(writer);
|
||||
*neededSize = writer.AllocatedSize();
|
||||
} else
|
||||
return B_ERROR;
|
||||
@@ -206,9 +205,6 @@ _user_find_partition(const char *_filename, size_t *neededSize)
|
||||
itself (if \a deviceOnly is true).
|
||||
\param deviceOnly Specifies whether only IDs of disk devices (\c true),
|
||||
or also IDs of partitions (\c false) are accepted for \a id.
|
||||
\param shadow If \c true, the data of the shadow disk device is returned,
|
||||
otherwise of the physical device. If there is no shadow device,
|
||||
the parameter is ignored.
|
||||
\param buffer The buffer into which the disk device data shall be written.
|
||||
May be \c NULL.
|
||||
\param bufferSize The size of \a buffer.
|
||||
@@ -229,7 +225,7 @@ _user_find_partition(const char *_filename, size_t *neededSize)
|
||||
- another error code...
|
||||
*/
|
||||
status_t
|
||||
_user_get_disk_device_data(partition_id id, bool deviceOnly, bool shadow,
|
||||
_user_get_disk_device_data(partition_id id, bool deviceOnly,
|
||||
user_disk_device_data *buffer, size_t bufferSize, size_t *_neededSize)
|
||||
{
|
||||
if (!buffer && bufferSize > 0)
|
||||
@@ -241,7 +237,7 @@ _user_get_disk_device_data(partition_id id, bool deviceOnly, bool shadow,
|
||||
if (DeviceReadLocker locker = device) {
|
||||
// do a dry run first to get the needed size
|
||||
UserDataWriter writer;
|
||||
device->WriteUserData(writer, shadow);
|
||||
device->WriteUserData(writer);
|
||||
size_t neededSize = writer.AllocatedSize();
|
||||
if (_neededSize) {
|
||||
status_t error = copy_ref_var_to_user(neededSize, _neededSize);
|
||||
@@ -260,7 +256,7 @@ _user_get_disk_device_data(partition_id id, bool deviceOnly, bool shadow,
|
||||
MemoryDeleter deleter(kernelBuffer);
|
||||
// write the device data into the buffer
|
||||
writer.SetTo(kernelBuffer, bufferSize);
|
||||
device->WriteUserData(writer, shadow);
|
||||
device->WriteUserData(writer);
|
||||
// sanity check
|
||||
if (writer.AllocatedSize() != neededSize) {
|
||||
ERROR(("Size of written disk device user data changed from "
|
||||
|
||||
@@ -119,22 +119,12 @@ get_disk_device(partition_id partitionID)
|
||||
}
|
||||
|
||||
|
||||
// get_physical_partition
|
||||
partition_data*
|
||||
get_physical_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager* manager = KDiskDeviceManager::Default();
|
||||
KPartition* partition = manager->FindPartition(partitionID, true);
|
||||
return (partition ? partition->PartitionData() : NULL);
|
||||
}
|
||||
|
||||
|
||||
// get_partition
|
||||
partition_data *
|
||||
get_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *partition = manager->FindPartition(partitionID, false);
|
||||
KPartition *partition = manager->FindPartition(partitionID);
|
||||
return (partition ? partition->PartitionData() : NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -5343,7 +5343,7 @@ fs_mount(char *path, const char *device, const char *fsName, uint32 flags,
|
||||
return status;
|
||||
|
||||
// get a corresponding partition from the DDM
|
||||
partition = ddm->RegisterPartition(normalizedDevice.Path(), true);
|
||||
partition = ddm->RegisterPartition(normalizedDevice.Path());
|
||||
|
||||
if (!partition) {
|
||||
// Partition not found: This either means, the user supplied
|
||||
@@ -5352,7 +5352,7 @@ fs_mount(char *path, const char *device, const char *fsName, uint32 flags,
|
||||
partition_id deviceID = ddm->CreateFileDevice(normalizedDevice.Path(),
|
||||
&newlyCreatedFileDevice);
|
||||
if (deviceID >= 0) {
|
||||
partition = ddm->RegisterPartition(deviceID, true);
|
||||
partition = ddm->RegisterPartition(deviceID);
|
||||
if (newlyCreatedFileDevice)
|
||||
fileDeviceDeleter.id = deviceID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user