Now the partition type string is set to `Unrecognized Type 0xXY', if the type is unknown. If the PTS for an extended partition could not be read, it is ignored.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2610 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -153,6 +153,7 @@ PartitionMapParser::_ParseExtended(PrimaryPartition *primary, off_t offset)
|
||||
status_t error = B_OK;
|
||||
int32 partitionCount = 0;
|
||||
while (error == B_OK) {
|
||||
// check for cycles
|
||||
if (++partitionCount > kMaxLogicalPartitionCount) {
|
||||
TRACE(("intel: _ParseExtended(): Maximal number of logical "
|
||||
"partitions for extended partition reached. Cycle?\n"));
|
||||
@@ -162,10 +163,17 @@ PartitionMapParser::_ParseExtended(PrimaryPartition *primary, off_t offset)
|
||||
if (error == B_OK)
|
||||
error = _ReadPTS(offset);
|
||||
// check the signature
|
||||
if (error == B_OK && fPTS->signature != kPartitionTableSectorSignature) {
|
||||
if (error == B_OK
|
||||
&& fPTS->signature != kPartitionTableSectorSignature) {
|
||||
TRACE(("intel: _ParseExtended(): invalid PTS signature\n"));
|
||||
error = B_BAD_DATA;
|
||||
}
|
||||
// ignore the PTS, if any error occured till now
|
||||
if (error != B_OK) {
|
||||
TRACE(("intel: _ParseExtended(): ignoring this PTS\n"));
|
||||
error = B_OK;
|
||||
break;
|
||||
}
|
||||
// examine the table
|
||||
LogicalPartition extended;
|
||||
LogicalPartition nonExtended;
|
||||
@@ -333,8 +341,7 @@ intel_get_nth_info(int deviceFD, const session_info *sessionInfo,
|
||||
partitionInfo->flags = 0;
|
||||
}
|
||||
partitionInfo->partition_name[0] = '\0';
|
||||
strcpy(partitionInfo->partition_type,
|
||||
partition->TypeString());
|
||||
partition->GetTypeString(partitionInfo->partition_type);
|
||||
partitionInfo->partition_code = partition->Type();
|
||||
} else
|
||||
error = B_ENTRY_NOT_FOUND;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <new.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -58,6 +59,7 @@ static const struct partition_type kPartitionTypes[] = {
|
||||
};
|
||||
|
||||
// partition_type_string
|
||||
static
|
||||
const char *
|
||||
partition_type_string(uint8 type)
|
||||
{
|
||||
@@ -67,7 +69,19 @@ partition_type_string(uint8 type)
|
||||
if (type == kPartitionTypes[i].type)
|
||||
return kPartitionTypes[i].name;
|
||||
}
|
||||
return "unknown";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get_partition_type_string
|
||||
void
|
||||
get_partition_type_string(uint8 type, char *buffer)
|
||||
{
|
||||
if (buffer) {
|
||||
if (const char *str = partition_type_string(type))
|
||||
strcpy(buffer, str);
|
||||
else
|
||||
sprintf(buffer, "Unrecognized Type 0x%x", type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ is_extended_type(uint8 type)
|
||||
return (type == 0x05 || type == 0x0f || type == 0x85);
|
||||
}
|
||||
|
||||
const char *partition_type_string(uint8 type);
|
||||
void get_partition_type_string(uint8 type, char *buffer);
|
||||
|
||||
// chs
|
||||
struct chs {
|
||||
@@ -82,7 +82,8 @@ public:
|
||||
off_t Size() const { return fSize; }
|
||||
uint8 Type() const { return fType; }
|
||||
bool Active() const { return fActive; }
|
||||
const char *TypeString() const { return partition_type_string(fType); }
|
||||
void GetTypeString(char *buffer) const
|
||||
{ get_partition_type_string(fType, buffer); }
|
||||
|
||||
void SetPTSOffset(off_t offset) { fPTSOffset = offset; }
|
||||
void SetOffset(off_t offset) { fOffset = offset; }
|
||||
|
||||
Reference in New Issue
Block a user