From 5f1b31debdf97da331be6e97a6c2bc5899e2423a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 14 Apr 2009 14:46:26 +0000 Subject: [PATCH] * Made the intel disk_systems add-on independent from the block size as well. * This also fixes the build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30157 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../intel/ExtendedPartitionAddOn.cpp | 10 +++--- .../disk_systems/intel/IntelDiskSystem.h | 4 +-- .../disk_systems/intel/PartitionMapAddOn.cpp | 31 ++++++++++--------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp index e33dc7214a..10bf29cbb9 100644 --- a/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp +++ b/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp @@ -15,6 +15,8 @@ #include +#include "IntelDiskSystem.h" + using std::nothrow; @@ -83,7 +85,7 @@ bool ExtendedPartitionAddOn::CanInitialize(const BMutablePartition* partition) { // If it's big enough, we can initialize it. - return partition->Size() >= 2 * SECTOR_SIZE; + return partition->Size() >= 2 * partition->BlockSize(); } @@ -138,12 +140,12 @@ ExtendedPartitionAddOn::Initialize(BMutablePartition* partition, status_t error = partition->SetContentType(Name()); if (error != B_OK) return error; -// TODO: The content type could as well be set by the caller. + // TODO: The content type could as well be set by the caller. partition->SetContentName(NULL); partition->SetContentParameters(NULL); - partition->SetBlockSize(SECTOR_SIZE); - partition->SetContentSize(partition->Size() / SECTOR_SIZE * SECTOR_SIZE); + partition->SetContentSize( + sector_align(partition->Size(), partition->BlockSize())); *_handle = handleDeleter.Detach(); diff --git a/src/add-ons/disk_systems/intel/IntelDiskSystem.h b/src/add-ons/disk_systems/intel/IntelDiskSystem.h index 6aed0842e1..4732eeaa16 100644 --- a/src/add-ons/disk_systems/intel/IntelDiskSystem.h +++ b/src/add-ons/disk_systems/intel/IntelDiskSystem.h @@ -9,9 +9,9 @@ static inline off_t -sector_align(off_t offset) +sector_align(off_t offset, uint32 blockSize) { - return offset / SECTOR_SIZE * SECTOR_SIZE; + return offset / blockSize * blockSize; } diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp index 295e18363d..637444c8e1 100644 --- a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp +++ b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp @@ -19,7 +19,7 @@ using std::nothrow; -static const uint32 kDiskSystemFlags = +static const uint32 kDiskSystemFlags = 0 // | B_DISK_SYSTEM_SUPPORTS_CHECKING // | B_DISK_SYSTEM_SUPPORTS_REPAIRING @@ -82,7 +82,7 @@ bool PartitionMapAddOn::CanInitialize(const BMutablePartition* partition) { // If it's big enough, we can initialize it. - return partition->Size() >= 2 * SECTOR_SIZE; + return partition->Size() >= 2 * partition->BlockSize(); } @@ -136,12 +136,12 @@ PartitionMapAddOn::Initialize(BMutablePartition* partition, const char* name, status_t error = partition->SetContentType(Name()); if (error != B_OK) return error; -// TODO: The content type could as well be set by the caller. + // TODO: The content type could as well be set by the caller. partition->SetContentName(NULL); partition->SetContentParameters(NULL); - partition->SetBlockSize(SECTOR_SIZE); - partition->SetContentSize(partition->Size() / SECTOR_SIZE * SECTOR_SIZE); + partition->SetContentSize( + sector_align(partition->Size(), partition->BlockSize())); *_handle = handleDeleter.Detach(); @@ -196,7 +196,8 @@ PartitionMapHandle::Init() bool active = false; PrimaryPartition* primary = fPartitionMap.PrimaryPartitionAt(index); - primary->SetTo(child->Offset(), child->Size(), type.Type(), active); + primary->SetTo(child->Offset(), child->Size(), type.Type(), active, + partition->BlockSize()); child->SetChildCookie(primary); } @@ -311,7 +312,8 @@ PartitionMapHandle::GetPartitioningInfo(BPartitioningInfo* info) { // init to the full size (minus the first sector) off_t size = Partition()->ContentSize(); - status_t error = info->SetTo(SECTOR_SIZE, size - SECTOR_SIZE); + status_t error = info->SetTo(Partition()->BlockSize(), + size - Partition()->BlockSize()); if (error != B_OK) return error; @@ -376,8 +378,8 @@ PartitionMapHandle::ValidateCreateChild(off_t* _offset, off_t* _size, return B_BAD_VALUE; // check offset and size - off_t offset = sector_align(*_offset); - off_t size = sector_align(*_size); + off_t offset = sector_align(*_offset, Partition()->BlockSize()); + off_t size = sector_align(*_size, Partition()->BlockSize()); // TODO: Rather round size up? off_t end = offset + size; @@ -484,7 +486,8 @@ PartitionMapHandle::CreateChild(off_t offset, off_t size, return B_BAD_VALUE; // offset properly aligned? - if (offset != sector_align(offset) || size != sector_align(size)) + if (offset != sector_align(offset, Partition()->BlockSize()) + || size != sector_align(size, Partition()->BlockSize())) return B_BAD_VALUE; // check the free space situation @@ -525,17 +528,17 @@ PartitionMapHandle::CreateChild(off_t offset, off_t size, // init the child child->SetOffset(offset); child->SetSize(size); - child->SetBlockSize(SECTOR_SIZE); + child->SetBlockSize(partition->BlockSize()); //child->SetFlags(0); child->SetChildCookie(primary); // init the primary partition bool active = false; // TODO: Get from parameters! - primary->SetTo(offset, size, type.Type(), active); + primary->SetTo(offset, size, type.Type(), active, partition->BlockSize()); -// TODO: If the child is an extended partition, we should trigger its -// initialization. + // TODO: If the child is an extended partition, we should trigger its + // initialization. *_child = child; return B_OK;