Skip to content

Commit

Permalink
gpt: Always use at least 4K to align partitions.
Browse files Browse the repository at this point in the history
* Many of today's disks that use 4K internally don't advertize this.
  • Loading branch information
axeld committed Jan 28, 2013
1 parent 9e8f937 commit 7775bfe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
Expand Up @@ -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

Expand Down

0 comments on commit 7775bfe

Please sign in to comment.