From 7775bfeb6bb0d4b71d9436a6e33e112d53878ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 28 Jan 2013 22:47:30 +0100 Subject: [PATCH] gpt: Always use at least 4K to align partitions. * Many of today's disks that use 4K internally don't advertize this. --- .../kernel/partitioning_systems/gpt/efi_gpt.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp index 248de689e8..7b87a291a0 100644 --- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp +++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp @@ -42,12 +42,13 @@ static off_t block_align(partition_data* partition, off_t offset, bool upwards) { - if (upwards) { - return ((offset + partition->block_size - 1) / partition->block_size) - * partition->block_size; - } + // Take HDs into account that hide the fact they are using a + // block size of 4096 bytes, and round to that. + uint32 blockSize = max_c(partition->block_size, 4096); + if (upwards) + return ((offset + blockSize - 1) / blockSize) * blockSize; - return (offset / partition->block_size) * partition->block_size; + return (offset / blockSize) * blockSize; } #endif // !_BOOT_MODE