diff --git a/headers/os/storage/DiskDeviceDefs.h b/headers/os/storage/DiskDeviceDefs.h index e6fdfec717..ae626d6c13 100644 --- a/headers/os/storage/DiskDeviceDefs.h +++ b/headers/os/storage/DiskDeviceDefs.h @@ -110,8 +110,8 @@ enum { B_DISK_DEVICE_JOB_SET_NAME, B_DISK_DEVICE_JOB_SET_CONTENT_NAME, B_DISK_DEVICE_JOB_SET_TYPE, - B_DISK_DEVICE_JOB_SET_PARMETERS, - B_DISK_DEVICE_JOB_SET_CONTENT_PARMETERS, + B_DISK_DEVICE_JOB_SET_PARAMETERS, + B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS, B_DISK_DEVICE_JOB_INITIALIZE, B_DISK_DEVICE_JOB_UNINITIALIZE, B_DISK_DEVICE_JOB_CREATE, diff --git a/headers/private/storage/Partition.h b/headers/private/storage/Partition.h index 037ca07ca9..97e8a11ba7 100644 --- a/headers/private/storage/Partition.h +++ b/headers/private/storage/Partition.h @@ -194,6 +194,7 @@ private: BPartition* _ChildAt(int32 index) const; int32 _CountChildren() const; + int32 _CountDescendants() const; int32 _Level() const; virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor, diff --git a/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp b/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp index cf08ed0783..34c6fcf263 100644 --- a/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp +++ b/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp @@ -19,7 +19,15 @@ #include "PartitionDelegate.h" #include "PartitionReference.h" +#include "CreateChildJob.h" +#include "DeleteChildJob.h" +#include "DefragmentJob.h" #include "InitializeJob.h" +#include "MoveJob.h" +#include "RepairJob.h" +#include "ResizeJob.h" +#include "SetStringJob.h" +#include "UninitializeJob.h" using std::nothrow; @@ -84,13 +92,18 @@ DiskDeviceJobGenerator::DiskDeviceJobGenerator(BDiskDevice* device, : fDevice(device), fJobQueue(jobQueue), fMoveInfos(NULL), - fPartitionRefs(NULL) + fPartitionRefs(NULL), + fContentsToMove(NULL), + fContentsToMoveCount(0) { - fPartitionCount = fDevice->CountDescendants(); + // Make sure the arrays are big enough (worst case: all old partitions have + // been deleted and new ones been created). + fPartitionCount = fDevice->CountDescendants() + + fDevice->_CountDescendants(); fMoveInfos = new(nothrow) MoveInfo[fPartitionCount]; -// fPartitionIDs = new(nothrow) partition_id[fPartitionCount]; fPartitionRefs = new(nothrow) PartitionRefInfo[fPartitionCount]; + fContentsToMove = new(nothrow) PartitionReference*[fPartitionCount]; } @@ -98,8 +111,8 @@ DiskDeviceJobGenerator::DiskDeviceJobGenerator(BDiskDevice* device, DiskDeviceJobGenerator::~DiskDeviceJobGenerator() { delete[] fMoveInfos; -// delete[] fPartitionIDs; delete[] fPartitionRefs; + delete[] fContentsToMove; } @@ -111,7 +124,7 @@ DiskDeviceJobGenerator::GenerateJobs() if (!fDevice || !fJobQueue) return B_BAD_VALUE; - if (!fMoveInfos /*|| !fPartitionIDs*/ || !fPartitionRefs) + if (!fMoveInfos || !fPartitionRefs || !fContentsToMove) return B_NO_MEMORY; // 1) Generate jobs for all physical partitions that don't have an @@ -268,7 +281,7 @@ DiskDeviceJobGenerator::_GenerateChildPlacementJobs(BPartition* partition) // sort the move infos if (childCount > 0 && moveForth + moveBack > 0) { qsort(fMoveInfos, childCount, sizeof(MoveInfo), - _CompareMoveInfoPosition); + _CompareMoveInfoPosition); } // move the children to their final positions @@ -277,7 +290,7 @@ DiskDeviceJobGenerator::_GenerateChildPlacementJobs(BPartition* partition) if (moveForth < moveBack) { // move children back for (int32 i = 0; i < childCount; i++) { - MoveInfo &info = fMoveInfos[i]; + MoveInfo& info = fMoveInfos[i]; if (info.position > info.target_position) { if (i == 0 || info.target_position >= fMoveInfos[i - 1].position @@ -488,8 +501,12 @@ DiskDeviceJobGenerator::_GenerateInitializeJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateUninitializeJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + return _AddJob(new(nothrow) UninitializeJob(reference)); } @@ -497,8 +514,23 @@ DiskDeviceJobGenerator::_GenerateUninitializeJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateSetContentNameJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + SetStringJob* job = new(nothrow) SetStringJob(reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->ContentName(), + B_DISK_DEVICE_JOB_SET_CONTENT_NAME); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -506,8 +538,23 @@ DiskDeviceJobGenerator::_GenerateSetContentNameJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateSetContentParametersJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + SetStringJob* job = new(nothrow) SetStringJob(reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->ContentParameters(), + B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -515,8 +562,12 @@ DiskDeviceJobGenerator::_GenerateSetContentParametersJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateDefragmentJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + return _AddJob(new(nothrow) DefragmentJob(reference)); } @@ -524,8 +575,12 @@ DiskDeviceJobGenerator::_GenerateDefragmentJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateRepairJob(BPartition* partition, bool repair) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + return _AddJob(new(nothrow) RepairJob(reference, repair)); } @@ -534,18 +589,48 @@ status_t DiskDeviceJobGenerator::_GenerateCreateChildJob(BPartition* parent, BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + CreateChildJob* job = new(nothrow) CreateChildJob(parentReference, + reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->Offset(), partition->Size(), partition->Type(), + partition->Name(), partition->Parameters()); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } // _GenerateDeleteChildJob status_t DiskDeviceJobGenerator::_GenerateDeleteChildJob(BPartition* parent, - BPartition* child) + BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + return _AddJob(new(nothrow) DeleteChildJob(parentReference, reference)); } @@ -553,8 +638,22 @@ DiskDeviceJobGenerator::_GenerateDeleteChildJob(BPartition* parent, status_t DiskDeviceJobGenerator::_GenerateResizeJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + BPartition* parent = partition->Parent(); + if (!parent) + return B_BAD_VALUE; + + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + return _AddJob(new(nothrow) ResizeJob(parentReference, reference, + partition->Size(), partition->ContentSize())); } @@ -562,8 +661,39 @@ DiskDeviceJobGenerator::_GenerateResizeJob(BPartition* partition) status_t DiskDeviceJobGenerator::_GenerateMoveJob(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + BPartition* parent = partition->Parent(); + if (!parent) + return B_BAD_VALUE; + + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + // collect all descendants whose contents need to be moved + fContentsToMoveCount = 0; + error = _CollectContentsToMove(partition); + if (error != B_OK) + return B_OK; + + // create and init the job + MoveJob* job = new(nothrow) MoveJob(parentReference, reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->Offset(), fContentsToMove, + fContentsToMoveCount); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -572,8 +702,27 @@ status_t DiskDeviceJobGenerator::_GenerateSetNameJob(BPartition* parent, BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + SetStringJob* job = new(nothrow) SetStringJob(parentReference, reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->Name(), B_DISK_DEVICE_JOB_SET_NAME); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -582,8 +731,27 @@ status_t DiskDeviceJobGenerator::_GenerateSetTypeJob(BPartition* parent, BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + SetStringJob* job = new(nothrow) SetStringJob(parentReference, reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->Type(), B_DISK_DEVICE_JOB_SET_TYPE); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -592,8 +760,28 @@ status_t DiskDeviceJobGenerator::_GenerateSetParametersJob(BPartition* parent, BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + PartitionReference* parentReference; + status_t error = _GetPartitionReference(parent, parentReference); + if (error != B_OK) + return error; + + PartitionReference* reference; + error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + SetStringJob* job = new(nothrow) SetStringJob(parentReference, reference); + if (!job) + return B_NO_MEMORY; + + error = job->Init(partition->Parameters(), + B_DISK_DEVICE_JOB_SET_PARAMETERS); + if (error != B_OK) { + delete job; + return error; + } + + return _AddJob(job); } @@ -601,8 +789,43 @@ DiskDeviceJobGenerator::_GenerateSetParametersJob(BPartition* parent, status_t DiskDeviceJobGenerator::_CollectContentsToMove(BPartition* partition) { -// TODO: Implement! - return B_BAD_VALUE; + BMutablePartition* shadow = _GetMutablePartition(partition); + if (shadow->Status() == B_PARTITION_UNRECOGNIZED) + return B_ERROR; + + // if the partition has contents, push its ID + if (shadow->ContentType() + && !(shadow->ChangeFlags() & B_PARTITION_CHANGED_INITIALIZATION)) { + status_t error = _PushContentsToMove(partition); + if (error != B_OK) + return error; + } + + // recurse + for (int32 i = 0; BPartition* child = partition->ChildAt(i); i++) { + status_t error = _CollectContentsToMove(child); + if (error != B_OK) + return error; + } + return B_OK; +} + + +// _PushContentsToMove +status_t +DiskDeviceJobGenerator::_PushContentsToMove(BPartition* partition) +{ + if (fContentsToMoveCount >= fPartitionCount) + return B_ERROR; + + PartitionReference* reference; + status_t error = _GetPartitionReference(partition, reference); + if (error != B_OK) + return error; + + fContentsToMove[fContentsToMoveCount++] = reference; + + return B_OK; } diff --git a/src/kits/storage/disk_device/DiskDeviceJobGenerator.h b/src/kits/storage/disk_device/DiskDeviceJobGenerator.h index af7dd901f7..bc00e02b62 100644 --- a/src/kits/storage/disk_device/DiskDeviceJobGenerator.h +++ b/src/kits/storage/disk_device/DiskDeviceJobGenerator.h @@ -54,7 +54,7 @@ private: status_t _GenerateCreateChildJob(BPartition* parent, BPartition* partition); status_t _GenerateDeleteChildJob(BPartition* parent, - BPartition* child); + BPartition* partition); status_t _GenerateResizeJob(BPartition* partition); status_t _GenerateMoveJob(BPartition* partition); status_t _GenerateSetNameJob(BPartition* parent, @@ -65,6 +65,7 @@ private: BPartition* partition); status_t _CollectContentsToMove(BPartition* partition); + status_t _PushContentsToMove(BPartition* partition); status_t _GetPartitionReference(BPartition* partition, PartitionReference*& reference); @@ -81,6 +82,8 @@ private: MoveInfo* fMoveInfos; int32 fPartitionCount; PartitionRefInfo* fPartitionRefs; + PartitionReference** fContentsToMove; + int32 fContentsToMoveCount; }; diff --git a/src/kits/storage/disk_device/Partition.cpp b/src/kits/storage/disk_device/Partition.cpp index e25ac70113..73593aa05b 100644 --- a/src/kits/storage/disk_device/Partition.cpp +++ b/src/kits/storage/disk_device/Partition.cpp @@ -1425,6 +1425,17 @@ BPartition::_CountChildren() const } +// _CountDescendants +int32 +BPartition::_CountDescendants() const +{ + int32 count = 1; + for (int32 i = 0; BPartition* child = _ChildAt(i); i++) + count += child->_CountDescendants(); + return count; +} + + // _Level int32 BPartition::_Level() const diff --git a/src/kits/storage/disk_device/jobs/CreateChildJob.cpp b/src/kits/storage/disk_device/jobs/CreateChildJob.cpp new file mode 100644 index 0000000000..59d05b0233 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/CreateChildJob.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "CreateChildJob.h" + +#include "DiskDeviceUtils.h" +#include "PartitionReference.h" + + +// constructor +CreateChildJob::CreateChildJob(PartitionReference* partition, + PartitionReference* child) + : DiskDeviceJob(partition, child), + fOffset(0), + fSize(0), + fType(NULL), + fName(NULL), + fParameters(NULL) +{ +} + + +// destructor +CreateChildJob::~CreateChildJob() +{ + free(fType); + free(fName); + free(fParameters); +} + + +// Init +status_t +CreateChildJob::Init(off_t offset, off_t size, const char* type, + const char* name, const char* parameters) +{ + fOffset = offset; + fSize = size; + + SET_STRING_RETURN_ON_ERROR(fType, type); + SET_STRING_RETURN_ON_ERROR(fName, name); + SET_STRING_RETURN_ON_ERROR(fParameters, parameters); + + return B_OK; +} + + +// Do +status_t +CreateChildJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/CreateChildJob.h b/src/kits/storage/disk_device/jobs/CreateChildJob.h new file mode 100644 index 0000000000..ad59eda996 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/CreateChildJob.h @@ -0,0 +1,40 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _CREATE_CHILD_JOB_H +#define _CREATE_CHILD_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class CreateChildJob : public DiskDeviceJob { +public: + + CreateChildJob(PartitionReference* partition, + PartitionReference* child); + virtual ~CreateChildJob(); + + status_t Init(off_t offset, off_t size, + const char* type, const char* name, + const char* parameters); + + virtual status_t Do(); + +protected: + off_t fOffset; + off_t fSize; + char* fType; + char* fName; + char* fParameters; +}; + + +} // namespace BPrivate + +using BPrivate::CreateChildJob; + +#endif // _CREATE_CHILD_JOB_H diff --git a/src/kits/storage/disk_device/jobs/DefragmentJob.cpp b/src/kits/storage/disk_device/jobs/DefragmentJob.cpp new file mode 100644 index 0000000000..457f92a2fd --- /dev/null +++ b/src/kits/storage/disk_device/jobs/DefragmentJob.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "DefragmentJob.h" + +#include "PartitionReference.h" + + +// constructor +DefragmentJob::DefragmentJob(PartitionReference* partition) + : DiskDeviceJob(partition) +{ +} + + +// destructor +DefragmentJob::~DefragmentJob() +{ +} + + +// Do +status_t +DefragmentJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/DefragmentJob.h b/src/kits/storage/disk_device/jobs/DefragmentJob.h new file mode 100644 index 0000000000..9dc0346b90 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/DefragmentJob.h @@ -0,0 +1,28 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _DEFRAGMENT_JOB_H +#define _DEFRAGMENT_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class DefragmentJob : public DiskDeviceJob { +public: + + DefragmentJob(PartitionReference* partition); + virtual ~DefragmentJob(); + + virtual status_t Do(); +}; + + +} // namespace BPrivate + +using BPrivate::DefragmentJob; + +#endif // _DEFRAGMENT_JOB_H diff --git a/src/kits/storage/disk_device/jobs/DeleteChildJob.cpp b/src/kits/storage/disk_device/jobs/DeleteChildJob.cpp new file mode 100644 index 0000000000..80a5087ee6 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/DeleteChildJob.cpp @@ -0,0 +1,33 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "DeleteChildJob.h" + +#include "DiskDeviceUtils.h" +#include "PartitionReference.h" + + +// constructor +DeleteChildJob::DeleteChildJob(PartitionReference* partition, + PartitionReference* child) + : DiskDeviceJob(partition, child) +{ +} + + +// destructor +DeleteChildJob::~DeleteChildJob() +{ +} + + +// Do +status_t +DeleteChildJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/DeleteChildJob.h b/src/kits/storage/disk_device/jobs/DeleteChildJob.h new file mode 100644 index 0000000000..eaa079e401 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/DeleteChildJob.h @@ -0,0 +1,29 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _DELETE_CHILD_JOB_H +#define _DELETE_CHILD_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class DeleteChildJob : public DiskDeviceJob { +public: + + DeleteChildJob(PartitionReference* partition, + PartitionReference* child); + virtual ~DeleteChildJob(); + + virtual status_t Do(); +}; + + +} // namespace BPrivate + +using BPrivate::DeleteChildJob; + +#endif // _DELETE_CHILD_JOB_H diff --git a/src/kits/storage/disk_device/jobs/MoveJob.cpp b/src/kits/storage/disk_device/jobs/MoveJob.cpp new file mode 100644 index 0000000000..738523b11a --- /dev/null +++ b/src/kits/storage/disk_device/jobs/MoveJob.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include "MoveJob.h" + +#include "DiskDeviceUtils.h" +#include "PartitionReference.h" + + +using std::nothrow; + + +// constructor +MoveJob::MoveJob(PartitionReference* partition, PartitionReference* child) + : DiskDeviceJob(partition, child), + fContents(NULL), + fContentsCount(0) +{ +} + + +// destructor +MoveJob::~MoveJob() +{ + if (fContents) { + for (int32 i = 0; i < fContentsCount; i++) + fContents[i]->RemoveReference(); + delete[] fContents; + } +} + + +// Init +status_t +MoveJob::Init(off_t offset, PartitionReference** contents, int32 contentsCount) +{ + fContents = new(nothrow) PartitionReference*[contentsCount]; + if (!fContents) + return B_NO_MEMORY; + + fContentsCount = contentsCount; + for (int32 i = 0; i < contentsCount; i++) { + fContents[i] = contents[i]; + fContents[i]->AddReference(); + } + + fOffset = offset; + + return B_OK; +} + + +// Do +status_t +MoveJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/MoveJob.h b/src/kits/storage/disk_device/jobs/MoveJob.h new file mode 100644 index 0000000000..ac4591991b --- /dev/null +++ b/src/kits/storage/disk_device/jobs/MoveJob.h @@ -0,0 +1,38 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _MOVE_JOB_H +#define _MOVE_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class MoveJob : public DiskDeviceJob { +public: + + MoveJob(PartitionReference* partition, + PartitionReference* child); + virtual ~MoveJob(); + + status_t Init(off_t offset, + PartitionReference** contents, + int32 contentsCount); + + virtual status_t Do(); + +protected: + off_t fOffset; + PartitionReference** fContents; + int32 fContentsCount; +}; + + +} // namespace BPrivate + +using BPrivate::MoveJob; + +#endif // _MOVE_JOB_H diff --git a/src/kits/storage/disk_device/jobs/RepairJob.cpp b/src/kits/storage/disk_device/jobs/RepairJob.cpp new file mode 100644 index 0000000000..b23ee1ddd8 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/RepairJob.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "RepairJob.h" + +#include "PartitionReference.h" + + +// constructor +RepairJob::RepairJob(PartitionReference* partition, bool checkOnly) + : DiskDeviceJob(partition), + fCheckOnly(checkOnly) +{ +} + + +// destructor +RepairJob::~RepairJob() +{ +} + + +// Do +status_t +RepairJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/RepairJob.h b/src/kits/storage/disk_device/jobs/RepairJob.h new file mode 100644 index 0000000000..084a9257b1 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/RepairJob.h @@ -0,0 +1,32 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _REPAIR_JOB_H +#define _REPAIR_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class RepairJob : public DiskDeviceJob { +public: + + RepairJob(PartitionReference* partition, + bool checkOnly); + virtual ~RepairJob(); + + virtual status_t Do(); + +private: + bool fCheckOnly; +}; + + +} // namespace BPrivate + +using BPrivate::RepairJob; + +#endif // _REPAIR_JOB_H diff --git a/src/kits/storage/disk_device/jobs/ResizeJob.cpp b/src/kits/storage/disk_device/jobs/ResizeJob.cpp new file mode 100644 index 0000000000..f15c7c0aef --- /dev/null +++ b/src/kits/storage/disk_device/jobs/ResizeJob.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ResizeJob.h" + +#include "DiskDeviceUtils.h" +#include "PartitionReference.h" + + +// constructor +ResizeJob::ResizeJob(PartitionReference* partition, PartitionReference* child, + off_t size, off_t contentSize) + : DiskDeviceJob(partition, child), + fSize(size), + fContentSize(contentSize) +{ +} + + +// destructor +ResizeJob::~ResizeJob() +{ +} + + +// Do +status_t +ResizeJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/ResizeJob.h b/src/kits/storage/disk_device/jobs/ResizeJob.h new file mode 100644 index 0000000000..f8892c976d --- /dev/null +++ b/src/kits/storage/disk_device/jobs/ResizeJob.h @@ -0,0 +1,34 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _RESIZE_JOB_H +#define _RESIZE_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class ResizeJob : public DiskDeviceJob { +public: + + ResizeJob(PartitionReference* partition, + PartitionReference* child, off_t size, + off_t contentSize); + virtual ~ResizeJob(); + + virtual status_t Do(); + +protected: + off_t fSize; + off_t fContentSize; +}; + + +} // namespace BPrivate + +using BPrivate::ResizeJob; + +#endif // _RESIZE_JOB_H diff --git a/src/kits/storage/disk_device/jobs/SetStringJob.cpp b/src/kits/storage/disk_device/jobs/SetStringJob.cpp new file mode 100644 index 0000000000..530ad42a33 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/SetStringJob.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "SetStringJob.h" + +#include "DiskDeviceUtils.h" +#include "PartitionReference.h" + + +// constructor +SetStringJob::SetStringJob(PartitionReference* partition, + PartitionReference* child) + : DiskDeviceJob(partition, child), + fString(NULL) +{ +} + + +// destructor +SetStringJob::~SetStringJob() +{ + free(fString); +} + + +// Init +status_t +SetStringJob::Init(const char* string, uint32 jobType) +{ + switch (jobType) { + case B_DISK_DEVICE_JOB_SET_NAME: + case B_DISK_DEVICE_JOB_SET_CONTENT_NAME: + case B_DISK_DEVICE_JOB_SET_TYPE: + case B_DISK_DEVICE_JOB_SET_PARAMETERS: + case B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS: + break; + default: + return B_BAD_VALUE; + } + + fJobType = jobType; + SET_STRING_RETURN_ON_ERROR(fString, string); + + return B_OK; +} + + +// Do +status_t +SetStringJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/SetStringJob.h b/src/kits/storage/disk_device/jobs/SetStringJob.h new file mode 100644 index 0000000000..df1607af93 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/SetStringJob.h @@ -0,0 +1,35 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _SET_STRING_JOB_H +#define _SET_STRING_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class SetStringJob : public DiskDeviceJob { +public: + + SetStringJob(PartitionReference* partition, + PartitionReference* child = NULL); + virtual ~SetStringJob(); + + status_t Init(const char* string, uint32 jobType); + + virtual status_t Do(); + +protected: + char* fString; + uint32 fJobType; +}; + + +} // namespace BPrivate + +using BPrivate::SetStringJob; + +#endif // _SET_STRING_JOB_H diff --git a/src/kits/storage/disk_device/jobs/UninitializeJob.cpp b/src/kits/storage/disk_device/jobs/UninitializeJob.cpp new file mode 100644 index 0000000000..2a2100c5ee --- /dev/null +++ b/src/kits/storage/disk_device/jobs/UninitializeJob.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "UninitializeJob.h" + +#include "PartitionReference.h" + + +// constructor +UninitializeJob::UninitializeJob(PartitionReference* partition) + : DiskDeviceJob(partition) +{ +} + + +// destructor +UninitializeJob::~UninitializeJob() +{ +} + + +// Do +status_t +UninitializeJob::Do() +{ +// Implement! + return B_BAD_VALUE; +} + diff --git a/src/kits/storage/disk_device/jobs/UninitializeJob.h b/src/kits/storage/disk_device/jobs/UninitializeJob.h new file mode 100644 index 0000000000..21e7d03312 --- /dev/null +++ b/src/kits/storage/disk_device/jobs/UninitializeJob.h @@ -0,0 +1,28 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _UNINITIALIZE_JOB_H +#define _UNINITIALIZE_JOB_H + +#include "DiskDeviceJob.h" + + +namespace BPrivate { + + +class UninitializeJob : public DiskDeviceJob { +public: + + UninitializeJob(PartitionReference* partition); + virtual ~UninitializeJob(); + + virtual status_t Do(); +}; + + +} // namespace BPrivate + +using BPrivate::UninitializeJob; + +#endif // _UNINITIALIZE_JOB_H