Skip to content

Commit

Permalink
cmd: gpt: backup boot code before writing MBR
Browse files Browse the repository at this point in the history
On some cases the first 440 bytes of MBR are used to keep an additional
information for ROM boot loader. 'gpt write' command doesn't preserve
that area and makes boot code gone.

Preserve boot code area when run 'gpt write' command.

Signed-off-by: Vincent Tinelli <[email protected]>
Signed-off-by: Brennan Ashton <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
Vincent Tinelli authored and trini committed Feb 8, 2017
1 parent d726f22 commit e163a93
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions disk/part_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
printf("%s: calloc failed!\n", __func__);
return -1;
}

/* Read MBR to backup boot code if it exists */
if (blk_dread(dev_desc, 0, 1, p_mbr) != 1) {
error("** Can't read from device %d **\n", dev_desc->devnum);
return -1;
}

/* Append signature */
p_mbr->signature = MSDOS_MBR_SIGNATURE;
p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT;
Expand Down

0 comments on commit e163a93

Please sign in to comment.