Skip to content

Commit f1587b5

Browse files
author
Nir Sonnenschein
authored
Merge pull request #8262 from juhoeskeli/mbrblockdevice_align
Align MBRBlockDevice writes to underlying BlockDevice write size
2 parents b1b6399 + d32b454 commit f1587b5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

features/storage/blockdevice/MBRBlockDevice.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ static int partition_absolute(
7373
{
7474
// Allocate smallest buffer necessary to write MBR
7575
uint32_t buffer_size = std::max<uint32_t>(bd->get_program_size(), sizeof(struct mbr_table));
76+
77+
// Prevent alignment issues
78+
if(buffer_size % bd->get_program_size() != 0) {
79+
buffer_size += bd->get_program_size() - (buffer_size % bd->get_program_size());
80+
}
81+
7682
uint8_t *buffer = new uint8_t[buffer_size];
7783

7884
// Check for existing MBR

0 commit comments

Comments
 (0)