Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22600 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,62 +1,66 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2007, Ingo Weinhold, [email protected].
|
||||||
// by the OpenBeOS license.
|
* Copyright 2003, Tyler Akidau, [email protected].
|
||||||
//---------------------------------------------------------------------
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _DISK_DEVICE_H
|
#ifndef _DISK_DEVICE_H
|
||||||
#define _DISK_DEVICE_H
|
#define _DISK_DEVICE_H
|
||||||
|
|
||||||
#include <Partition.h>
|
#include <Partition.h>
|
||||||
|
|
||||||
|
|
||||||
struct user_disk_device_data;
|
struct user_disk_device_data;
|
||||||
|
|
||||||
class BDiskDevice : public BPartition {
|
class BDiskDevice : public BPartition {
|
||||||
public:
|
public:
|
||||||
BDiskDevice();
|
BDiskDevice();
|
||||||
virtual ~BDiskDevice();
|
virtual ~BDiskDevice();
|
||||||
|
|
||||||
bool HasMedia() const;
|
bool HasMedia() const;
|
||||||
bool IsRemovableMedia() const;
|
bool IsRemovableMedia() const;
|
||||||
bool IsReadOnlyMedia() const;
|
bool IsReadOnlyMedia() const;
|
||||||
bool IsWriteOnceMedia() const;
|
bool IsWriteOnceMedia() const;
|
||||||
|
|
||||||
status_t Eject(bool update = false);
|
status_t Eject(bool update = false);
|
||||||
|
|
||||||
status_t SetTo(partition_id id);
|
status_t SetTo(partition_id id);
|
||||||
status_t Update(bool *updated = NULL);
|
status_t Update(bool* updated = NULL);
|
||||||
void Unset();
|
void Unset();
|
||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
|
|
||||||
virtual status_t GetPath(BPath *path) const;
|
virtual status_t GetPath(BPath* path) const;
|
||||||
|
|
||||||
bool IsModified() const;
|
bool IsModified() const;
|
||||||
status_t PrepareModifications();
|
status_t PrepareModifications();
|
||||||
status_t CommitModifications(bool synchronously = true,
|
status_t CommitModifications(bool synchronously = true,
|
||||||
BMessenger progressMessenger = BMessenger(),
|
BMessenger progressMessenger = BMessenger(),
|
||||||
bool receiveCompleteProgressUpdates = true);
|
bool receiveCompleteProgressUpdates = true);
|
||||||
status_t CancelModifications();
|
status_t CancelModifications();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BDiskDeviceList;
|
friend class BDiskDeviceList;
|
||||||
friend class BDiskDeviceRoster;
|
friend class BDiskDeviceRoster;
|
||||||
|
|
||||||
BDiskDevice(const BDiskDevice &);
|
BDiskDevice(const BDiskDevice&);
|
||||||
BDiskDevice &operator=(const BDiskDevice &);
|
BDiskDevice& operator=(const BDiskDevice&);
|
||||||
|
|
||||||
static status_t _GetData(partition_id id, bool deviceOnly, bool shadow,
|
static status_t _GetData(partition_id id, bool deviceOnly,
|
||||||
size_t neededSize, user_disk_device_data **data);
|
bool shadow, size_t neededSize,
|
||||||
|
user_disk_device_data** data);
|
||||||
|
|
||||||
status_t _SetTo(partition_id id, bool deviceOnly, bool shadow,
|
status_t _SetTo(partition_id id, bool deviceOnly,
|
||||||
size_t neededSize);
|
bool shadow, size_t neededSize);
|
||||||
status_t _SetTo(user_disk_device_data *data);
|
status_t _SetTo(user_disk_device_data* data);
|
||||||
status_t _Update(bool shadow, bool *updated);
|
status_t _Update(bool shadow, bool* updated);
|
||||||
status_t _Update(user_disk_device_data *data, bool *updated);
|
status_t _Update(user_disk_device_data* data,
|
||||||
|
bool* updated);
|
||||||
|
|
||||||
static void _ClearUserData(user_partition_data* data);
|
static void _ClearUserData(user_partition_data* data);
|
||||||
|
|
||||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
|
||||||
|
int32 level);
|
||||||
|
|
||||||
user_disk_device_data *fDeviceData;
|
user_disk_device_data* fDeviceData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _DISK_DEVICE_H
|
#endif // _DISK_DEVICE_H
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Ingo Weinhold, [email protected].de.
|
* Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
|
* Copyright 2003, Tyler Akidau, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PARTITION_H
|
#ifndef _PARTITION_H
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2007, Ingo Weinhold, [email protected].
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
|
|
||||||
#include <DiskDevice.h>
|
#include <DiskDevice.h>
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
\brief A BDiskDevice object represents a storage device.
|
\brief A BDiskDevice object represents a storage device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
/*! \brief Creates an uninitialized BDiskDevice object.
|
/*! \brief Creates an uninitialized BDiskDevice object.
|
||||||
*/
|
*/
|
||||||
@@ -36,6 +37,7 @@ BDiskDevice::BDiskDevice()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
/*! \brief Frees all resources associated with this object.
|
/*! \brief Frees all resources associated with this object.
|
||||||
*/
|
*/
|
||||||
@@ -44,6 +46,7 @@ BDiskDevice::~BDiskDevice()
|
|||||||
CancelModifications();
|
CancelModifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HasMedia
|
// HasMedia
|
||||||
/*! \brief Returns whether the device contains a media.
|
/*! \brief Returns whether the device contains a media.
|
||||||
\return \c true, if the device contains a media, \c false otherwise.
|
\return \c true, if the device contains a media, \c false otherwise.
|
||||||
@@ -52,9 +55,10 @@ bool
|
|||||||
BDiskDevice::HasMedia() const
|
BDiskDevice::HasMedia() const
|
||||||
{
|
{
|
||||||
return (fDeviceData
|
return (fDeviceData
|
||||||
&& fDeviceData->device_flags & B_DISK_DEVICE_HAS_MEDIA);
|
&& fDeviceData->device_flags & B_DISK_DEVICE_HAS_MEDIA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsRemovableMedia
|
// IsRemovableMedia
|
||||||
/*! \brief Returns whether the device media are removable.
|
/*! \brief Returns whether the device media are removable.
|
||||||
\return \c true, if the device media are removable, \c false otherwise.
|
\return \c true, if the device media are removable, \c false otherwise.
|
||||||
@@ -63,25 +67,28 @@ bool
|
|||||||
BDiskDevice::IsRemovableMedia() const
|
BDiskDevice::IsRemovableMedia() const
|
||||||
{
|
{
|
||||||
return (fDeviceData
|
return (fDeviceData
|
||||||
&& fDeviceData->device_flags & B_DISK_DEVICE_REMOVABLE);
|
&& fDeviceData->device_flags & B_DISK_DEVICE_REMOVABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsReadOnlyMedia
|
// IsReadOnlyMedia
|
||||||
bool
|
bool
|
||||||
BDiskDevice::IsReadOnlyMedia() const
|
BDiskDevice::IsReadOnlyMedia() const
|
||||||
{
|
{
|
||||||
return (fDeviceData
|
return (fDeviceData
|
||||||
&& fDeviceData->device_flags & B_DISK_DEVICE_READ_ONLY);
|
&& fDeviceData->device_flags & B_DISK_DEVICE_READ_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsWriteOnceMedia
|
// IsWriteOnceMedia
|
||||||
bool
|
bool
|
||||||
BDiskDevice::IsWriteOnceMedia() const
|
BDiskDevice::IsWriteOnceMedia() const
|
||||||
{
|
{
|
||||||
return (fDeviceData
|
return (fDeviceData
|
||||||
&& fDeviceData->device_flags & B_DISK_DEVICE_WRITE_ONCE);
|
&& fDeviceData->device_flags & B_DISK_DEVICE_WRITE_ONCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Eject
|
// Eject
|
||||||
/*! \brief Eject the device's media.
|
/*! \brief Eject the device's media.
|
||||||
|
|
||||||
@@ -99,7 +106,7 @@ status_t
|
|||||||
BDiskDevice::Eject(bool update)
|
BDiskDevice::Eject(bool update)
|
||||||
{
|
{
|
||||||
/* // get path
|
/* // get path
|
||||||
const char *path = Path();
|
const char* path = Path();
|
||||||
status_t error = (path ? B_OK : B_NO_INIT);
|
status_t error = (path ? B_OK : B_NO_INIT);
|
||||||
// check whether the device media is removable
|
// check whether the device media is removable
|
||||||
if (error == B_OK && !IsRemovable())
|
if (error == B_OK && !IsRemovable())
|
||||||
@@ -120,6 +127,7 @@ BDiskDevice::Eject(bool update)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetTo
|
// SetTo
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::SetTo(partition_id id)
|
BDiskDevice::SetTo(partition_id id)
|
||||||
@@ -127,6 +135,7 @@ BDiskDevice::SetTo(partition_id id)
|
|||||||
return _SetTo(id, true, false, 0);
|
return _SetTo(id, true, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
/*! \brief Updates the object to reflect the latest changes to the device.
|
/*! \brief Updates the object to reflect the latest changes to the device.
|
||||||
|
|
||||||
@@ -141,11 +150,12 @@ BDiskDevice::SetTo(partition_id id)
|
|||||||
\return \c B_OK, if the update went fine, another error code otherwise.
|
\return \c B_OK, if the update went fine, another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::Update(bool *updated)
|
BDiskDevice::Update(bool* updated)
|
||||||
{
|
{
|
||||||
return _Update(_IsShadow(), updated);
|
return _Update(_IsShadow(), updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Unset
|
// Unset
|
||||||
void
|
void
|
||||||
BDiskDevice::Unset()
|
BDiskDevice::Unset()
|
||||||
@@ -155,6 +165,7 @@ BDiskDevice::Unset()
|
|||||||
fDeviceData = NULL;
|
fDeviceData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// InitCheck
|
// InitCheck
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::InitCheck() const
|
BDiskDevice::InitCheck() const
|
||||||
@@ -162,23 +173,26 @@ BDiskDevice::InitCheck() const
|
|||||||
return (fDeviceData ? B_OK : B_NO_INIT);
|
return (fDeviceData ? B_OK : B_NO_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetPath
|
// GetPath
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::GetPath(BPath *path) const
|
BDiskDevice::GetPath(BPath* path) const
|
||||||
{
|
{
|
||||||
if (!path || !fDeviceData)
|
if (!path || !fDeviceData)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
return path->SetTo(fDeviceData->path);
|
return path->SetTo(fDeviceData->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsModified
|
// IsModified
|
||||||
bool
|
bool
|
||||||
BDiskDevice::IsModified() const
|
BDiskDevice::IsModified() const
|
||||||
{
|
{
|
||||||
return (InitCheck() == B_OK && _IsShadow()
|
return (InitCheck() == B_OK && _IsShadow()
|
||||||
&& _kern_is_disk_device_modified(ID()));
|
&& _kern_is_disk_device_modified(ID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// PrepareModifications
|
// PrepareModifications
|
||||||
/*! \brief Initializes the partition hierarchy for modifications.
|
/*! \brief Initializes the partition hierarchy for modifications.
|
||||||
*
|
*
|
||||||
@@ -197,19 +211,23 @@ BDiskDevice::PrepareModifications()
|
|||||||
return error;
|
return error;
|
||||||
if (_IsShadow())
|
if (_IsShadow())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// ask kernel to prepare for modifications
|
// ask kernel to prepare for modifications
|
||||||
error = _kern_prepare_disk_device_modifications(ID());
|
error = _kern_prepare_disk_device_modifications(ID());
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
// update
|
// update
|
||||||
error = _Update(true, NULL);
|
error = _Update(true, NULL);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
// bad -- cancelling the modifications is all we can do
|
// bad -- cancelling the modifications is all we can do
|
||||||
_kern_cancel_disk_device_modifications(ID());
|
_kern_cancel_disk_device_modifications(ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CommitModifications
|
// CommitModifications
|
||||||
/*! \brief Commits modifications to device.
|
/*! \brief Commits modifications to device.
|
||||||
*
|
*
|
||||||
@@ -219,14 +237,14 @@ BDiskDevice::PrepareModifications()
|
|||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::CommitModifications(bool synchronously,
|
BDiskDevice::CommitModifications(bool synchronously,
|
||||||
BMessenger progressMessenger,
|
BMessenger progressMessenger, bool receiveCompleteProgressUpdates)
|
||||||
bool receiveCompleteProgressUpdates)
|
|
||||||
{
|
{
|
||||||
status_t error = InitCheck();
|
status_t error = InitCheck();
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
if (!_IsShadow())
|
if (!_IsShadow())
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// TODO: Get port and token from the progressMessenger
|
// TODO: Get port and token from the progressMessenger
|
||||||
// TODO: Respect "synchronously"!
|
// TODO: Respect "synchronously"!
|
||||||
port_id port = -1;
|
port_id port = -1;
|
||||||
@@ -235,9 +253,11 @@ BDiskDevice::CommitModifications(bool synchronously,
|
|||||||
receiveCompleteProgressUpdates);
|
receiveCompleteProgressUpdates);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = _SetTo(ID(), true, false, 0);
|
error = _SetTo(ID(), true, false, 0);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CancelModifications
|
// CancelModifications
|
||||||
/*! \brief Cancels all modifications performed on the device.
|
/*! \brief Cancels all modifications performed on the device.
|
||||||
*
|
*
|
||||||
@@ -251,35 +271,40 @@ BDiskDevice::CancelModifications()
|
|||||||
return error;
|
return error;
|
||||||
if (!_IsShadow())
|
if (!_IsShadow())
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
error = _kern_cancel_disk_device_modifications(ID());
|
error = _kern_cancel_disk_device_modifications(ID());
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = _SetTo(ID(), true, false, 0);
|
error = _SetTo(ID(), true, false, 0);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// copy constructor
|
// copy constructor
|
||||||
/*! \brief Privatized copy constructor to avoid usage.
|
/*! \brief Privatized copy constructor to avoid usage.
|
||||||
*/
|
*/
|
||||||
BDiskDevice::BDiskDevice(const BDiskDevice &)
|
BDiskDevice::BDiskDevice(const BDiskDevice&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// =
|
// =
|
||||||
/*! \brief Privatized assignment operator to avoid usage.
|
/*! \brief Privatized assignment operator to avoid usage.
|
||||||
*/
|
*/
|
||||||
BDiskDevice &
|
BDiskDevice&
|
||||||
BDiskDevice::operator=(const BDiskDevice &)
|
BDiskDevice::operator=(const BDiskDevice&)
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _GetData
|
// _GetData
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
|
BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
|
||||||
size_t neededSize, user_disk_device_data **data)
|
size_t neededSize, user_disk_device_data** data)
|
||||||
{
|
{
|
||||||
// get the device data
|
// get the device data
|
||||||
void *buffer = NULL;
|
void* buffer = NULL;
|
||||||
size_t bufferSize = 0;
|
size_t bufferSize = 0;
|
||||||
if (neededSize > 0) {
|
if (neededSize > 0) {
|
||||||
// allocate initial buffer
|
// allocate initial buffer
|
||||||
@@ -288,6 +313,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
bufferSize = neededSize;
|
bufferSize = neededSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
do {
|
do {
|
||||||
error = _kern_get_disk_device_data(id, deviceOnly, shadow,
|
error = _kern_get_disk_device_data(id, deviceOnly, shadow,
|
||||||
@@ -297,79 +323,99 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
|
|||||||
// buffer to small re-allocate it
|
// buffer to small re-allocate it
|
||||||
if (buffer)
|
if (buffer)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
buffer = malloc(neededSize);
|
buffer = malloc(neededSize);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
bufferSize = neededSize;
|
bufferSize = neededSize;
|
||||||
else
|
else
|
||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
} while (error == B_BUFFER_OVERFLOW);
|
} while (error == B_BUFFER_OVERFLOW);
|
||||||
|
|
||||||
// set result / cleanup on error
|
// set result / cleanup on error
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
*data = (user_disk_device_data*)buffer;
|
*data = (user_disk_device_data*)buffer;
|
||||||
else if (buffer)
|
else if (buffer)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _SetTo
|
// _SetTo
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, bool shadow,
|
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, bool shadow,
|
||||||
size_t neededSize)
|
size_t neededSize)
|
||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
|
|
||||||
// get the device data
|
// get the device data
|
||||||
user_disk_device_data *data = NULL;
|
user_disk_device_data* data = NULL;
|
||||||
status_t error = _GetData(id, deviceOnly, shadow, neededSize, &data);
|
status_t error = _GetData(id, deviceOnly, shadow, neededSize, &data);
|
||||||
|
|
||||||
// set the data
|
// set the data
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = _SetTo(data);
|
error = _SetTo(data);
|
||||||
|
|
||||||
// cleanup on error
|
// cleanup on error
|
||||||
if (error != B_OK && data)
|
if (error != B_OK && data)
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _SetTo
|
// _SetTo
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::_SetTo(user_disk_device_data *data)
|
BDiskDevice::_SetTo(user_disk_device_data* data)
|
||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fDeviceData = data;
|
fDeviceData = data;
|
||||||
|
|
||||||
status_t error = BPartition::_SetTo(this, NULL,
|
status_t error = BPartition::_SetTo(this, NULL,
|
||||||
&fDeviceData->device_partition_data);
|
&fDeviceData->device_partition_data);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
// If _SetTo() fails, the caller retains ownership of the supplied
|
// If _SetTo() fails, the caller retains ownership of the supplied
|
||||||
// data. So, unset fDeviceData before calling Unset().
|
// data. So, unset fDeviceData before calling Unset().
|
||||||
fDeviceData = NULL;
|
fDeviceData = NULL;
|
||||||
Unset();
|
Unset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _Update
|
// _Update
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::_Update(bool shadow, bool *updated)
|
BDiskDevice::_Update(bool shadow, bool* updated)
|
||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return InitCheck();
|
return InitCheck();
|
||||||
|
|
||||||
// get the device data
|
// get the device data
|
||||||
user_disk_device_data *data = NULL;
|
user_disk_device_data* data = NULL;
|
||||||
status_t error = _GetData(ID(), true, shadow, 0, &data);
|
status_t error = _GetData(ID(), true, shadow, 0, &data);
|
||||||
|
|
||||||
// set the data
|
// set the data
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = _Update(data, updated);
|
error = _Update(data, updated);
|
||||||
|
|
||||||
// cleanup on error
|
// cleanup on error
|
||||||
if (error != B_OK && data)
|
if (error != B_OK && data)
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _Update
|
// _Update
|
||||||
status_t
|
status_t
|
||||||
BDiskDevice::_Update(user_disk_device_data *data, bool *updated)
|
BDiskDevice::_Update(user_disk_device_data* data, bool* updated)
|
||||||
{
|
{
|
||||||
if (!data || !fDeviceData || ID() != data->device_partition_data.id)
|
if (!data || !fDeviceData || ID() != data->device_partition_data.id)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -390,7 +436,7 @@ BDiskDevice::_Update(user_disk_device_data *data, bool *updated)
|
|||||||
// update existing partitions and add new ones
|
// update existing partitions and add new ones
|
||||||
error = BPartition::_Update(&data->device_partition_data, updated);
|
error = BPartition::_Update(&data->device_partition_data, updated);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
user_disk_device_data *oldData = fDeviceData;
|
user_disk_device_data* oldData = fDeviceData;
|
||||||
fDeviceData = data;
|
fDeviceData = data;
|
||||||
// check for changes
|
// check for changes
|
||||||
if (data->device_flags != oldData->device_flags
|
if (data->device_flags != oldData->device_flags
|
||||||
@@ -399,12 +445,14 @@ BDiskDevice::_Update(user_disk_device_data *data, bool *updated)
|
|||||||
}
|
}
|
||||||
free(oldData);
|
free(oldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _AcceptVisitor
|
// _AcceptVisitor
|
||||||
bool
|
bool
|
||||||
BDiskDevice::_AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level)
|
BDiskDevice::_AcceptVisitor(BDiskDeviceVisitor* visitor, int32 level)
|
||||||
{
|
{
|
||||||
return visitor->Visit(this);
|
return visitor->Visit(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Ingo Weinhold, [email protected].de.
|
* Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user