From 7f96148cacdbf4ed476c22e6e8148b7f44a91d9e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 20 Jul 2009 20:29:16 +0000 Subject: [PATCH] Patch by Bryce Groff with changes by myself: * Added missing name parameter to the partitioning system module child creation and child creation validation hooks. Pass the name to them. * Added BPartitionParameterEditor interface, which is/will be used for editing disk system specific parameters. * Implemented partition parameter editors for BFS initialization and Intel partition map child creation. * Fixed the incorrect supported child partition type iteration in the Intel partition map add-on. It does now return actual types. * Handle the "active" flag parameter in the Intel partitioning system module. * DriveSetup: - Replaced the "Create" submenu by a simple menu item. The type can now by chosen in the dialog. - Make use of initialization and child creation parameter editors. Some non-generic code has been moved to the respective editor implementations (BFS, intel partitioning system). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31658 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/disk_device_manager/ddm_modules.h | 9 +- headers/private/storage/DiskSystemAddOn.h | 10 +- headers/private/storage/Partition.h | 14 +- .../storage/PartitionParameterEditor.h | 34 +++++ src/add-ons/disk_systems/bfs/BFSAddOn.cpp | 11 +- src/add-ons/disk_systems/bfs/BFSAddOn.h | 2 +- .../bfs/InitializeParameterEditor.cpp | 136 ++++++++++++++++++ .../bfs/InitializeParameterEditor.h | 38 +++++ src/add-ons/disk_systems/bfs/Jamfile | 1 + .../intel/CreationParameterEditor.cpp | 71 +++++++++ .../intel/CreationParameterEditor.h | 34 +++++ .../intel/ExtendedPartitionAddOn.cpp | 4 +- .../intel/ExtendedPartitionAddOn.h | 4 +- src/add-ons/disk_systems/intel/Jamfile | 1 + .../disk_systems/intel/PartitionMapAddOn.cpp | 95 +++++------- .../disk_systems/intel/PartitionMapAddOn.h | 4 +- .../intel/PartitionMap.cpp | 77 +++++----- .../partitioning_systems/intel/PartitionMap.h | 10 ++ .../intel/write_support.cpp | 33 +++-- .../intel/write_support.h | 18 +-- src/apps/drivesetup/CreateParamsPanel.cpp | 103 +++++++++---- src/apps/drivesetup/CreateParamsPanel.h | 16 ++- src/apps/drivesetup/InitParamsPanel.cpp | 80 ++++------- src/apps/drivesetup/InitParamsPanel.h | 11 +- src/apps/drivesetup/MainWindow.cpp | 61 +++----- src/apps/drivesetup/MainWindow.h | 5 +- src/kits/storage/Jamfile | 1 + .../storage/disk_device/DiskSystemAddOn.cpp | 8 +- src/kits/storage/disk_device/Partition.cpp | 24 ++-- .../storage/disk_device/PartitionDelegate.cpp | 8 +- .../storage/disk_device/PartitionDelegate.h | 8 +- .../disk_device/PartitionParameterEditor.cpp | 109 ++++++++++++++ .../KPartitioningSystem.cpp | 3 +- 33 files changed, 751 insertions(+), 292 deletions(-) create mode 100644 headers/private/storage/PartitionParameterEditor.h create mode 100644 src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp create mode 100644 src/add-ons/disk_systems/bfs/InitializeParameterEditor.h create mode 100644 src/add-ons/disk_systems/intel/CreationParameterEditor.cpp create mode 100644 src/add-ons/disk_systems/intel/CreationParameterEditor.h create mode 100644 src/kits/storage/disk_device/PartitionParameterEditor.cpp diff --git a/headers/private/kernel/disk_device_manager/ddm_modules.h b/headers/private/kernel/disk_device_manager/ddm_modules.h index 9a173ad4d9..eff0377bd2 100644 --- a/headers/private/kernel/disk_device_manager/ddm_modules.h +++ b/headers/private/kernel/disk_device_manager/ddm_modules.h @@ -57,8 +57,8 @@ typedef struct partition_module_info { bool (*validate_initialize)(partition_data* partition, char* name, const char* parameters); bool (*validate_create_child)(partition_data* partition, off_t* start, - off_t* size, const char* type, const char* parameters, - int32* index); + off_t* size, const char* type, const char* name, + const char* parameters, int32* index); status_t (*get_partitionable_spaces)(partition_data* partition, partitionable_space_data* buffer, int32 count, int32* actualCount); @@ -100,8 +100,9 @@ typedef struct partition_module_info { status_t (*initialize)(int fd, partition_id partition, const char* name, const char *parameters, off_t partitionSize, disk_job_id job); status_t (*create_child)(int fd, partition_id partition, off_t offset, - off_t size, const char* type, const char* parameters, - disk_job_id job, partition_id* childID); + off_t size, const char* type, const char* name, + const char* parameters, disk_job_id job, + partition_id* childID); // childID is used for the return value, but is also an optional input // parameter -- -1 to be ignored status_t (*delete_child)(int fd, partition_id partition, partition_id child, diff --git a/headers/private/storage/DiskSystemAddOn.h b/headers/private/storage/DiskSystemAddOn.h index d39fb7ecfc..5e8607d825 100644 --- a/headers/private/storage/DiskSystemAddOn.h +++ b/headers/private/storage/DiskSystemAddOn.h @@ -9,7 +9,7 @@ #include -class BDiskDeviceParameterEditor; +class BPartitionParameterEditor; class BList; class BMutablePartition; class BPartitionHandle; @@ -33,7 +33,7 @@ public: const BMutablePartition* partition); virtual status_t GetInitializationParameterEditor( const BMutablePartition* partition, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateInitialize( const BMutablePartition* partition, BString* name, const char* parameters); @@ -107,10 +107,10 @@ public: const char* type); virtual status_t GetContentParameterEditor( - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t GetParameterEditor( const BMutablePartition* child, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateSetContentParameters( const char* parameters); virtual status_t ValidateSetParameters( @@ -122,7 +122,7 @@ public: virtual status_t GetChildCreationParameterEditor( const char* type, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateCreateChild(off_t* offset, off_t* size, const char* type, BString* name, const char* parameters); diff --git a/headers/private/storage/Partition.h b/headers/private/storage/Partition.h index 295108d41f..204e36707e 100644 --- a/headers/private/storage/Partition.h +++ b/headers/private/storage/Partition.h @@ -6,6 +6,7 @@ #ifndef _PARTITION_H #define _PARTITION_H + #include #include #include @@ -14,7 +15,7 @@ class BBitmap; class BDiskDevice; -class BDiskDeviceParameterEditor; +class BPartitionParameterEditor; class BDiskDeviceVisitor; class BDiskSystem; class BMutablePartition; @@ -128,13 +129,13 @@ public: bool CanEditParameters() const; status_t GetParameterEditor( - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); status_t SetParameters(const char* parameters); bool CanEditContentParameters( bool* whileMounted = NULL) const; status_t GetContentParameterEditor( - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); status_t SetContentParameters(const char* parameters); status_t GetNextSupportedType(int32 *cookie, @@ -152,7 +153,7 @@ public: bool CanInitialize(const char* diskSystem) const; status_t GetInitializationParameterEditor( const char* system, - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t ValidateInitialize(const char* diskSystem, BString* name, const char* parameters); status_t Initialize(const char* diskSystem, @@ -164,7 +165,7 @@ public: bool CanCreateChild() const; status_t GetChildCreationParameterEditor( const char* type, - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t ValidateCreateChild(off_t* start, off_t* size, const char* type, BString* name, const char* parameters) const; @@ -176,6 +177,8 @@ public: bool CanDeleteChild(int32 index) const; status_t DeleteChild(int32 index); + bool SupportsChildName() const; + private: class Delegate; @@ -230,4 +233,5 @@ private: Delegate* fDelegate; }; + #endif // _PARTITION_H diff --git a/headers/private/storage/PartitionParameterEditor.h b/headers/private/storage/PartitionParameterEditor.h new file mode 100644 index 0000000000..701d84e759 --- /dev/null +++ b/headers/private/storage/PartitionParameterEditor.h @@ -0,0 +1,34 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ +#ifndef _PARTITION_PARAMETER_EDITOR_H +#define _PARTITION_PARAMETER_EDITOR_H + + +#include + + +// BPartitionParameterEditor +class BPartitionParameterEditor { +public: + BPartitionParameterEditor(); + virtual ~BPartitionParameterEditor(); + + virtual bool FinishedEditing(); + + virtual BView* View(); + + virtual status_t GetParameters(BString* parameters); + + // TODO: Those are child creation specific and shouldn't be in a generic + // interface. Something like a + // GenericPartitionParameterChanged(partition_parameter_type, + // const BVariant&) + // would be better. + virtual status_t PartitionTypeChanged(const char* type); + virtual status_t PartitionNameChanged(const char* name); +}; + + +#endif //_PARTITION_PARAMETER_EDITOR_H diff --git a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp index d352bbb74f..a129dbb7c5 100644 --- a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp +++ b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp @@ -5,7 +5,9 @@ * Distributed under the terms of the MIT License. */ + #include "BFSAddOn.h" +#include "InitializeParameterEditor.h" #include @@ -100,10 +102,15 @@ BFSAddOn::CanInitialize(const BMutablePartition* partition) // GetInitializationParameterEditor status_t BFSAddOn::GetInitializationParameterEditor(const BMutablePartition* partition, - BDiskDeviceParameterEditor** editor) + BPartitionParameterEditor** editor) { - // TODO: Implement! *editor = NULL; + + try { + *editor = new InitializeBFSEditor(); + } catch (std::bad_alloc) { + return B_NO_MEMORY; + } return B_OK; } diff --git a/src/add-ons/disk_systems/bfs/BFSAddOn.h b/src/add-ons/disk_systems/bfs/BFSAddOn.h index 6448055ec4..f7a8a09e0e 100644 --- a/src/add-ons/disk_systems/bfs/BFSAddOn.h +++ b/src/add-ons/disk_systems/bfs/BFSAddOn.h @@ -21,7 +21,7 @@ public: const BMutablePartition* partition); virtual status_t GetInitializationParameterEditor( const BMutablePartition* partition, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateInitialize( const BMutablePartition* partition, BString* name, const char* parameters); diff --git a/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp new file mode 100644 index 0000000000..0d0e4629f9 --- /dev/null +++ b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp @@ -0,0 +1,136 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include "InitializeParameterEditor.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static uint32 MSG_BLOCK_SIZE = 'blsz'; + + +InitializeBFSEditor::InitializeBFSEditor() + : + BPartitionParameterEditor(), + fView(NULL), + fNameTC(NULL), + fBlockSizeMF(NULL), + fParameters(NULL) +{ + _CreateViewControls(); +} + + +InitializeBFSEditor::~InitializeBFSEditor() +{ +} + + +BView* +InitializeBFSEditor::View() +{ + return fView; +} + + +bool +InitializeBFSEditor::FinishedEditing() +{ + fParameters = ""; + if (BMenuItem* item = fBlockSizeMF->Menu()->FindMarked()) { + const char* size; + BMessage* message = item->Message(); + if (!message || message->FindString("size", &size) < B_OK) + size = "2048"; + // TODO: use libroot driver settings API + fParameters << "block_size " << size << ";\n"; + } + fParameters << "name " << fNameTC->Text() << ";\n"; + + return true; +} + + +status_t +InitializeBFSEditor::GetParameters(BString* parameters) +{ + if (parameters == NULL) + return B_BAD_VALUE; + + *parameters = fParameters; + return B_OK; +} + + +status_t +InitializeBFSEditor::PartitionNameChanged(const char* name) +{ + fNameTC->SetText(name); + return B_OK; +} + + +void +InitializeBFSEditor::_CreateViewControls() +{ + fNameTC = new BTextControl("Name", "Haiku", NULL); + // TODO find out what is the max length for this specific FS partition name + fNameTC->TextView()->SetMaxBytes(31); + + BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize"); + BMessage* message = new BMessage(MSG_BLOCK_SIZE); + message->AddString("size", "1024"); + blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)", + message)); + message = new BMessage(MSG_BLOCK_SIZE); + message->AddString("size", "2048"); + BMenuItem* defaultItem = new BMenuItem("2048 (Recommended)", message); + blocksizeMenu->AddItem(defaultItem); + message = new BMessage(MSG_BLOCK_SIZE); + message->AddString("size", "4096"); + blocksizeMenu->AddItem(new BMenuItem("4096", message)); + message = new BMessage(MSG_BLOCK_SIZE); + message->AddString("size", "8192"); + blocksizeMenu->AddItem(new BMenuItem("8192 (Mostly large files)", + message)); + + fBlockSizeMF = new BMenuField("Blocksize", blocksizeMenu, NULL); + defaultItem->SetMarked(true); + + fView = BGroupLayoutBuilder(B_VERTICAL, 5) + .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) + + // test views + .Add(BGridLayoutBuilder(10, 10) + // row 1 + .Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 0, 0) + + .Add(fNameTC->CreateLabelLayoutItem(), 1, 0) + .Add(fNameTC->CreateTextViewLayoutItem(), 2, 0) + + .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 3, 0) + + // row 2 + .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1) + + .Add(fBlockSizeMF->CreateLabelLayoutItem(), 1, 1) + .Add(fBlockSizeMF->CreateMenuBarLayoutItem(), 2, 1) + + .Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 3, 1) + ) + ; +} diff --git a/src/add-ons/disk_systems/bfs/InitializeParameterEditor.h b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.h new file mode 100644 index 0000000000..574c5461c8 --- /dev/null +++ b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ +#ifndef _INITIALIZE_PARAMETER_EDITOR +#define _INITIALIZE_PARAMETER_EDITOR + + +#include + +#include +#include +#include +#include + + +class InitializeBFSEditor : public BPartitionParameterEditor { +public: + InitializeBFSEditor(); + virtual ~InitializeBFSEditor(); + + virtual bool FinishedEditing(); + virtual BView* View(); + virtual status_t GetParameters(BString* parameters); + + virtual status_t PartitionNameChanged(const char* name); + +private: + void _CreateViewControls(); + + BView* fView; + BTextControl* fNameTC; + BMenuField* fBlockSizeMF; + BString fParameters; +}; + + +#endif //_INITIALIZE_PARAMETER_EDITOR diff --git a/src/add-ons/disk_systems/bfs/Jamfile b/src/add-ons/disk_systems/bfs/Jamfile index 77ecc3cb6b..2be9729ed8 100644 --- a/src/add-ons/disk_systems/bfs/Jamfile +++ b/src/add-ons/disk_systems/bfs/Jamfile @@ -7,6 +7,7 @@ SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems bfs ] ; Addon bfs : BFSAddOn.cpp + InitializeParameterEditor.cpp bfs_disk_system.cpp diff --git a/src/add-ons/disk_systems/intel/CreationParameterEditor.cpp b/src/add-ons/disk_systems/intel/CreationParameterEditor.cpp new file mode 100644 index 0000000000..94504fb4bf --- /dev/null +++ b/src/add-ons/disk_systems/intel/CreationParameterEditor.cpp @@ -0,0 +1,71 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ + + +#include "CreationParameterEditor.h" + +#include +#include +#include +#include + + +PrimaryPartitionEditor::PrimaryPartitionEditor() + : + BPartitionParameterEditor(), + fView(NULL), + fActiveCB(NULL), + fParameters(NULL) +{ + fActiveCB = new BCheckBox("active", "Active Partition", NULL); + fView = BGroupLayoutBuilder(B_VERTICAL, 4) + .Add(fActiveCB) + ; +} + + +PrimaryPartitionEditor::~PrimaryPartitionEditor() +{ +} + + +BView* +PrimaryPartitionEditor::View() +{ + return fView; +} + + +bool +PrimaryPartitionEditor::FinishedEditing() +{ + if (fActiveCB->IsEnabled()) { + if (fActiveCB->Value() == B_CONTROL_ON) + fParameters.SetTo("active true ;"); + else + fParameters.SetTo("active false ;"); + } else fParameters.SetTo(""); + + return true; +} + + +status_t +PrimaryPartitionEditor::GetParameters(BString* parameters) +{ + if (fParameters == NULL) + return B_BAD_VALUE; + + *parameters = fParameters; + return B_OK; +} + + +status_t +PrimaryPartitionEditor::PartitionTypeChanged(const char* type) +{ + fActiveCB->SetEnabled(strcmp(type, kPartitionTypeIntelExtended) != 0); + return B_OK; +} diff --git a/src/add-ons/disk_systems/intel/CreationParameterEditor.h b/src/add-ons/disk_systems/intel/CreationParameterEditor.h new file mode 100644 index 0000000000..b31dc57122 --- /dev/null +++ b/src/add-ons/disk_systems/intel/CreationParameterEditor.h @@ -0,0 +1,34 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ +#ifndef _CREATION_PARAMETER_EDITOR +#define _CREATION_PARAMETER_EDITOR + + +#include + +#include +#include +#include + + +class PrimaryPartitionEditor : public BPartitionParameterEditor { +public: + PrimaryPartitionEditor(); + virtual ~PrimaryPartitionEditor(); + + virtual bool FinishedEditing(); + virtual BView* View(); + virtual status_t GetParameters(BString* parameters); + + virtual status_t PartitionTypeChanged(const char* type); + +private: + BView* fView; + BCheckBox* fActiveCB; + BString fParameters; +}; + + +#endif //_CREATION_PARAMETER_EDITOR diff --git a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp index 9c551be3e2..feebe0813f 100644 --- a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp +++ b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp @@ -99,7 +99,7 @@ ExtendedPartitionAddOn::CanInitialize(const BMutablePartition* partition) // GetInitializationParameterEditor status_t ExtendedPartitionAddOn::GetInitializationParameterEditor( - const BMutablePartition* partition, BDiskDeviceParameterEditor** editor) + const BMutablePartition* partition, BPartitionParameterEditor** editor) { // Nothing to edit, really. *editor = NULL; @@ -307,7 +307,7 @@ info->PrintToStream(); // GetChildCreationParameterEditor status_t ExtendedPartitionHandle::GetChildCreationParameterEditor(const char* type, - BDiskDeviceParameterEditor** editor) + BPartitionParameterEditor** editor) { // TODO: We actually need an editor here. *editor = NULL; diff --git a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h index 78da7b2382..7fda49fe4e 100644 --- a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h +++ b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h @@ -23,7 +23,7 @@ public: const BMutablePartition* partition); virtual status_t GetInitializationParameterEditor( const BMutablePartition* partition, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateInitialize( const BMutablePartition* partition, BString* name, const char* parameters); @@ -54,7 +54,7 @@ public: virtual status_t GetChildCreationParameterEditor( const char* type, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateCreateChild(off_t* offset, off_t* size, const char* type, BString* name, const char* parameters); diff --git a/src/add-ons/disk_systems/intel/Jamfile b/src/add-ons/disk_systems/intel/Jamfile index bf1639409c..d0d05851b4 100644 --- a/src/add-ons/disk_systems/intel/Jamfile +++ b/src/add-ons/disk_systems/intel/Jamfile @@ -16,6 +16,7 @@ Addon intel : IntelDiskSystem.cpp ExtendedPartitionAddOn.cpp PartitionMapAddOn.cpp + CreationParameterEditor.cpp # kernel sources PartitionMap.cpp diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp index cf25dd10ae..86edd76907 100644 --- a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp +++ b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp @@ -3,6 +3,7 @@ * Distributed under the terms of the MIT License. */ +#include "CreationParameterEditor.h" #include "PartitionMapAddOn.h" #include @@ -99,7 +100,7 @@ PartitionMapAddOn::CanInitialize(const BMutablePartition* partition) // GetInitializationParameterEditor status_t PartitionMapAddOn::GetInitializationParameterEditor( - const BMutablePartition* partition, BDiskDeviceParameterEditor** editor) + const BMutablePartition* partition, BPartitionParameterEditor** editor) { // Nothing to edit, really. *editor = NULL; @@ -263,58 +264,25 @@ PartitionMapHandle::GetNextSupportedType(const BMutablePartition* child, { TRACE("%p->PartitionMapHandle::GetNextSupportedType(child: %p, " "cookie: %ld)\n", this, child, *cookie); - // TODO: What are we supposed to do with the child? - // we support creating two types, primary and extended - if (*cookie < 0 || *cookie > 1) - return B_ENTRY_NOT_FOUND; - - // check if there are any spaces at all - // TODO: check if the spaces have enough size at all - BPartitioningInfo info; - status_t ret = GetPartitioningInfo(&info); - if (ret < B_OK) - return ret; - - if (info.CountPartitionableSpaces() == 0) - return B_ENTRY_NOT_FOUND; - - // adjust the cookie here already so that we don't have - // to worry about it when returning early below - *cookie = *cookie + 1; - - if (*cookie == 1) { - // On first iteration, check if we can create more primary - // partitions. If this is not possible, we cannot create - // any extended partitions either. - for (int32 i = 0; i < 4; i++) { - PrimaryPartition* primary = fPartitionMap.PrimaryPartitionAt(i); - if (primary->IsEmpty()) { - *type = kPartitionTypeIntelPrimary; - return B_OK; - } - } - } else if (*cookie == 2) { - // On second iteration, check if we can create more primary - // partitions. Also check if there already is an extended - // partition, only if there is at least one empty and no - // extended partition, we can create an extended partition. - bool foundExtended = false; - bool foundEmpty = false; - for (int32 i = 0; i < 4; i++) { - PrimaryPartition* primary = fPartitionMap.PrimaryPartitionAt(i); - if (primary->IsEmpty()) - foundEmpty = true; - else if (primary->IsExtended()) - foundExtended = true; - } - if (foundEmpty && !foundExtended) { - *type = kPartitionTypeIntelExtended; - return B_OK; - } + int32 index = *cookie; + const partition_type* nextType; + while (true) { + nextType = fPartitionMap.GetNextSupportedPartitionType(index); + if (nextType == NULL) + return B_ENTRY_NOT_FOUND; + index++; + if (nextType->used) + break; } - return B_ENTRY_NOT_FOUND; + if (!nextType) + return B_ENTRY_NOT_FOUND; + + type->SetTo(nextType->name); + *cookie = index; + + return B_OK; } @@ -347,10 +315,15 @@ PartitionMapHandle::GetPartitioningInfo(BPartitioningInfo* info) // GetChildCreationParameterEditor status_t PartitionMapHandle::GetChildCreationParameterEditor(const char* type, - BDiskDeviceParameterEditor** editor) + BPartitionParameterEditor** editor) { - // TODO: We actually need an editor here. *editor = NULL; + + try { + *editor = new PrimaryPartitionEditor(); + } catch (std::bad_alloc) { + return B_NO_MEMORY; + } return B_OK; } @@ -373,7 +346,11 @@ PartitionMapHandle::ValidateCreateChild(off_t* _offset, off_t* _size, name->Truncate(0); // check parameters - // TODO:... + void* handle = parse_driver_settings_string(parameters); + if (handle == NULL) + return B_ERROR; + + bool active = get_driver_boolean_parameter(handle, "active", false, true); // do we have a spare primary partition? if (fPartitionMap.CountNonEmptyPrimaryPartitions() == 4) @@ -481,11 +458,15 @@ PartitionMapHandle::CreateChild(off_t offset, off_t size, return B_BAD_VALUE; // check name - if (name && strlen(name) > 0) + if (name && *name != '\0') return B_BAD_VALUE; // check parameters - // TODO:... + void* handle = parse_driver_settings_string(parameters); + if (handle == NULL) + return B_ERROR; + + bool active = get_driver_boolean_parameter(handle, "active", false, true); // get a spare primary partition PrimaryPartition* primary = NULL; @@ -533,7 +514,7 @@ PartitionMapHandle::CreateChild(off_t offset, off_t size, // we picked the first empty primary partition.) BMutablePartition* partition = Partition(); BMutablePartition* child; - error = partition->CreateChild(primary->Index(), typeString, NULL, + error = partition->CreateChild(primary->Index(), typeString, name, parameters, &child); if (error != B_OK) return error; @@ -546,8 +527,6 @@ PartitionMapHandle::CreateChild(off_t offset, off_t size, child->SetChildCookie(primary); // init the primary partition - bool active = false; - // TODO: Get from parameters! primary->SetTo(offset, size, type.Type(), active, partition->BlockSize()); // TODO: If the child is an extended partition, we should trigger its diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.h b/src/add-ons/disk_systems/intel/PartitionMapAddOn.h index 3623ddd639..098849e87f 100644 --- a/src/add-ons/disk_systems/intel/PartitionMapAddOn.h +++ b/src/add-ons/disk_systems/intel/PartitionMapAddOn.h @@ -23,7 +23,7 @@ public: const BMutablePartition* partition); virtual status_t GetInitializationParameterEditor( const BMutablePartition* partition, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateInitialize( const BMutablePartition* partition, BString* name, const char* parameters); @@ -54,7 +54,7 @@ public: virtual status_t GetChildCreationParameterEditor( const char* type, - BDiskDeviceParameterEditor** editor); + BPartitionParameterEditor** editor); virtual status_t ValidateCreateChild(off_t* offset, off_t* size, const char* type, BString* name, const char* parameters); diff --git a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp index d5c025751e..e4907ee18e 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp +++ b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp @@ -43,11 +43,6 @@ using std::nothrow; -// partition_type -struct partition_type { - uint8 type; - const char *name; -}; static const char* const kUnrecognizedTypeString = "Unrecognized Type "; static const size_t kUnrecognizedTypeStringLength = 18; @@ -55,36 +50,39 @@ static const size_t kUnrecognizedTypeStringLength = 18; static const struct partition_type kPartitionTypes[] = { // these entries must be sorted by type (currently not) // TODO: Standardize naming. - { 0x00, "empty" }, - { 0x01, "FAT 12-bit" }, - { 0x02, "Xenix root" }, - { 0x03, "Xenix user" }, - { 0x04, "FAT 16-bit (dos 3.0)" }, - { 0x05, /*"Extended Partition"*/INTEL_EXTENDED_PARTITION_NAME }, - { 0x06, "FAT 16-bit (dos 3.31)" }, - { 0x07, "OS/2 IFS, Windows NT, Advanced Unix" }, - { 0x0b, "FAT 32-bit" }, - { 0x0c, "FAT 32-bit, LBA-mapped" }, - { 0x0d, "FAT 16-bit, LBA-mapped" }, - { 0x0f, /*"Extended Partition, LBA-mapped"*/INTEL_EXTENDED_PARTITION_NAME }, - { 0x42, "Windows 2000 marker (switches to a proprietary partition table)" }, - { 0x4d, "QNX 4" }, - { 0x4e, "QNX 4 2nd part" }, - { 0x4f, "QNX 4 3rd part" }, - { 0x78, "XOSL boot loader" }, - { 0x82, "Linux swapfile" }, - { 0x83, "Linux native" }, - { 0x85, /*"Linux extendend partition"*/INTEL_EXTENDED_PARTITION_NAME }, - { 0xa5, "FreeBSD" }, - { 0xa6, "OpenBSD" }, - { 0xa7, "NextSTEP" }, - { 0xa8, "MacOS X" }, - { 0xa9, "NetBSD" }, - { 0xab, "MacOS X boot" }, - { 0xaf, "MacOS X HFS" }, - { 0xbe, "Solaris 8 boot" }, - { 0xeb, /*"BeOS"*/ BFS_NAME }, - { 0, NULL } + { 0x00, "empty", true }, + { 0x01, "FAT 12-bit", false}, + { 0x02, "Xenix root", false }, + { 0x03, "Xenix user", false }, + { 0x04, "FAT 16-bit (dos 3.0)", false }, + { 0x05, /*"Extended Partition"*/INTEL_EXTENDED_PARTITION_NAME, false }, + { 0x06, "FAT 16-bit (dos 3.31)", false }, + { 0x07, "OS/2 IFS, Windows NT, Advanced Unix", true }, + { 0x0b, "FAT 32-bit", false }, + { 0x0c, "FAT 32-bit, LBA-mapped", true }, + { 0x0d, "FAT 16-bit, LBA-mapped", false }, + { 0x0f, /*"Extended Partition, LBA-mapped"*/INTEL_EXTENDED_PARTITION_NAME, + true }, + { 0x42, "Windows 2000 marker (switches to a proprietary partition table)", + false }, + { 0x4d, "QNX 4", true }, + { 0x4e, "QNX 4 2nd part", false }, + { 0x4f, "QNX 4 3rd part", false }, + { 0x78, "XOSL boot loader", false }, + { 0x82, "Linux swapfile", true }, + { 0x83, "Linux native", true }, + { 0x85, /*"Linux extendend partition"*/INTEL_EXTENDED_PARTITION_NAME, + false }, + { 0xa5, "FreeBSD", true }, + { 0xa6, "OpenBSD", true }, + { 0xa7, "NextSTEP", false }, + { 0xa8, "MacOS X", true }, + { 0xa9, "NetBSD", true }, + { 0xab, "MacOS X boot", true }, + { 0xaf, "MacOS X HFS", true }, + { 0xbe, "Solaris 8 boot", false }, + { 0xeb, /*"BeOS"*/ BFS_NAME, true }, + { 0, NULL, false } }; static const struct partition_type kPartitionContentTypes[] = { @@ -835,3 +833,12 @@ PartitionMap::Check(off_t sessionSize) const return result; } + +const partition_type* +PartitionMap::GetNextSupportedPartitionType(uint32 index) +{ + if (index > (sizeof(kPartitionTypes) / sizeof(partition_type) - 2)) + return NULL; + + return kPartitionTypes + index; +} diff --git a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h index 60bed17df6..b9c0ab67fa 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h +++ b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h @@ -14,6 +14,7 @@ // NOTE: #include +#include #ifndef _USER_MODE # include @@ -27,6 +28,14 @@ #define BFS_NAME "BFS Filesystem" +// partition_type +struct partition_type { + uint8 type; + const char *name; + bool used; +}; + + // is_empty_type static inline bool is_empty_type(uint8 type) @@ -287,6 +296,7 @@ public: const Partition* PartitionAt(int32 index) const; bool Check(off_t sessionSize) const; + const partition_type* GetNextSupportedPartitionType(uint32 cookie); private: PrimaryPartition fPrimaries[4]; diff --git a/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp b/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp index 52f86c51c7..81a78ecef1 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp +++ b/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp @@ -530,7 +530,7 @@ validate_create_child_partition(partition_data *partition, off_t *start, */ bool pm_validate_create_child(partition_data *partition, off_t *start, off_t *size, - const char *type, const char *parameters, int32 *index) + const char *type, const char *name, const char *parameters, int32 *index) { TRACE(("intel: pm_validate_create_child\n")); @@ -540,6 +540,7 @@ pm_validate_create_child(partition_data *partition, off_t *start, off_t *size, return false; } + // TODO: check name // TODO: check parameters // type check if (!is_type_valid_pm(type, partition)) @@ -1291,8 +1292,8 @@ pm_initialize(int fd, partition_id partitionID, const char *name, */ status_t pm_create_child(int fd, partition_id partitionID, off_t offset, off_t size, - const char *type, const char *parameters, disk_job_id job, - partition_id *childID) + const char *type, const char *name, const char *parameters, + disk_job_id job, partition_id *childID) { TRACE(("intel: pm_create_child\n")); @@ -1318,7 +1319,7 @@ pm_create_child(int fd, partition_id partitionID, off_t offset, off_t size, int32 index = 0; if (!pm_validate_create_child(partition, &validatedOffset, &validatedSize, - type, parameters, &index)) { + type, name, parameters, &index)) { return B_BAD_VALUE; } @@ -1338,12 +1339,26 @@ pm_create_child(int fd, partition_id partitionID, off_t offset, off_t size, PartitionType ptype; ptype.SetType(type); + // check parameters + void *handle = parse_driver_settings_string(parameters); + if (handle == NULL) + return B_ERROR; + + bool active = get_driver_boolean_parameter(handle, "active", false, true); + + // set the active flags to false + if (active) { + for (int i = 0; i < 4; i++) { + PrimaryPartition *partition = map->PrimaryPartitionAt(i); + partition->SetActive(false); + } + } + primary->SetPartitionTableOffset(0); primary->SetOffset(validatedOffset); primary->SetSize(validatedSize); primary->SetType(ptype.Type()); - // TODO: correctly fill active parameter - primary->SetActive(false); + primary->SetActive(active); // write changes to disk PartitionMapWriter writer(fd, 0, partition->size); @@ -1602,7 +1617,7 @@ ep_validate_initialize(partition_data *partition, char *name, // ep_validate_create_child bool ep_validate_create_child(partition_data *partition, off_t *_start, off_t *_size, - const char *type, const char *parameters, int32 *index) + const char *type, const char *name, const char *parameters, int32 *index) // index - returns position of the new partition (the last one) { TRACE(("intel: ep_validate_create_child\n")); @@ -2049,7 +2064,7 @@ ep_initialize(int fd, partition_id partitionID, const char *name, */ status_t ep_create_child(int fd, partition_id partitionID, off_t offset, off_t size, - const char *type, const char *parameters, disk_job_id job, + const char *type, const char *name, const char *parameters, disk_job_id job, partition_id *childID) { TRACE(("intel: ep_create_child\n")); @@ -2077,7 +2092,7 @@ ep_create_child(int fd, partition_id partitionID, off_t offset, off_t size, int32 index = 0; if (!ep_validate_create_child(partition, &validatedOffset, &validatedSize, - type, parameters, &index)) { + type, name, parameters, &index)) { return B_BAD_VALUE; } diff --git a/src/add-ons/kernel/partitioning_systems/intel/write_support.h b/src/add-ons/kernel/partitioning_systems/intel/write_support.h index 50346142f1..1c8f1fc251 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/write_support.h +++ b/src/add-ons/kernel/partitioning_systems/intel/write_support.h @@ -25,8 +25,8 @@ bool pm_validate_set_type(partition_data *partition, const char *type); bool pm_validate_initialize(partition_data *partition, char *name, const char *parameters); bool pm_validate_create_child(partition_data *partition, off_t *start, - off_t *size, const char *type, const char *parameters, - int32 *index); + off_t *size, const char *type, const char *name, + const char *parameters, int32 *index); status_t pm_get_partitionable_spaces(partition_data *partition, partitionable_space_data *buffer, int32 count, @@ -49,8 +49,9 @@ status_t pm_set_type(int fd, partition_id partitionID, const char *type, status_t pm_initialize(int fd, partition_id partitionID, const char *name, const char *parameters, off_t partitionSize, disk_job_id job); status_t pm_create_child(int fd, partition_id partitionID, off_t offset, - off_t size, const char *type, const char *parameters, - disk_job_id job, partition_id *childID); + off_t size, const char *type, const char *name, + const char *parameters, disk_job_id job, + partition_id *childID); status_t pm_delete_child(int fd, partition_id partitionID, partition_id childID, disk_job_id job); @@ -71,8 +72,8 @@ bool ep_validate_set_type(partition_data *partition, const char *type); bool ep_validate_initialize(partition_data *partition, char *name, const char *parameters); bool ep_validate_create_child(partition_data *partition, off_t *_start, - off_t *_size, const char *type, const char *parameters, - int32 *index); + off_t *_size, const char *type, const char* name, + const char *parameters, int32 *index); status_t ep_get_partitionable_spaces(partition_data *partition, partitionable_space_data *buffer, int32 count, int32 *actualCount); @@ -94,8 +95,9 @@ status_t ep_set_type(int fd, partition_id partitionID, const char *type, status_t ep_initialize(int fd, partition_id partitionID, const char *name, const char *parameters, off_t partitionSize, disk_job_id job); status_t ep_create_child(int fd, partition_id partitionID, off_t offset, - off_t size, const char *type, const char *parameters, - disk_job_id job, partition_id *childID); + off_t size, const char *type, const char *name, + const char *parameters, disk_job_id job, + partition_id *childID); status_t ep_delete_child(int fd, partition_id partitionID, partition_id childID, disk_job_id job); diff --git a/src/apps/drivesetup/CreateParamsPanel.cpp b/src/apps/drivesetup/CreateParamsPanel.cpp index ce9b8f0d41..f2c35f32c3 100644 --- a/src/apps/drivesetup/CreateParamsPanel.cpp +++ b/src/apps/drivesetup/CreateParamsPanel.cpp @@ -10,8 +10,9 @@ #include "CreateParamsPanel.h" #include "Support.h" +#include #include -#include +#include #include #include #include @@ -19,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,9 +34,11 @@ public: fPanel(target) { } + virtual ~EscapeFilter() { } + virtual filter_result Filter(BMessage* message, BHandler** target) { filter_result result = B_DISPATCH_MESSAGE; @@ -54,6 +59,7 @@ public: } return result; } + private: CreateParamsPanel* fPanel; }; @@ -64,11 +70,12 @@ private: enum { MSG_OK = 'okok', MSG_CANCEL = 'cncl', - MSG_PARTITION_TYPE = 'prty' + MSG_PARTITION_TYPE = 'type' }; -CreateParamsPanel::CreateParamsPanel(BWindow* window, off_t offset, off_t size) +CreateParamsPanel::CreateParamsPanel(BWindow* window, BPartition* partition, + off_t offset, off_t size) : BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), @@ -83,7 +90,7 @@ CreateParamsPanel::CreateParamsPanel(BWindow* window, off_t offset, off_t size) // so that we do not run over a signed int32. offset /= kMegaByte; size /= kMegaByte; - _CreateViewControls(offset, size); + _CreateViewControls(partition, offset, size); } @@ -117,6 +124,12 @@ CreateParamsPanel::MessageReceived(BMessage* message) release_sem(fExitSemaphore); break; + case MSG_PARTITION_TYPE: + const char* type; + message->FindString("type", &type); + fEditor->PartitionTypeChanged(type); + break; + default: BWindow::MessageReceived(message); } @@ -124,7 +137,8 @@ CreateParamsPanel::MessageReceived(BMessage* message) int32 -CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type) +CreateParamsPanel::Go(off_t& offset, off_t& size, BString& name, + BString& type, BString& parameters) { // run the window thread, to get an initial layout of the controls Hide(); @@ -154,16 +168,28 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type) return GO_CANCELED; if (fReturnValue == GO_SUCCESS) { + // Return the value back as bytes. + size = (off_t)fSizeSlider->Size() * kMegaByte; + offset = (off_t)fSizeSlider->Offset() * kMegaByte; + + // get name + name.SetTo(fNameTextControl->Text()); + + // get type if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) { const char* _type; BMessage* message = item->Message(); if (!message || message->FindString("type", &_type) < B_OK) - _type = "BFS Filesystem"; + _type = kPartitionTypeBFS; type << _type; } - // Return the value back as bytes. - size = (off_t)fSizeSlider->Size() * kMegaByte; - offset = (off_t)fSizeSlider->Offset() * kMegaByte; + + // get editors parameters + if (fEditor->FinishedEditing()) { + status_t status = fEditor->GetParameters(¶meters); + if (status != B_OK) + fReturnValue = status; + } } int32 value = fReturnValue; @@ -184,38 +210,59 @@ CreateParamsPanel::Cancel() void -CreateParamsPanel::_CreateViewControls(off_t offset, off_t size) +CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, + off_t size) { // Setup the controls - //TODO Add all the partition types that we want/can use - fTypePopUpMenu = new BPopUpMenu("Partition Type"); - BMessage* message = new BMessage(MSG_PARTITION_TYPE); - message->AddString("type", "BFS Filesystem"); - BMenuItem *item = new BMenuItem("BFS Filesystem", message); - fTypePopUpMenu->AddItem(item); - item->SetMarked(true); - fTypeMenuField = new BMenuField("Partition Type", fTypePopUpMenu, NULL); - fSizeSlider = new SizeSlider("Slider", "Partition Size", NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); + fNameTextControl = new BTextControl("Name Control", "Partition Name", + "", NULL); + if (!parent->SupportsChildName()) + fNameTextControl->SetEnabled(false); + + fTypePopUpMenu = new BPopUpMenu("Partition Type"); + + int32 cookie = 0; + BString supportedType; + while (parent->GetNextSupportedChildType(&cookie, &supportedType) + == B_OK) { + BMessage* message = new BMessage(MSG_PARTITION_TYPE); + message->AddString("type", supportedType); + BMenuItem* item = new BMenuItem(supportedType, message); + fTypePopUpMenu->AddItem(item); + + if (strcmp(supportedType, kPartitionTypeBFS) == 0) + item->SetMarked(true); + } + + fTypeMenuField = new BMenuField("Partition Type", fTypePopUpMenu, NULL); + fOKButton = new BButton("Create", new BMessage(MSG_OK)); fCancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL)); + BView* infoView = BGroupLayoutBuilder(B_VERTICAL, 3) + .Add(fSizeSlider) + .Add(fNameTextControl) + .Add(fTypeMenuField) + ; + BBox* infoBox = new BBox(B_FANCY_BORDER, infoView); + + parent->GetChildCreationParameterEditor(NULL, &fEditor); + BBox* parameterBox = new BBox(B_FANCY_BORDER, fEditor->View()); + BView* rootView = BGroupLayoutBuilder(B_VERTICAL, 4) + .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) + + // slider and types + .Add(infoBox) .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) - // test views - .Add(BGridLayoutBuilder(10, 10) - // row 1 - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 0, 0) - - .Add(fSizeSlider, 1, 0) - .Add(BSpaceLayoutItem::CreateVerticalStrut(5), 1, 0) - .Add(fTypeMenuField, 1, 1) - ) + // editor's view + .Add(parameterBox) // controls .AddGroup(B_HORIZONTAL, 10) diff --git a/src/apps/drivesetup/CreateParamsPanel.h b/src/apps/drivesetup/CreateParamsPanel.h index 48af7668e6..774836a215 100644 --- a/src/apps/drivesetup/CreateParamsPanel.h +++ b/src/apps/drivesetup/CreateParamsPanel.h @@ -13,6 +13,7 @@ #include #include +#include #include class BMenuField; @@ -22,28 +23,33 @@ class SizeSlider; class CreateParamsPanel : public BWindow { public: CreateParamsPanel(BWindow* window, - off_t offset, off_t size); + BPartition* parent, off_t offset, + off_t size); virtual ~CreateParamsPanel(); virtual bool QuitRequested(); virtual void MessageReceived(BMessage* message); - int32 Go(off_t& offset, off_t& size, - BString& parameters); + int32 Go(off_t& offset, off_t& size, BString& name, + BString& type, BString& parameters); void Cancel(); private: - void _CreateViewControls(off_t offset, off_t size); + void _CreateViewControls(BPartition* parent, + off_t offset, off_t size); class EscapeFilter; EscapeFilter* fEscapeFilter; sem_id fExitSemaphore; BWindow* fWindow; int32 fReturnValue; - + + BPartitionParameterEditor* fEditor; + BPopUpMenu* fTypePopUpMenu; BMenuField* fTypeMenuField; + BTextControl* fNameTextControl; SizeSlider* fSizeSlider; BButton* fOKButton; BButton* fCancelButton; diff --git a/src/apps/drivesetup/InitParamsPanel.cpp b/src/apps/drivesetup/InitParamsPanel.cpp index cfa616fe42..68a257b256 100644 --- a/src/apps/drivesetup/InitParamsPanel.cpp +++ b/src/apps/drivesetup/InitParamsPanel.cpp @@ -8,6 +8,7 @@ #include "InitParamsPanel.h" +#include #include #include @@ -31,9 +32,11 @@ public: fPanel(target) { } + virtual ~EscapeFilter() { } + virtual filter_result Filter(BMessage* message, BHandler** target) { filter_result result = B_DISPATCH_MESSAGE; @@ -54,6 +57,7 @@ public: } return result; } + private: InitParamsPanel* fPanel; }; @@ -69,7 +73,8 @@ enum { }; -InitParamsPanel::InitParamsPanel(BWindow* window) +InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem, + BPartition* partition) : BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), @@ -80,53 +85,17 @@ InitParamsPanel::InitParamsPanel(BWindow* window) { AddCommonFilter(fEscapeFilter); - fNameTC = new BTextControl("Name", NULL, NULL); - // TODO find out what is the max length for this specific FS partition name - fNameTC->TextView()->SetMaxBytes(31); - - BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize"); - BMessage* message = new BMessage(MSG_BLOCK_SIZE); - message->AddString("size", "1024"); - blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)", message)); - message = new BMessage(MSG_BLOCK_SIZE); - message->AddString("size", "2048"); - BMenuItem* defaultItem = new BMenuItem("2048 (Recommended)", message); - blocksizeMenu->AddItem(defaultItem); - message = new BMessage(MSG_BLOCK_SIZE); - message->AddString("size", "4096"); - blocksizeMenu->AddItem(new BMenuItem("4096", message)); - message = new BMessage(MSG_BLOCK_SIZE); - message->AddString("size", "8192"); - blocksizeMenu->AddItem(new BMenuItem("8192 (Mostly large files)", message)); - - fBlockSizeMF = new BMenuField("Blocksize", blocksizeMenu, NULL); - defaultItem->SetMarked(true); - BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK)); BButton* cancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL)); - BView* rootView = BGroupLayoutBuilder(B_VERTICAL, 5) + partition->GetInitializationParameterEditor(diskSystem.String(), + &fEditor); + BView* rootView = BGroupLayoutBuilder(B_VERTICAL, 5) .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) // test views - .Add(BGridLayoutBuilder(10, 10) - // row 1 - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 0, 0) - - .Add(fNameTC->CreateLabelLayoutItem(), 1, 0) - .Add(fNameTC->CreateTextViewLayoutItem(), 2, 0) - - .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 3, 0) - - // row 2 - .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1) - - .Add(fBlockSizeMF->CreateLabelLayoutItem(), 1, 1) - .Add(fBlockSizeMF->CreateMenuBarLayoutItem(), 2, 1) - - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 3, 1) - ) + .Add(fEditor->View()) // controls .AddGroup(B_HORIZONTAL, 10) @@ -144,6 +113,11 @@ InitParamsPanel::InitParamsPanel(BWindow* window) AddChild(rootView); SetDefaultButton(okButton); + // If the partition had a previous name, set to that name. + BString name = partition->ContentName(); + if (name.Length() > 0) + fEditor->PartitionNameChanged(name.String()); + AddToSubset(fWindow); } @@ -199,9 +173,6 @@ InitParamsPanel::Go(BString& name, BString& parameters) MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2.0, (parentFrame.top + parentFrame.bottom - frame.Height()) / 2.0); - fNameTC->SetText(name.String()); - fNameTC->MakeFocus(true); - Show(); Unlock(); @@ -218,15 +189,18 @@ InitParamsPanel::Go(BString& name, BString& parameters) return GO_CANCELED; if (fReturnValue == GO_SUCCESS) { - name = fNameTC->Text(); - parameters = ""; - if (BMenuItem* item = fBlockSizeMF->Menu()->FindMarked()) { - const char* size; - BMessage* message = item->Message(); - if (!message || message->FindString("size", &size) < B_OK) - size = "2048"; - // TODO: use libroot driver settings API - parameters << "block_size " << size << ";\n"; + if (fEditor->FinishedEditing()) { + status_t err = fEditor->GetParameters(¶meters); + if (err == B_OK) { + void* handle = parse_driver_settings_string( + parameters.String()); + if (handle != NULL) { + const char* string = get_driver_parameter(handle, "name", + NULL, NULL); + name.SetTo(string); + } + } else + fReturnValue = err; } } diff --git a/src/apps/drivesetup/InitParamsPanel.h b/src/apps/drivesetup/InitParamsPanel.h index 16fc12514e..9f625acdef 100644 --- a/src/apps/drivesetup/InitParamsPanel.h +++ b/src/apps/drivesetup/InitParamsPanel.h @@ -10,6 +10,8 @@ #include "Support.h" +#include +#include #include class BMenuField; @@ -18,7 +20,9 @@ class BTextControl; class InitParamsPanel : public BWindow { public: - InitParamsPanel(BWindow* window); + InitParamsPanel(BWindow* window, + const BString& diskSystem, + BPartition* partition); virtual ~InitParamsPanel(); virtual bool QuitRequested(); @@ -33,9 +37,8 @@ private: sem_id fExitSemaphore; BWindow* fWindow; int32 fReturnValue; - - BTextControl* fNameTC; - BMenuField* fBlockSizeMF; + + BPartitionParameterEditor* fEditor; }; #endif // INIT_PARAMS_PANEL_H diff --git a/src/apps/drivesetup/MainWindow.cpp b/src/apps/drivesetup/MainWindow.cpp index 29bb83ba0e..f3ae3c2c3f 100644 --- a/src/apps/drivesetup/MainWindow.cpp +++ b/src/apps/drivesetup/MainWindow.cpp @@ -168,6 +168,8 @@ MainWindow::MainWindow(BRect frame) new BMessage(MSG_SURFACE_TEST)); fRescanMI = new BMenuItem("Rescan", new BMessage(MSG_RESCAN)); + fCreateMI = new BMenuItem("Create" B_UTF8_ELLIPSIS, + new BMessage(MSG_CREATE), 'C'); fDeleteMI = new BMenuItem("Delete", new BMessage(MSG_DELETE), 'D'); fMountMI = new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M'); @@ -188,8 +190,7 @@ MainWindow::MainWindow(BRect frame) // Parition menu fPartitionMenu = new BMenu("Partition"); - fCreateMenu = new BMenu("Create"); - fPartitionMenu->AddItem(fCreateMenu); + fPartitionMenu->AddItem(fCreateMI); fInitMenu = new BMenu("Initialize"); fPartitionMenu->AddItem(fInitMenu); @@ -263,10 +264,7 @@ MainWindow::MessageReceived(BMessage* message) break; case MSG_CREATE: { - BString diskSystemName; - //if (message->FindString("disk system", &diskSystemName) != B_OK) - // break; - _Create(fCurrentDisk, fCurrentPartitionID, diskSystemName); + _Create(fCurrentDisk, fCurrentPartitionID); break; } @@ -469,10 +467,6 @@ void MainWindow::_UpdateMenus(BDiskDevice* disk, partition_id selectedPartition, partition_id parentID) { - // clean out Create and Init menu - while (BMenuItem* item = fCreateMenu->RemoveItem(0L)) - delete item; - while (BMenuItem* item = fInitMenu->RemoveItem(0L)) delete item; @@ -488,6 +482,7 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, fEjectMI->SetEnabled(disk->IsRemovableMedia()); // fSurfaceTestMI->SetEnabled(true); fSurfaceTestMI->SetEnabled(false); + fCreateMI->SetEnabled(false); // Create menu and items fPartitionMenu->SetEnabled(true); @@ -496,12 +491,14 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, if (selectedPartition <= -2) parentPartition = disk->FindDescendant(parentID); + if (parentPartition && parentPartition->ContainsPartitioningSystem()) + fCreateMI->SetEnabled(true); + BPartition* partition = disk->FindDescendant(selectedPartition); if (partition == NULL) partition = disk; bool prepared = disk->PrepareModifications() == B_OK; - fCreateMenu->SetEnabled(prepared); fInitMenu->SetEnabled(prepared); fDeleteMI->SetEnabled(prepared); @@ -532,27 +529,6 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, fInitMenu->AddItem(item); } - if (parentPartition != NULL) { - BString supportedChildType; - int32 cookie = 0; - status_t ret; - while ((ret = parentPartition->GetNextSupportedChildType(&cookie, - &supportedChildType)) == B_OK) { - BMessage* message = new BMessage(MSG_CREATE); - message->AddInt32("parent id", parentID); - message->AddInt32("space id", selectedPartition); - message->AddString("type", supportedChildType); - BMenuItem* item = new BMenuItem(supportedChildType.String(), - message); - fCreateMenu->AddItem(item); - } - if (fCreateMenu->CountItems() == 0) - fprintf(stderr, "Failed to get supported child types: %s\n", - strerror(ret)); - } else { - fCreateMenu->SetEnabled(false); - } - if (prepared) disk->CancelModifications(); @@ -804,14 +780,11 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition, return; } - // TODO: use partition initialization editor - // (partition->GetInitializationParameterEditor()) - BString name = partition->ContentName(); + BString name; BString parameters; if (diskSystemName == "Be File System") { - if (name.Length() == 0) - name = "Haiku"; - InitParamsPanel* panel = new InitParamsPanel(this); + InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName, + partition); if (panel->Go(name, parameters) == GO_CANCELED) return; } else if (diskSystemName == "Intel Partition Map") { @@ -880,8 +853,7 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition, void -MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition, - const BString& partitionType) +MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition) { if (!disk || selectedPartition > -2) { _DisplayPartitionError("The currently selected partition is not" @@ -942,12 +914,13 @@ MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition, off_t offset = currentSelection->Offset(); off_t size = currentSelection->Size(); - CreateParamsPanel* panel = new CreateParamsPanel(this, offset, size); - if (panel->Go(offset, size, type) == GO_CANCELED) + CreateParamsPanel* panel = new CreateParamsPanel(this, parent, offset, + size); + if (panel->Go(offset, size, name, type, parameters) == GO_CANCELED) return; ret = parent->ValidateCreateChild(&offset, &size, type.String(), - NULL, NULL); + &name, parameters.String()); if (ret != B_OK) { _DisplayPartitionError("Validation of the given creation " @@ -968,7 +941,7 @@ MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition, return; ret = parent->CreateChild(offset, size, type.String(), - NULL, parameters.String()); + name.String(), parameters.String()); if (ret != B_OK) { _DisplayPartitionError("Creation of the partition has failed\n"); diff --git a/src/apps/drivesetup/MainWindow.h b/src/apps/drivesetup/MainWindow.h index fc520e76cd..11c1bad119 100644 --- a/src/apps/drivesetup/MainWindow.h +++ b/src/apps/drivesetup/MainWindow.h @@ -67,8 +67,7 @@ private: partition_id selectedPartition, const BString& diskSystemName); void _Create(BDiskDevice* disk, - partition_id selectedPartition, - const BString& partitionType); + partition_id selectedPartition); void _Delete(BDiskDevice* disk, partition_id selectedPartition); @@ -85,13 +84,13 @@ private: BMenu* fDiskMenu; BMenu* fPartitionMenu; BMenu* fInitMenu; - BMenu* fCreateMenu; BMenuItem* fFormatMI; BMenuItem* fEjectMI; BMenuItem* fSurfaceTestMI; BMenuItem* fRescanMI; + BMenuItem* fCreateMI; BMenuItem* fDeleteMI; BMenuItem* fMountMI; BMenuItem* fUnmountMI; diff --git a/src/kits/storage/Jamfile b/src/kits/storage/Jamfile index 90cead866f..3fd96e4add 100644 --- a/src/kits/storage/Jamfile +++ b/src/kits/storage/Jamfile @@ -76,6 +76,7 @@ MergeObject storage_kit.o : Partition.cpp PartitionDelegate.cpp PartitioningInfo.cpp + PartitionParameterEditor.cpp PartitionReference.cpp CreateChildJob.cpp diff --git a/src/kits/storage/disk_device/DiskSystemAddOn.cpp b/src/kits/storage/disk_device/DiskSystemAddOn.cpp index 33946cdfde..89cc7ec8d0 100644 --- a/src/kits/storage/disk_device/DiskSystemAddOn.cpp +++ b/src/kits/storage/disk_device/DiskSystemAddOn.cpp @@ -52,7 +52,7 @@ BDiskSystemAddOn::CanInitialize(const BMutablePartition* partition) // GetInitializationParameterEditor status_t BDiskSystemAddOn::GetInitializationParameterEditor( - const BMutablePartition* partition, BDiskDeviceParameterEditor** editor) + const BMutablePartition* partition, BPartitionParameterEditor** editor) { return B_NOT_SUPPORTED; } @@ -297,7 +297,7 @@ BPartitionHandle::SetType(BMutablePartition* child, const char* type) // GetContentParameterEditor status_t -BPartitionHandle::GetContentParameterEditor(BDiskDeviceParameterEditor** editor) +BPartitionHandle::GetContentParameterEditor(BPartitionParameterEditor** editor) { return B_NOT_SUPPORTED; } @@ -306,7 +306,7 @@ BPartitionHandle::GetContentParameterEditor(BDiskDeviceParameterEditor** editor) // GetParameterEditor status_t BPartitionHandle::GetParameterEditor(const BMutablePartition* child, - BDiskDeviceParameterEditor** editor) + BPartitionParameterEditor** editor) { return B_NOT_SUPPORTED; } @@ -349,7 +349,7 @@ BPartitionHandle::SetParameters(BMutablePartition* child, // GetChildCreationParameterEditor status_t BPartitionHandle::GetChildCreationParameterEditor(const char* type, - BDiskDeviceParameterEditor** editor) + BPartitionParameterEditor** editor) { return B_NOT_SUPPORTED; } diff --git a/src/kits/storage/disk_device/Partition.cpp b/src/kits/storage/disk_device/Partition.cpp index c54fed92bc..37029acd03 100644 --- a/src/kits/storage/disk_device/Partition.cpp +++ b/src/kits/storage/disk_device/Partition.cpp @@ -212,6 +212,14 @@ BPartition::IsBusy() const } +// SupportsChildName +bool +BPartition::SupportsChildName() const +{ + return _SupportsChildOperation(NULL, B_DISK_SYSTEM_SUPPORTS_NAME); +} + + // Flags /*! \brief Returns the flags for this partitions. @@ -557,11 +565,11 @@ BPartition::Mount(const char* mountPoint, uint32 mountFlags, mountPoint = mountPointPath.Path(); markerPath = mountPointPath; markerPath.Append(skAutoCreatePrefix); - + // create the directory if (mkdir(mountPoint, S_IRWXU | S_IRWXG | S_IRWXO) < 0) return errno; - + if (mkdir(markerPath.Path(), S_IRWXU | S_IRWXG | S_IRWXO) < 0) { rmdir(mountPoint); return errno; @@ -1075,7 +1083,7 @@ BPartition::CanEditParameters() const // GetParameterEditor status_t -BPartition::GetParameterEditor(BDiskDeviceParameterEditor** editor) +BPartition::GetParameterEditor(BPartitionParameterEditor** editor) { BPartition* parent = Parent(); if (!parent || !fDelegate) @@ -1109,7 +1117,7 @@ BPartition::CanEditContentParameters(bool* whileMounted) const // GetContentParameterEditor status_t -BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor** editor) +BPartition::GetContentParameterEditor(BPartitionParameterEditor** editor) { if (!fDelegate) return B_NO_INIT; @@ -1131,7 +1139,7 @@ BPartition::SetContentParameters(const char* parameters) // GetNextSupportedType status_t -BPartition::GetNextSupportedType(int32 *cookie, BString* type) const +BPartition::GetNextSupportedType(int32* cookie, BString* type) const { TRACE("%p->BPartition::GetNextSupportedType(%ld)\n", this, *cookie); @@ -1149,7 +1157,7 @@ BPartition::GetNextSupportedType(int32 *cookie, BString* type) const // GetNextSupportedChildType status_t -BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const +BPartition::GetNextSupportedChildType(int32* cookie, BString* type) const { TRACE("%p->BPartition::GetNextSupportedChildType(%ld)\n", this, *cookie); @@ -1185,7 +1193,7 @@ BPartition::CanInitialize(const char* diskSystem) const // GetInitializationParameterEditor status_t BPartition::GetInitializationParameterEditor(const char* diskSystem, - BDiskDeviceParameterEditor** editor) const + BPartitionParameterEditor** editor) const { if (!fDelegate) return B_NO_INIT; @@ -1238,7 +1246,7 @@ BPartition::CanCreateChild() const // GetChildCreationParameterEditor status_t BPartition::GetChildCreationParameterEditor(const char* type, - BDiskDeviceParameterEditor** editor) const + BPartitionParameterEditor** editor) const { if (!fDelegate) return B_NO_INIT; diff --git a/src/kits/storage/disk_device/PartitionDelegate.cpp b/src/kits/storage/disk_device/PartitionDelegate.cpp index 39eea05fd9..1ab862f775 100644 --- a/src/kits/storage/disk_device/PartitionDelegate.cpp +++ b/src/kits/storage/disk_device/PartitionDelegate.cpp @@ -339,7 +339,7 @@ BPartition::Delegate::SetType(Delegate* child, const char* type) // GetContentParameterEditor status_t BPartition::Delegate::GetContentParameterEditor( - BDiskDeviceParameterEditor** editor) const + BPartitionParameterEditor** editor) const { if (!fPartitionHandle) return B_NO_INIT; @@ -351,7 +351,7 @@ BPartition::Delegate::GetContentParameterEditor( // GetParameterEditor status_t BPartition::Delegate::GetParameterEditor(Delegate* child, - BDiskDeviceParameterEditor** editor) const + BPartitionParameterEditor** editor) const { if (!fPartitionHandle || !child) return B_NO_INIT; @@ -443,7 +443,7 @@ BPartition::Delegate::CanInitialize(const char* diskSystem) const // GetInitializationParameterEditor status_t BPartition::Delegate::GetInitializationParameterEditor( - const char* diskSystem, BDiskDeviceParameterEditor** editor) const + const char* diskSystem, BPartitionParameterEditor** editor) const { // get the disk system add-on DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default(); @@ -540,7 +540,7 @@ BPartition::Delegate::GetPartitioningInfo(BPartitioningInfo* info) // GetChildCreationParameterEditor status_t BPartition::Delegate::GetChildCreationParameterEditor(const char* type, - BDiskDeviceParameterEditor** editor) const + BPartitionParameterEditor** editor) const { if (!fPartitionHandle) return B_NO_INIT; diff --git a/src/kits/storage/disk_device/PartitionDelegate.h b/src/kits/storage/disk_device/PartitionDelegate.h index a5b5ed2414..92fba1166b 100644 --- a/src/kits/storage/disk_device/PartitionDelegate.h +++ b/src/kits/storage/disk_device/PartitionDelegate.h @@ -67,9 +67,9 @@ public: status_t SetType(Delegate* child, const char* type); status_t GetContentParameterEditor( - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t GetParameterEditor(Delegate* child, - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t SetContentParameters(const char* parameters); status_t SetParameters(Delegate* child, const char* parameters); @@ -82,7 +82,7 @@ public: bool CanInitialize(const char* diskSystem) const; status_t GetInitializationParameterEditor( const char* system, - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t ValidateInitialize(const char* diskSystem, BString* name, const char* parameters); status_t Initialize(const char* diskSystem, @@ -96,7 +96,7 @@ public: status_t GetChildCreationParameterEditor( const char* system, - BDiskDeviceParameterEditor** editor) const; + BPartitionParameterEditor** editor) const; status_t ValidateCreateChild(off_t* start, off_t* size, const char* type, BString* name, const char* parameters) const; diff --git a/src/kits/storage/disk_device/PartitionParameterEditor.cpp b/src/kits/storage/disk_device/PartitionParameterEditor.cpp new file mode 100644 index 0000000000..abd7591c34 --- /dev/null +++ b/src/kits/storage/disk_device/PartitionParameterEditor.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2009, Bryce Groff, brycegroff@gmail.com. + * Distributed under the terms of the MIT License. + */ + +#include + +#include +#include + + +BPartitionParameterEditor::BPartitionParameterEditor() +{ +} + + +BPartitionParameterEditor::~BPartitionParameterEditor() +{ +} + + +/*! \brief Returns a view containing the controls needed for editing the + parameters. + + To be overridden by derived classes. + The base class version returns \c NULL. + + The returned BView is added to a window occasionally and removed, when + editing is done. The view belongs to the editor and needs to be deleted + by it. Subsequent calls to this method may return the same view, or each + time delete the old one and return a new one. + + \return A view containing the controls needed for editing the parameters. + \c NULL can be returned, if no parameters are needed. +*/ +BView* +BPartitionParameterEditor::View() +{ + return NULL; +} + + +// FinishedEditing +/*! \brief Called when the user finishes editing the parameters. + + To be overridden by derived classes. + The base class version returns \c true. + + The method is supposed to check whether the parameters the user set, + are valid, and, if so, return \c true. Otherwise return \c false. + + \return \c true, if the current parameters are valid, \c false otherwise. +*/ +bool +BPartitionParameterEditor::FinishedEditing() +{ + return true; +} + + +/*! \brief Returns the edited parameters. + + To be overridden by derived classes. + The base class version returns an empty string. + + \param parameters A BString to be set to the edited parameters. + + \return \c B_OK, if everything went fine, another error code otherwise. +*/ +status_t +BPartitionParameterEditor::GetParameters(BString* parameters) +{ + status_t error = (parameters ? B_OK : B_BAD_VALUE); + if (error == B_OK) + parameters->SetTo(""); + return error; +} + + +/*! \brief Called when type information has changed. + + To be overridden by derived classes. + The base class version returns B_OK. + + \param type A string that is the new type. + + \return \c B_OK, if everything went fine, another error code otherwise. +*/ +status_t +BPartitionParameterEditor::PartitionTypeChanged(const char* type) +{ + return B_OK; +} + + +/*! \brief Called when name information has changed. + + To be overridden by derived classes. + The base class version returns B_OK. + + \param name A string that is the new name. + + \return \c B_OK, if everything went fine, another error code otherwise. +*/ +status_t +BPartitionParameterEditor::PartitionNameChanged(const char* name) +{ + return B_OK; +} diff --git a/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp b/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp index a7c90c9f65..20ac4a797d 100644 --- a/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp +++ b/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp @@ -434,8 +434,7 @@ KPartitioningSystem::CreateChild(KPartition* partition, off_t offset, // let the module do its job result = fModule->create_child(fd, partition->ID(), offset, size, - type, parameters, job, &childID); -// TODO: Added name parameter to create_child() hook. + type, name, parameters, job, &childID); // find and return the child *child = KDiskDeviceManager::Default()->FindPartition(childID);