* Apparently, a drive's size is not always reported the same; at least I have

a drive (which had its MBR created on Linux) report a smaller size than the
  size of its first partition.
* Since other operating systems seem to ignore this, we now relax our validity
  checks and always adjust the size of a child partition to fit into its parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34381 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-11-30 15:56:37 +00:00
parent beef46972c
commit a0973602c3
4 changed files with 20 additions and 35 deletions

View File

@ -11,18 +11,3 @@ KernelAddon intel :
PartitionMapWriter.cpp
write_support.cpp
;
# Also build a userland version
# ToDo: it's probably not a good idea to build them into the same directory
#Addon <partitioning_system>intel :
# intel.cpp
# PartitionLocker.cpp
# PartitionMap.cpp
# PartitionMapParser.cpp
# PartitionMapWriter.cpp
#;
#LinkAgainst <partitioning_system>intel :
# libkernelland_emu.so
# libdisk_device_manager.so
#;

View File

@ -6,11 +6,13 @@
* Ingo Weinhold, bonefish@cs.tu-berlin.de
*/
/*! \file PartitionMap.cpp
\brief Definitions for "intel" style partitions and implementation
of related classes.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -356,19 +358,6 @@ Partition::Unset()
}
#ifdef _BOOT_MODE
void
Partition::AdjustSize(off_t sessionSize)
{
// To work around buggy (or older) BIOS, we shrink the partition size to
// always fit into its session - this should improve detection of boot
// partitions (see bug #238 for more information)
if (sessionSize < fOffset + fSize && sessionSize > fOffset)
fSize = sessionSize - fOffset;
}
#endif
bool
Partition::CheckLocation(off_t sessionSize) const
{
@ -410,6 +399,20 @@ Partition::CheckLocation(off_t sessionSize) const
}
void
Partition::FitSizeToSession(off_t sessionSize)
{
// To work around buggy (or older) BIOS, we shrink the partition size to
// always fit into its session - this should improve detection of boot
// partitions (see bug #238 for more information).
// Also, the drive size is obviously reported differently sometimes; this
// should let us read problematic drives - let the file system figure out
// if something is wrong.
if (sessionSize < fOffset + fSize && sessionSize > fOffset)
fSize = sessionSize - fOffset;
}
// #pragma mark - PrimaryPartition

View File

@ -182,9 +182,7 @@ public:
{ fBlockSize = blockSize; }
bool CheckLocation(off_t sessionSize) const;
#ifdef _BOOT_MODE
void AdjustSize(off_t sessionSize);
#endif
void FitSizeToSession(off_t sessionSize);
private:
off_t fPartitionTableOffset;

View File

@ -110,10 +110,9 @@ PartitionMapParser::_ParsePrimary(const partition_table* table)
PrimaryPartition* partition = fMap->PrimaryPartitionAt(i);
partition->SetTo(descriptor, 0, fBlockSize);
#ifdef _BOOT_MODE
// work-around potential BIOS problems
partition->AdjustSize(fSessionSize);
#endif
// work-around potential BIOS/OS problems
partition->FitSizeToSession(fSessionSize);
// ignore, if location is bad
if (!partition->CheckLocation(fSessionSize)) {
TRACE(("intel: _ParsePrimary(): partition %ld: bad location, "