Merge pull request #8262 from juhoeskeli/mbrblockdevice_align

Align MBRBlockDevice writes to underlying BlockDevice write size
pull/8280/head
Nir Sonnenschein 2018-09-28 13:23:55 +03:00 committed by GitHub
commit f1587b50d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -73,6 +73,12 @@ static int partition_absolute(
{
// Allocate smallest buffer necessary to write MBR
uint32_t buffer_size = std::max<uint32_t>(bd->get_program_size(), sizeof(struct mbr_table));
// Prevent alignment issues
if(buffer_size % bd->get_program_size() != 0) {
buffer_size += bd->get_program_size() - (buffer_size % bd->get_program_size());
}
uint8_t *buffer = new uint8_t[buffer_size];
// Check for existing MBR