Skip to content
Permalink
Browse files

Don't error on unset BootOrder when we're trying to add to or rm from…

… it.

Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information...
vathpela committed Oct 15, 2014
1 parent 1bc5558 commit 301c0628f7fa7333791d2b5d79eb8e02fc848ee7
Showing with 21 additions and 12 deletions.
  1. +21 −12 src/efibootmgr/efibootmgr.c
@@ -323,6 +323,15 @@ read_boot_order(efi_variable_t **boot_order)
return rc;
}

static int
set_boot_u16(const char *name, uint16_t num)
{
return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_t *)&num,
sizeof (num), EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS);
}

static int
add_to_boot_order(uint16_t num)
{
@@ -332,8 +341,11 @@ add_to_boot_order(uint16_t num)
int rc;

rc = read_boot_order(&boot_order);
if (rc < 0)
if (rc < 0) {
if (errno == ENOENT)
rc = set_boot_u16("BootOrder", num);
return rc;
}

/* We've now got an array (in boot_order->data) of the
* boot order. First add our entry, then copy the old array.
@@ -369,8 +381,11 @@ remove_dupes_from_boot_order(void)
int rc;

rc = read_boot_order(&boot_order);
if (rc < 0)
if (rc < 0) {
if (errno == ENOENT)
rc = 0;
return rc;
}

old_data = (uint16_t *)(boot_order->data);
/* Start with the same size */
@@ -420,8 +435,11 @@ remove_from_boot_order(uint16_t num)
int rc;

rc = read_boot_order(&boot_order);
if (rc < 0)
if (rc < 0) {
if (errno == ENOENT)
rc = 0;
return rc;
}

/* We've now got an array (in boot_order->data) of the
boot order. Simply copy the array, skipping the
@@ -480,15 +498,6 @@ read_boot_u16(const char *name)
return rc;
}

static int
set_boot_u16(const char *name, uint16_t num)
{
return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_t *)&num,
sizeof (num), EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS);
}

static int
delete_boot_var(uint16_t num)
{

0 comments on commit 301c062

Please sign in to comment.
You can’t perform that action at this time.