gpt: let the type be changed
Change-Id: I1c049c28b416d13b679aa32eb8cbc41a3273a05d Reviewed-on: https://review.haiku-os.org/c/haiku/+/5657 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
6b7504173c
commit
6b3e198d41
@@ -15,6 +15,7 @@
|
|||||||
#include <PartitioningInfo.h>
|
#include <PartitioningInfo.h>
|
||||||
#include <PartitionParameterEditor.h>
|
#include <PartitionParameterEditor.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ GPTPartitionHandle::SupportedChildOperations(const BMutablePartition* child,
|
|||||||
| B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD
|
| B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD
|
||||||
| B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD
|
| B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD
|
||||||
| B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE
|
| B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE
|
||||||
|
| B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS
|
||||||
| B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD;
|
| B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +114,7 @@ GPTPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
|
|||||||
TRACE("GPTPartitionHandle::GetNextSupportedType(child: %p, cookie: %" B_PRId32 ")\n",
|
TRACE("GPTPartitionHandle::GetNextSupportedType(child: %p, cookie: %" B_PRId32 ")\n",
|
||||||
child, index);
|
child, index);
|
||||||
|
|
||||||
if (index >= int32(sizeof(kTypeMap) / sizeof(kTypeMap[0])))
|
if (index >= int32(B_COUNT_OF(kTypeMap)))
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
type->SetTo(kTypeMap[index].type);
|
type->SetTo(kTypeMap[index].type);
|
||||||
@@ -152,7 +154,7 @@ GPTPartitionHandle::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type,
|
|||||||
BPartitionParameterEditor** editor)
|
BPartitionParameterEditor** editor)
|
||||||
{
|
{
|
||||||
*editor = NULL;
|
*editor = NULL;
|
||||||
if (type == B_CREATE_PARAMETER_EDITOR) {
|
if (type == B_CREATE_PARAMETER_EDITOR || type == B_PROPERTIES_PARAMETER_EDITOR) {
|
||||||
try {
|
try {
|
||||||
*editor = new BPartitionParameterEditor();
|
*editor = new BPartitionParameterEditor();
|
||||||
} catch (std::bad_alloc&) {
|
} 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
|
status_t
|
||||||
GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size,
|
GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size,
|
||||||
const char* typeString, BString* name, const char* parameters)
|
const char* typeString, BString* name, const char* parameters)
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ public:
|
|||||||
BString* name);
|
BString* name);
|
||||||
virtual status_t SetName(BMutablePartition* child,
|
virtual status_t SetName(BMutablePartition* child,
|
||||||
const char* name);
|
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(
|
virtual status_t GetNextSupportedType(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
|
|||||||
Reference in New Issue
Block a user