* Added SetTo(partition_id), InitCheck().
* Added more parameters to _SetTo(). * Fixed problem in Unset() -- the BPartition version wasn't called. * Implemented {Prepare,Cancel}Modifications() and IsModified(). The latter doesn't work yet, since the syscall implementation is still empty yet. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3977 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dd43c7769f
commit
92b9e33326
@ -22,8 +22,10 @@ public:
|
||||
|
||||
status_t Eject(bool update = false);
|
||||
|
||||
status_t SetTo(partition_id id);
|
||||
status_t Update(bool *updated = NULL);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
virtual status_t GetPath(BPath *path) const;
|
||||
|
||||
@ -38,7 +40,8 @@ private:
|
||||
friend class BDiskDeviceList;
|
||||
friend class BDiskDeviceRoster;
|
||||
|
||||
status_t _SetTo(partition_id id, size_t neededSize = 0);
|
||||
status_t _SetTo(partition_id id, bool deviceOnly, bool shadow,
|
||||
size_t neededSize);
|
||||
status_t _SetTo(user_disk_device_data *data);
|
||||
|
||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
||||
|
@ -117,6 +117,13 @@ BDiskDevice::Eject(bool update)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// SetTo
|
||||
status_t
|
||||
BDiskDevice::SetTo(partition_id id)
|
||||
{
|
||||
return _SetTo(id, true, false, 0);
|
||||
}
|
||||
|
||||
// Update
|
||||
/*! \brief Updates the object to reflect the latest changes to the device.
|
||||
|
||||
@ -184,10 +191,18 @@ BDiskDevice::Update(bool *updated)
|
||||
void
|
||||
BDiskDevice::Unset()
|
||||
{
|
||||
BPartition::_Unset();
|
||||
free(fDeviceData);
|
||||
fDeviceData = NULL;
|
||||
}
|
||||
|
||||
// InitCheck
|
||||
status_t
|
||||
BDiskDevice::InitCheck() const
|
||||
{
|
||||
return (fDeviceData ? B_OK : B_NO_INIT);
|
||||
}
|
||||
|
||||
// GetPath
|
||||
status_t
|
||||
BDiskDevice::GetPath(BPath *path) const
|
||||
@ -201,16 +216,27 @@ BDiskDevice::GetPath(BPath *path) const
|
||||
bool
|
||||
BDiskDevice::IsModified() const
|
||||
{
|
||||
// not implemented
|
||||
return false;
|
||||
return (InitCheck() == B_OK && _IsShadow()
|
||||
&& _kern_is_disk_device_modified(ID()));
|
||||
}
|
||||
|
||||
// PrepareModifications
|
||||
status_t
|
||||
BDiskDevice::PrepareModifications()
|
||||
{
|
||||
// not implemented
|
||||
// check initialization
|
||||
status_t error = InitCheck();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (_IsShadow())
|
||||
return B_ERROR;
|
||||
// ask kernel to prepare for modifications
|
||||
error = _kern_prepare_disk_device_modifications(ID());
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
// update
|
||||
// TODO: Add an _Update(bool shadow)?
|
||||
return _SetTo(ID(), true, true, 0);
|
||||
}
|
||||
|
||||
// CommitModifications
|
||||
@ -227,13 +253,21 @@ BDiskDevice::CommitModifications(bool synchronously,
|
||||
status_t
|
||||
BDiskDevice::CancelModifications()
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
status_t error = InitCheck();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (!_IsShadow())
|
||||
return B_BAD_VALUE;
|
||||
error = _kern_cancel_disk_device_modifications(ID());
|
||||
if (error == B_OK)
|
||||
error = _SetTo(ID(), true, false, 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
// _SetTo
|
||||
status_t
|
||||
BDiskDevice::_SetTo(partition_id id, size_t neededSize)
|
||||
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, bool shadow,
|
||||
size_t neededSize)
|
||||
{
|
||||
Unset();
|
||||
// get the device data
|
||||
@ -248,7 +282,7 @@ BDiskDevice::_SetTo(partition_id id, size_t neededSize)
|
||||
}
|
||||
status_t error = B_OK;
|
||||
do {
|
||||
error = _kern_get_disk_device_data(id, false,
|
||||
error = _kern_get_disk_device_data(id, deviceOnly, shadow,
|
||||
(user_disk_device_data*)buffer,
|
||||
bufferSize, &neededSize);
|
||||
if (error == B_BUFFER_OVERFLOW) {
|
||||
@ -282,11 +316,10 @@ BDiskDevice::_SetTo(user_disk_device_data *data)
|
||||
status_t error = BPartition::_SetTo(this, NULL,
|
||||
&fDeviceData->device_partition_data);
|
||||
if (error != B_OK) {
|
||||
// Don't call Unset() here. If _SetTo() fails, the caller retains
|
||||
// ownership of the supplied data.
|
||||
// TODO: Maybe introduce a _Unset() to avoid potential future
|
||||
// problems.
|
||||
// If _SetTo() fails, the caller retains ownership of the supplied
|
||||
// data. So, unset fDeviceData before calling Unset().
|
||||
fDeviceData = NULL;
|
||||
Unset();
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user