Added a new PartitionMap::CountNonEmptyPartitions() - now, a partition map
is only accepted when there is at least one valid partition in it. Before, the module would accept even the BFS boot loader which is now less likely (IOW you can now boot with Bochs again). Also, if there was one invalid partition, the partitions that come after it are no longer ignored. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12228 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
597c7235b9
commit
311049d751
|
@ -327,6 +327,19 @@ PartitionMap::CountPartitions() const
|
|||
return count;
|
||||
}
|
||||
|
||||
// CountNonEmptyPartitions
|
||||
int32
|
||||
PartitionMap::CountNonEmptyPartitions() const
|
||||
{
|
||||
int32 count = 0;
|
||||
for (int32 i = CountPartitions() - 1; i >= 0; i--) {
|
||||
if (!PartitionAt(i)->IsEmpty())
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// PartitionAt
|
||||
Partition *
|
||||
PartitionMap::PartitionAt(int32 index)
|
||||
|
|
|
@ -164,6 +164,7 @@ public:
|
|||
const PrimaryPartition *PrimaryPartitionAt(int32 index) const;
|
||||
|
||||
int32 CountPartitions() const;
|
||||
int32 CountNonEmptyPartitions() const;
|
||||
Partition *PartitionAt(int32 index);
|
||||
const Partition *PartitionAt(int32 index) const;
|
||||
|
||||
|
|
|
@ -53,8 +53,14 @@ PartitionMapParser::Parse(const uint8 *block, PartitionMap *map)
|
|||
if (error == B_OK)
|
||||
error = _ParsePrimary(&pts);
|
||||
}
|
||||
if (error == B_OK && !fMap->Check(fSessionSize, fBlockSize))
|
||||
|
||||
// If we don't have any partitions it might also just be an
|
||||
// empty partition map, but we still can't do much with it
|
||||
if (error == B_OK
|
||||
&& (fMap->CountNonEmptyPartitions() == 0
|
||||
|| !fMap->Check(fSessionSize, fBlockSize))) {
|
||||
error = B_BAD_DATA;
|
||||
}
|
||||
fMap = NULL;
|
||||
}
|
||||
return error;
|
||||
|
@ -81,7 +87,6 @@ PartitionMapParser::_ParsePrimary(const partition_table_sector *pts)
|
|||
TRACE(("intel: _ParsePrimary(): partition %ld: bad location, "
|
||||
"ignoring\n"));
|
||||
partition->Unset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue