gptrepair: fix status checking
None of these status bit checks were correct. Fix and simplify.
This commit is contained in:
parent
40e2f6fd35
commit
4268f3da52
1 changed files with 11 additions and 17 deletions
|
@ -46,8 +46,6 @@ grub_cmd_gptrepair (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_device_t dev = NULL;
|
||||
grub_gpt_t gpt = NULL;
|
||||
char *dev_name;
|
||||
grub_uint32_t primary_crc, backup_crc;
|
||||
enum grub_gpt_status old_status;
|
||||
|
||||
if (argc != 1 || !grub_strlen(args[0]))
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
|
||||
|
@ -67,29 +65,25 @@ grub_cmd_gptrepair (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (!gpt)
|
||||
goto done;
|
||||
|
||||
primary_crc = gpt->primary.crc32;
|
||||
backup_crc = gpt->backup.crc32;
|
||||
old_status = gpt->status;
|
||||
|
||||
if (grub_gpt_repair (dev->disk, gpt))
|
||||
goto done;
|
||||
|
||||
if (primary_crc == gpt->primary.crc32 &&
|
||||
backup_crc == gpt->backup.crc32 &&
|
||||
old_status && gpt->status)
|
||||
if ((gpt->status & GRUB_GPT_BOTH_VALID) == GRUB_GPT_BOTH_VALID)
|
||||
{
|
||||
grub_printf_ (N_("GPT already valid, %s unmodified.\n"), dev_name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((gpt->status & GRUB_GPT_PRIMARY_VALID) != GRUB_GPT_PRIMARY_VALID)
|
||||
grub_printf_ (N_("Found invalid primary GPT on %s\n"), dev_name);
|
||||
|
||||
if ((gpt->status & GRUB_GPT_BACKUP_VALID) != GRUB_GPT_BACKUP_VALID)
|
||||
grub_printf_ (N_("Found invalid backup GPT on %s\n"), dev_name);
|
||||
|
||||
if (grub_gpt_repair (dev->disk, gpt))
|
||||
goto done;
|
||||
|
||||
if (grub_gpt_write (dev->disk, gpt))
|
||||
goto done;
|
||||
|
||||
if (!(old_status & GRUB_GPT_PRIMARY_VALID))
|
||||
grub_printf_ (N_("Primary GPT for %s repaired.\n"), dev_name);
|
||||
|
||||
if (!(old_status & GRUB_GPT_BACKUP_VALID))
|
||||
grub_printf_ (N_("Backup GPT for %s repaired.\n"), dev_name);
|
||||
grub_printf_ (N_("Repaired GPT on %s\n"), dev_name);
|
||||
|
||||
done:
|
||||
if (gpt)
|
||||
|
|
Loading…
Reference in a new issue