gpt: Always use at least 4K to align partitions.

* Many of today's disks that use 4K internally don't advertize this.
This commit is contained in:
Axel Dörfler
2013-01-28 22:51:53 +01:00
parent 9e8f937437
commit 7775bfeb6b
@@ -42,12 +42,13 @@
static off_t static off_t
block_align(partition_data* partition, off_t offset, bool upwards) block_align(partition_data* partition, off_t offset, bool upwards)
{ {
if (upwards) { // Take HDs into account that hide the fact they are using a
return ((offset + partition->block_size - 1) / partition->block_size) // block size of 4096 bytes, and round to that.
* partition->block_size; 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 #endif // !_BOOT_MODE