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:47:30 +01:00
parent 9e8f937437
commit 7775bfeb6b
1 changed files with 6 additions and 5 deletions

View File

@ -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