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:
Ingo Weinhold
2003-01-31 21:21:57 +00:00
parent d713d1d973
commit b39b76027e
3 changed files with 28 additions and 6 deletions
@@ -153,6 +153,7 @@ PartitionMapParser::_ParseExtended(PrimaryPartition *primary, off_t offset)
status_t error = B_OK; status_t error = B_OK;
int32 partitionCount = 0; int32 partitionCount = 0;
while (error == B_OK) { while (error == B_OK) {
// check for cycles
if (++partitionCount > kMaxLogicalPartitionCount) { if (++partitionCount > kMaxLogicalPartitionCount) {
TRACE(("intel: _ParseExtended(): Maximal number of logical " TRACE(("intel: _ParseExtended(): Maximal number of logical "
"partitions for extended partition reached. Cycle?\n")); "partitions for extended partition reached. Cycle?\n"));
@@ -162,10 +163,17 @@ PartitionMapParser::_ParseExtended(PrimaryPartition *primary, off_t offset)
if (error == B_OK) if (error == B_OK)
error = _ReadPTS(offset); error = _ReadPTS(offset);
// check the signature // check the signature
if (error == B_OK && fPTS->signature != kPartitionTableSectorSignature) { if (error == B_OK
&& fPTS->signature != kPartitionTableSectorSignature) {
TRACE(("intel: _ParseExtended(): invalid PTS signature\n")); TRACE(("intel: _ParseExtended(): invalid PTS signature\n"));
error = B_BAD_DATA; 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 // examine the table
LogicalPartition extended; LogicalPartition extended;
LogicalPartition nonExtended; LogicalPartition nonExtended;
@@ -333,8 +341,7 @@ intel_get_nth_info(int deviceFD, const session_info *sessionInfo,
partitionInfo->flags = 0; partitionInfo->flags = 0;
} }
partitionInfo->partition_name[0] = '\0'; partitionInfo->partition_name[0] = '\0';
strcpy(partitionInfo->partition_type, partition->GetTypeString(partitionInfo->partition_type);
partition->TypeString());
partitionInfo->partition_code = partition->Type(); partitionInfo->partition_code = partition->Type();
} else } else
error = B_ENTRY_NOT_FOUND; error = B_ENTRY_NOT_FOUND;
@@ -9,6 +9,7 @@
*/ */
#include <new.h> #include <new.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -58,6 +59,7 @@ static const struct partition_type kPartitionTypes[] = {
}; };
// partition_type_string // partition_type_string
static
const char * const char *
partition_type_string(uint8 type) partition_type_string(uint8 type)
{ {
@@ -67,7 +69,19 @@ partition_type_string(uint8 type)
if (type == kPartitionTypes[i].type) if (type == kPartitionTypes[i].type)
return kPartitionTypes[i].name; 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); return (type == 0x05 || type == 0x0f || type == 0x85);
} }
const char *partition_type_string(uint8 type); void get_partition_type_string(uint8 type, char *buffer);
// chs // chs
struct chs { struct chs {
@@ -82,7 +82,8 @@ public:
off_t Size() const { return fSize; } off_t Size() const { return fSize; }
uint8 Type() const { return fType; } uint8 Type() const { return fType; }
bool Active() const { return fActive; } 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 SetPTSOffset(off_t offset) { fPTSOffset = offset; }
void SetOffset(off_t offset) { fOffset = offset; } void SetOffset(off_t offset) { fOffset = offset; }