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
This commit is contained in:
parent
f612278f55
commit
f379415697
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user