diff --git a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp index a25ddc3a56..6302c90590 100644 --- a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp +++ b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -100,6 +101,7 @@ GPTPartitionHandle::SupportedChildOperations(const BMutablePartition* child, | B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD | B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD | B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE + | B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS | B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD; } @@ -112,7 +114,7 @@ GPTPartitionHandle::GetNextSupportedType(const BMutablePartition* child, TRACE("GPTPartitionHandle::GetNextSupportedType(child: %p, cookie: %" B_PRId32 ")\n", child, index); - if (index >= int32(sizeof(kTypeMap) / sizeof(kTypeMap[0]))) + if (index >= int32(B_COUNT_OF(kTypeMap))) return B_ENTRY_NOT_FOUND; type->SetTo(kTypeMap[index].type); @@ -152,7 +154,7 @@ GPTPartitionHandle::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, BPartitionParameterEditor** editor) { *editor = NULL; - if (type == B_CREATE_PARAMETER_EDITOR) { + if (type == B_CREATE_PARAMETER_EDITOR || type == B_PROPERTIES_PARAMETER_EDITOR) { try { *editor = new BPartitionParameterEditor(); } catch (std::bad_alloc&) { @@ -195,6 +197,25 @@ GPTPartitionHandle::SetName(BMutablePartition* child, const char* name) } +status_t +GPTPartitionHandle::ValidateSetType(const BMutablePartition* child, + const char* type) +{ + for (size_t i = 0; i < B_COUNT_OF(kTypeMap); i++) { + if (strcmp(type, kTypeMap[i].type) == 0) + return B_OK; + } + return B_BAD_VALUE; +} + + +status_t +GPTPartitionHandle::SetType(BMutablePartition* child, const char* type) +{ + return child->SetType(type); +} + + status_t GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size, const char* typeString, BString* name, const char* parameters) diff --git a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.h b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.h index f99c3e95ad..434e597877 100644 --- a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.h +++ b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.h @@ -26,6 +26,9 @@ public: BString* name); virtual status_t SetName(BMutablePartition* child, const char* name); + virtual status_t ValidateSetType(const BMutablePartition* child, + const char* type); + virtual status_t SetType(BMutablePartition* child, const char* type); virtual status_t GetNextSupportedType( const BMutablePartition* child,