From f37941569751e0c57554ccd1776816e46898d791 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 8 Jul 2009 01:32:09 +0000 Subject: [PATCH] Partition type strings that we hand out we should also be able to handle. I.e. we need to parse the "Unrecognized Type ..." strings we produce for partition type IDs we can't match to a name. This fixes the "Failed to prepare modifications" error the userland tools would produce when a partition with such a type was encountered. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31453 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../partitioning_systems/intel/PartitionMap.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp index 749eab2fc0..d5c025751e 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp +++ b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp @@ -49,6 +49,9 @@ struct partition_type { const char *name; }; +static const char* const kUnrecognizedTypeString = "Unrecognized Type "; +static const size_t kUnrecognizedTypeStringLength = 18; + static const struct partition_type kPartitionTypes[] = { // these entries must be sorted by type (currently not) // TODO: Standardize naming. @@ -120,7 +123,7 @@ get_partition_type_string(uint8 type, char* buffer) if (const char* typeString = partition_type_string(type)) strcpy(buffer, typeString); else - sprintf(buffer, "Unrecognized Type 0x%x", type); + sprintf(buffer, "%s0x%x", kUnrecognizedTypeString, type); } } @@ -215,6 +218,18 @@ PartitionType::SetType(const char *typeName) return fValid; } } + + // If this is an unrecognized type, parse the type number. + if (strncmp(typeName, kUnrecognizedTypeString, + kUnrecognizedTypeStringLength) == 0) { + long type = strtol(typeName + kUnrecognizedTypeStringLength, NULL, 0); + if (type != 0 && type <= 255) { + fType = type; + fValid = true; + return fValid; + } + } + fValid = false; return fValid; }