* Removed the BDiskDeviceJob class. Jobs won't be generated and executed

in the kernel anymore. The respective functionality will be moved into
  the userland. Depending on how we want the API user to interface with
  it, we may want to reintroduce a similar class later.
* Cleared remaining references to shadow partitions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22606 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-17 22:56:23 +00:00
parent 271b1f27bf
commit 1573b62671
9 changed files with 32 additions and 304 deletions

View File

@ -45,13 +45,13 @@ private:
BDiskDevice& operator=(const BDiskDevice&);
static status_t _GetData(partition_id id, bool deviceOnly,
bool shadow, size_t neededSize,
size_t neededSize,
user_disk_device_data** data);
status_t _SetTo(partition_id id, bool deviceOnly,
bool shadow, size_t neededSize);
size_t neededSize);
status_t _SetTo(user_disk_device_data* data);
status_t _Update(bool shadow, bool* updated);
status_t _Update(bool* updated);
status_t _Update(user_disk_device_data* data,
bool* updated);

View File

@ -1,47 +0,0 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#ifndef _DISK_DEVICE_JOB_H
#define _DISK_DEVICE_JOB_H
#include <DiskDeviceDefs.h>
#include <String.h>
struct user_disk_device_job_info;
class BDiskDeviceJob {
public:
BDiskDeviceJob();
~BDiskDeviceJob();
status_t SetTo(disk_job_id id);
void Unset();
status_t InitCheck() const;
disk_job_id ID() const;
uint32 Type() const;
partition_id PartitionID() const;
const char *Description() const;
uint32 Status() const;
float Progress() const; // [0.0, 1.0]
status_t GetProgressInfo(disk_device_job_progress_info *info) const;
uint32 InterruptProperties() const;
status_t Cancel(bool reverse = false);
status_t Pause();
private:
status_t _SetTo(user_disk_device_job_info *info);
friend class BDiskDeviceRoster;
disk_job_id fID;
uint32 fType;
partition_id fPartitionID;
BString fDescription;
};
#endif // _DISK_DEVICE_JOB_H

View File

@ -14,7 +14,6 @@
class BDirectory;
class BDiskDevice;
class BDiskDeviceJob;
class BDiskDeviceVisiting;
class BDiskDeviceVisitor;
class BDiskScannerPartitionAddOn;
@ -95,10 +94,6 @@ public:
status_t GetNextDiskSystem(BDiskSystem *system);
status_t RewindDiskSystems();
// Active jobs are those that are scheduled or in-progress
status_t GetNextActiveJob(BDiskDeviceJob *job);
status_t RewindActiveJobs();
partition_id RegisterFileDevice(const char *filename);
// publishes: /dev/disk/virtual/files/<disk device ID>/raw
status_t UnregisterFileDevice(const char *filename);
@ -127,9 +122,6 @@ public:
status_t StartWatching(BMessenger target,
uint32 eventMask = B_DEVICE_REQUEST_ALL);
status_t StartWatchingJob(BDiskDeviceJob *job, BMessenger target,
uint32 eventMask = B_DEVICE_REQUEST_JOB_COMPLETE_PROGRESS);
// TODO: Maybe better a BDiskDeviceJob::{Start,Stop}Watching()?
status_t StopWatching(BMessenger target);
private:

View File

@ -187,8 +187,6 @@ private:
bool* updated);
void _RemoveChild(int32 index);
bool _IsShadow() const;
int32 _CountDescendants() const;
int32 _Level() const;
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,

View File

@ -134,7 +134,7 @@ BDiskDevice::Eject(bool update)
status_t
BDiskDevice::SetTo(partition_id id)
{
return _SetTo(id, true, false, 0);
return _SetTo(id, true, 0);
}
@ -154,7 +154,22 @@ BDiskDevice::SetTo(partition_id id)
status_t
BDiskDevice::Update(bool* updated)
{
return _Update(_IsShadow(), updated);
if (InitCheck() != B_OK)
return InitCheck();
// get the device data
user_disk_device_data* data = NULL;
status_t error = _GetData(ID(), true, 0, &data);
// set the data
if (error == B_OK)
error = _Update(data, updated);
// cleanup on error
if (error != B_OK && data)
free(data);
return error;
}
@ -274,7 +289,7 @@ BDiskDevice::CommitModifications(bool synchronously,
DiskSystemAddOnManager::Default()->UnloadDiskSystems();
if (error == B_OK)
error = _SetTo(ID(), true, false, 0);
error = _SetTo(ID(), true, 0);
return error;
}
@ -299,7 +314,7 @@ BDiskDevice::CancelModifications()
DiskSystemAddOnManager::Default()->UnloadDiskSystems();
if (error == B_OK)
error = _SetTo(ID(), true, false, 0);
error = _SetTo(ID(), true, 0);
return error;
}
@ -325,8 +340,8 @@ BDiskDevice::operator=(const BDiskDevice&)
// _GetData
status_t
BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
size_t neededSize, user_disk_device_data** data)
BDiskDevice::_GetData(partition_id id, bool deviceOnly, size_t neededSize,
user_disk_device_data** data)
{
// get the device data
void* buffer = NULL;
@ -341,7 +356,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
status_t error = B_OK;
do {
error = _kern_get_disk_device_data(id, deviceOnly, shadow,
error = _kern_get_disk_device_data(id, deviceOnly, false,
(user_disk_device_data*)buffer, bufferSize, &neededSize);
if (error == B_BUFFER_OVERFLOW) {
// buffer to small re-allocate it
@ -369,14 +384,13 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
// _SetTo
status_t
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, bool shadow,
size_t neededSize)
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, size_t neededSize)
{
Unset();
// get the device data
user_disk_device_data* data = NULL;
status_t error = _GetData(id, deviceOnly, shadow, neededSize, &data);
status_t error = _GetData(id, deviceOnly, neededSize, &data);
// set the data
if (error == B_OK)
@ -414,29 +428,6 @@ BDiskDevice::_SetTo(user_disk_device_data* data)
}
// _Update
status_t
BDiskDevice::_Update(bool shadow, bool* updated)
{
if (InitCheck() != B_OK)
return InitCheck();
// get the device data
user_disk_device_data* data = NULL;
status_t error = _GetData(ID(), true, shadow, 0, &data);
// set the data
if (error == B_OK)
error = _Update(data, updated);
// cleanup on error
if (error != B_OK && data)
free(data);
return error;
}
// _Update
status_t
BDiskDevice::_Update(user_disk_device_data* data, bool* updated)

View File

@ -1,168 +0,0 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#include <DiskDeviceJob.h>
#include <syscalls.h>
#include <disk_device_manager/ddm_userland_interface.h>
// constructor
BDiskDeviceJob::BDiskDeviceJob()
: fID(B_NO_INIT),
fType(B_DISK_DEVICE_JOB_BAD_TYPE),
fPartitionID(-1),
fDescription()
{
}
// destructor
BDiskDeviceJob::~BDiskDeviceJob()
{
}
// InitCheck
status_t
BDiskDeviceJob::InitCheck() const
{
return (fID >= 0 ? B_OK : fID);
}
// SetTo
status_t
BDiskDeviceJob::SetTo(disk_job_id id)
{
Unset();
user_disk_device_job_info info;
status_t error = _kern_get_disk_device_job_info(id, &info);
if (error != B_OK)
return error;
return _SetTo(&info);
}
// Unset
void
BDiskDeviceJob::Unset()
{
fID = B_NO_INIT;
fType = B_DISK_DEVICE_JOB_BAD_TYPE;
fPartitionID = -1;
fDescription.SetTo(NULL);
}
// ID
disk_job_id
BDiskDeviceJob::ID() const
{
return fID;
}
// Type
uint32
BDiskDeviceJob::Type() const
{
return fType;
}
// PartitionID
partition_id
BDiskDeviceJob::PartitionID() const
{
return fPartitionID;
}
// Description
const char *
BDiskDeviceJob::Description() const
{
return fDescription.String();
}
// Status
uint32
BDiskDeviceJob::Status() const
{
if (InitCheck() != B_OK)
return B_DISK_DEVICE_JOB_UNINITIALIZED;
disk_device_job_progress_info info;
status_t error = _kern_get_disk_device_job_progress_info(fID, &info);
if (error != B_OK)
return B_DISK_DEVICE_JOB_UNINITIALIZED;
return info.status;
}
// Progress
float
BDiskDeviceJob::Progress() const
{
if (InitCheck() != B_OK)
return 0;
disk_device_job_progress_info info;
status_t error = _kern_get_disk_device_job_progress_info(fID, &info);
if (error != B_OK)
return 0;
if (info.task_count < 1 || info.task_count <= info.completed_tasks)
return 1;
if (info.current_task_progress < 0)
info.current_task_progress = 0;
if (info.current_task_progress > 1)
info.current_task_progress = 1;
return (info.completed_tasks + info.current_task_progress)
/ info.task_count;
}
// GetProgressInfo
status_t
BDiskDeviceJob::GetProgressInfo(disk_device_job_progress_info *info) const
{
if (InitCheck() != B_OK)
return InitCheck();
return _kern_get_disk_device_job_progress_info(fID, info);
}
// InterruptProperties
uint32
BDiskDeviceJob::InterruptProperties() const
{
if (InitCheck() != B_OK)
return 0;
disk_device_job_progress_info info;
status_t error = _kern_get_disk_device_job_progress_info(fID, &info);
if (error != B_OK)
return 0;
return info.interrupt_properties;
}
// Cancel
status_t
BDiskDeviceJob::Cancel(bool reverse)
{
if (InitCheck() != B_OK)
return InitCheck();
return _kern_cancel_disk_device_job(fID, reverse);
}
// Pause
status_t
BDiskDeviceJob::Pause()
{
if (InitCheck() != B_OK)
return InitCheck();
return _kern_pause_disk_device_job(fID);
}
// _SetTo
status_t
BDiskDeviceJob::_SetTo(user_disk_device_job_info *info)
{
Unset();
if (!info)
return B_BAD_VALUE;
fID = info->id;
fType = info->type;
fPartitionID = info->partition;
fDescription.SetTo(info->description);
return B_OK;
}

View File

@ -7,7 +7,6 @@
#include <Directory.h>
#include <DiskDevice.h>
#include <DiskDeviceJob.h>
#include <DiskDevicePrivate.h>
#include <DiskDeviceRoster.h>
#include <DiskSystem.h>
@ -86,7 +85,7 @@ BDiskDeviceRoster::GetNextDevice(BDiskDevice *device)
&neededSize);
if (id < 0)
return id;
return device->_SetTo(id, true, false, neededSize);
return device->_SetTo(id, true, neededSize);
}
// RewindDevices
@ -122,26 +121,6 @@ BDiskDeviceRoster::RewindDiskSystems()
return B_OK;
}
// GetNextActiveJob
status_t
BDiskDeviceRoster::GetNextActiveJob(BDiskDeviceJob *job)
{
if (!job)
return B_BAD_VALUE;
user_disk_device_job_info info;
status_t error = _kern_get_next_disk_device_job_info(&fJobCookie, &info);
if (error == B_OK)
error = job->_SetTo(&info);
return error;
}
// RewindActiveJobs
status_t
BDiskDeviceRoster::RewindActiveJobs()
{
fJobCookie = 0;
return B_OK;
}
// RegisterFileDevice
partition_id
@ -334,7 +313,7 @@ BDiskDeviceRoster::GetDeviceWithID(int32 id, BDiskDevice *device) const
{
if (!device)
return B_BAD_VALUE;
return device->_SetTo(id, true, false, 0);
return device->_SetTo(id, true, 0);
}
// GetPartitionWithID
@ -361,7 +340,7 @@ BDiskDeviceRoster::GetPartitionWithID(int32 id, BDiskDevice *device,
if (!device || !partition)
return B_BAD_VALUE;
// download the device data
status_t error = device->_SetTo(id, false, false, 0);
status_t error = device->_SetTo(id, false, 0);
if (error != B_OK)
return error;
// find the partition object
@ -383,7 +362,7 @@ BDiskDeviceRoster::GetDeviceForPath(const char *filename, BDiskDevice *device)
if (id < 0)
return id;
// download the device data
return device->_SetTo(id, true, false, neededSize);
return device->_SetTo(id, true, neededSize);
}
// GetPartitionForPath
@ -400,7 +379,7 @@ BDiskDeviceRoster::GetPartitionForPath(const char *filename,
if (id < 0)
return id;
// download the device data
status_t error = device->_SetTo(id, false, false, neededSize);
status_t error = device->_SetTo(id, false, neededSize);
if (error != B_OK)
return error;
// find the partition object
@ -454,14 +433,6 @@ BDiskDeviceRoster::StartWatching(BMessenger target, uint32 eventMask)
return B_ERROR;
}
// StartWatchingJob
status_t
BDiskDeviceRoster::StartWatchingJob(BDiskDeviceJob *job, BMessenger target,
uint32 eventMask)
{
// not implemented
return B_ERROR;
}
// StopWatching
/*! \brief Remove a target from the list of targets to be notified on disk

View File

@ -71,7 +71,6 @@ MergeObject <libbe>storage_kit.o :
# disk device API
DiskDevice.cpp
DiskDeviceJob.cpp
DiskDeviceList.cpp
DiskDevicePrivate.cpp
DiskDeviceRoster.cpp

View File

@ -1397,14 +1397,6 @@ BPartition::_RemoveChild(int32 index)
}
// _IsShadow
bool
BPartition::_IsShadow() const
{
return (fPartitionData && fPartitionData->shadow_id >= 0);
}
// _CountDescendants
int32
BPartition::_CountDescendants() const