From 1573b62671c47e8b30966e97d830cece957e0ee3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 17 Oct 2007 22:56:23 +0000 Subject: [PATCH] * 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 --- headers/private/storage/DiskDevice.h | 6 +- headers/private/storage/DiskDeviceJob.h | 47 ------ headers/private/storage/DiskDeviceRoster.h | 8 - headers/private/storage/Partition.h | 2 - src/kits/storage/DiskDevice.cpp | 57 +++---- src/kits/storage/DiskDeviceJob.cpp | 168 --------------------- src/kits/storage/DiskDeviceRoster.cpp | 39 +---- src/kits/storage/Jamfile | 1 - src/kits/storage/Partition.cpp | 8 - 9 files changed, 32 insertions(+), 304 deletions(-) delete mode 100644 headers/private/storage/DiskDeviceJob.h delete mode 100644 src/kits/storage/DiskDeviceJob.cpp diff --git a/headers/private/storage/DiskDevice.h b/headers/private/storage/DiskDevice.h index b7ba1877c1..a9cf2b975c 100644 --- a/headers/private/storage/DiskDevice.h +++ b/headers/private/storage/DiskDevice.h @@ -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); diff --git a/headers/private/storage/DiskDeviceJob.h b/headers/private/storage/DiskDeviceJob.h deleted file mode 100644 index d4368ff89d..0000000000 --- a/headers/private/storage/DiskDeviceJob.h +++ /dev/null @@ -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 -#include - -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 diff --git a/headers/private/storage/DiskDeviceRoster.h b/headers/private/storage/DiskDeviceRoster.h index 1d51dc4dfe..31ff52001d 100644 --- a/headers/private/storage/DiskDeviceRoster.h +++ b/headers/private/storage/DiskDeviceRoster.h @@ -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//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: diff --git a/headers/private/storage/Partition.h b/headers/private/storage/Partition.h index f8d47fc35a..53737e8e12 100644 --- a/headers/private/storage/Partition.h +++ b/headers/private/storage/Partition.h @@ -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, diff --git a/src/kits/storage/DiskDevice.cpp b/src/kits/storage/DiskDevice.cpp index 11bdfb05b7..b4e3c664c6 100644 --- a/src/kits/storage/DiskDevice.cpp +++ b/src/kits/storage/DiskDevice.cpp @@ -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) diff --git a/src/kits/storage/DiskDeviceJob.cpp b/src/kits/storage/DiskDeviceJob.cpp deleted file mode 100644 index 587e72bb41..0000000000 --- a/src/kits/storage/DiskDeviceJob.cpp +++ /dev/null @@ -1,168 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#include - -#include -#include - -// 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; -} - diff --git a/src/kits/storage/DiskDeviceRoster.cpp b/src/kits/storage/DiskDeviceRoster.cpp index 22aaf92ac4..e1fdb3c85b 100644 --- a/src/kits/storage/DiskDeviceRoster.cpp +++ b/src/kits/storage/DiskDeviceRoster.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -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 diff --git a/src/kits/storage/Jamfile b/src/kits/storage/Jamfile index 81a639a5b1..6da570c572 100644 --- a/src/kits/storage/Jamfile +++ b/src/kits/storage/Jamfile @@ -71,7 +71,6 @@ MergeObject storage_kit.o : # disk device API DiskDevice.cpp - DiskDeviceJob.cpp DiskDeviceList.cpp DiskDevicePrivate.cpp DiskDeviceRoster.cpp diff --git a/src/kits/storage/Partition.cpp b/src/kits/storage/Partition.cpp index fc8bd19b13..56cc27ef57 100644 --- a/src/kits/storage/Partition.cpp +++ b/src/kits/storage/Partition.cpp @@ -1397,14 +1397,6 @@ BPartition::_RemoveChild(int32 index) } -// _IsShadow -bool -BPartition::_IsShadow() const -{ - return (fPartitionData && fPartitionData->shadow_id >= 0); -} - - // _CountDescendants int32 BPartition::_CountDescendants() const