Update to 0.9.0

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2014-10-14 16:33:50 -04:00
parent 59e75f7222
commit 2911475b8d
25 changed files with 243 additions and 2131 deletions

View File

@ -1,26 +0,0 @@
From 2a05511a070a56c720710b4f0410dc73b4c9b6d3 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 2 Apr 2014 10:04:52 -0400
Subject: [PATCH 01/22] Filenames and github - the worst of both worlds.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
efibootmgr.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/efibootmgr.spec b/efibootmgr.spec
index bd2eed0..39a5be5 100644
--- a/efibootmgr.spec
+++ b/efibootmgr.spec
@@ -16,7 +16,7 @@ BuildRequires: efivar-libs efivar-devel
Conflicts: elilo < 3.6-6
Obsoletes: elilo < 3.6-6
-Source0: https://github.com/vathpela/%{name}/archive/%{version}.tar.bz2
+Source0: https://github.com/vathpela/%{name}/archive/%{name}-%{version}.tar.bz2
%description
%{name} displays and allows the user to edit the Intel Extensible
--
1.9.3

View File

@ -0,0 +1,234 @@
From 9885893340146150df885f091bf17db840619154 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 14 Oct 2014 15:09:56 -0400
Subject: [PATCH] Make a few more return paths print some modicum of error
message.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 16 ++++++++---
src/lib/efi.c | 68 +++++++++++++++++++++++++++++----------------
2 files changed, 56 insertions(+), 28 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 01c1505..5f09b0b 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -242,16 +242,20 @@ make_boot_var(list_t *boot_list)
free_number = opts.bootnum;
}
- if (free_number == -1)
+ if (free_number == -1) {
+ fprintf(stderr, "efibootmgr: no available boot variables\n");
return NULL;
+ }
/* Create a new efi_variable_t object
and populate it.
*/
boot = calloc(1, sizeof(*boot));
- if (!boot)
+ if (!boot) {
+ fprintf(stderr, "efibootmgr: %m\n");
return NULL;
+ }
if (make_linux_load_option(&boot->data, &boot->data_size) < 0)
goto err_boot_entry;
if (append_extra_args(&boot->data, &boot->data_size) < 0)
@@ -260,8 +264,10 @@ make_boot_var(list_t *boot_list)
boot->num = free_number;
boot->guid = EFI_GLOBAL_VARIABLE;
rc = asprintf(&boot->name, "Boot%04X", free_number);
- if (rc < 0)
+ if (rc < 0) {
+ fprintf(stderr, "efibootmgr: %m\n");
goto err_boot_entry;
+ }
boot->attributes = EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS;
@@ -272,8 +278,10 @@ make_boot_var(list_t *boot_list)
list_add_tail(&boot->list, boot_list);
return boot;
err_boot_entry:
- if (boot->name)
+ if (boot->name) {
+ fprintf(stderr, "Could not set variable %s: %m\n", boot->name);
free(boot->name);
+ }
if (boot->data)
free(boot->data);
free(boot);
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 7cdc884..4b648fc 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -724,10 +724,13 @@ make_linux_load_option(uint8_t **data, size_t *data_size)
uint8_t *buf;
ssize_t needed;
off_t buf_offset = 0, desc_offset;
+ int rc;
load_option = calloc(1, sizeof (*load_option));
- if (load_option == NULL)
+ if (load_option == NULL) {
+ fprintf(stderr, "efibootmgr: %m\n");
return -1;
+ }
buf = (uint8_t *)load_option;
buf_offset = 0;
@@ -755,21 +758,33 @@ make_linux_load_option(uint8_t **data, size_t *data_size)
if (opts.iface) {
needed = make_net_load_option(opts.iface, NULL, 0);
if (needed < 0) {
+ fprintf(stderr, "efibootmgr: could not create load option: %m\n");
free(buf);
return needed;
}
buf = extend(load_option, load_option_size, needed);
- make_net_load_option(opts.iface, buf + buf_offset, needed);
+ rc = make_net_load_option(opts.iface, buf + buf_offset, needed);
buf_offset += needed;
+ if (rc < 0) {
+ fprintf(stderr, "efibootmgr: could not create load option: %m\n");
+ free(buf);
+ return rc;
+ }
} else {
needed = make_disk_load_option(opts.iface, NULL, 0);
if (needed < 0) {
+ fprintf(stderr, "efibootmgr: could not create load option: %m\n");
free(buf);
return needed;
}
buf = extend(load_option, load_option_size, needed);
- make_disk_load_option(opts.iface, buf + buf_offset, needed);
+ rc = make_disk_load_option(opts.iface, buf + buf_offset, needed);
buf_offset += needed;
+ if (rc < 0) {
+ fprintf(stderr, "efibootmgr: could not create load option: %m\n");
+ free(buf);
+ return rc;
+ }
}
load_option->file_path_list_length = buf_offset - desc_offset;
@@ -792,8 +807,10 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size)
int i;
unsigned long usedchars=0;
- if (!data || *data)
+ if (!data || *data) {
+ errno = EINVAL;
return -1;
+ }
for (i=opts.optind; i < opts.argc; i++) {
int l = strlen(opts.argv[i]) + 1;
@@ -829,8 +846,10 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size)
int i;
unsigned long usedchars=0;
- if (!data || *data)
+ if (!data || *data) {
+ errno = EINVAL;
return -1;
+ }
for (i = opts.optind; i < opts.argc; i++) {
int l = strlen(opts.argv[i]) + 1;
@@ -871,37 +890,31 @@ append_extra_args_file(uint8_t **data, size_t *data_size)
size_t maxchars = 0;
char *buffer;
- if (!data) {
- fprintf(stderr, "internal error\n");
- exit(1);
+ if (!data || *data) {
+ errno = EINVAL;
+ return -1;
}
if (file && strncmp(file, "-", 1))
fd = open(file, O_RDONLY);
- if (fd == -1) {
- perror("Failed to open extra arguments file");
- exit(1);
- }
+ if (fd < 0)
+ return -1;
buffer = malloc(maxchars);
do {
if (maxchars - appended == 0) {
maxchars += 1024;
char *tmp = realloc(buffer, maxchars);
- if (tmp == NULL) {
- perror("Error reading extra arguments file");
- exit(1);
- }
+ if (tmp == NULL)
+ return -1;
buffer = tmp;
}
num_read = read(fd, buffer + appended, maxchars - appended);
- if (num_read < 0) {
- perror("Error reading extra arguments file");
- exit(1);
- } else if (num_read > 0) {
+ if (num_read < 0)
+ return -1;
+ else if (num_read > 0)
appended += num_read;
- }
} while (num_read > 0);
if (fd != STDIN_FILENO)
@@ -935,14 +948,18 @@ append_extra_args(uint8_t **data, size_t *data_size)
if (opts.extra_opts_file) {
ret = append_extra_args_file(&new_data, &new_data_size);
- if (ret < 0)
+ if (ret < 0) {
+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n");
return -1;
+ }
}
if (new_data_size) {
ret = add_new_data(data, data_size, new_data, new_data_size);
free(new_data);
- if (ret < 0)
+ if (ret < 0) {
+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n");
return -1;
+ }
new_data = NULL;
new_data_size = 0;
}
@@ -952,6 +969,7 @@ append_extra_args(uint8_t **data, size_t *data_size)
else
ret = append_extra_args_ascii(&new_data, &new_data_size);
if (ret < 0) {
+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n");
if (new_data) /* this can't happen, but covscan believes */
free(new_data);
return -1;
@@ -960,8 +978,10 @@ append_extra_args(uint8_t **data, size_t *data_size)
ret = add_new_data(data, data_size, new_data, new_data_size);
free(new_data);
new_data = NULL;
- if (ret < 0)
+ if (ret < 0) {
+ fprintf(stderr, "efibootmgr: append_extra_args: %m\n");
return -1;
+ }
new_data_size = 0;
}
--
1.9.3

View File

@ -1,161 +0,0 @@
From c561f24adbce7b2e7aca4c4adf2ad32dae73435f Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 14 Apr 2014 16:39:42 -0400
Subject: [PATCH 02/22] Get a lot more picky with our compiler warnings.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Makefile | 2 +-
src/efibootmgr/efibootmgr.c | 9 ++++++---
src/include/efibootmgr.h | 4 ++--
src/lib/disk.c | 7 ++++---
src/lib/efi.c | 2 +-
src/lib/efichar.c | 4 ++--
src/lib/unparse_path.c | 2 +-
7 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index 610e165..c6e8e4a 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)
CFLAGS = $(EXTRA_CFLAGS) -DEFIBOOTMGR_VERSION=\"$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)\" \
- -Wall -g -D_FILE_OFFSET_BITS=64
+ -Wsign-compare -Wall -Werror -g -D_FILE_OFFSET_BITS=64
MODULES := src
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 98eea81..1bc48b2 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -342,7 +342,7 @@ remove_from_boot_order(uint16_t num)
efi_variable_t *boot_order = NULL;
uint64_t new_data_size;
uint16_t *new_data, *old_data;
- int old_i,new_i;
+ unsigned int old_i,new_i;
int rc;
rc = read_boot_order(&boot_order);
@@ -693,7 +693,7 @@ show_boot_vars()
printf("\n");
continue;
}
- if (optional_data_len > path->length + 4) {
+ if (optional_data_len > (uint64_t)(path->length + 4)) {
printf("(invalid optional data length)\n");
continue;
}
@@ -1083,7 +1083,10 @@ main(int argc, char **argv)
return 0;
}
- if (opts.iface && opts.acpi_hid == -1 && opts.acpi_uid == -1) {
+ if (opts.iface && (
+ opts.acpi_hid < 0 || opts.acpi_uid < 0 ||
+ opts.acpi_hid > UINT32_MAX ||
+ opts.acpi_uid > UINT32_MAX)) {
fprintf(stderr, "\nYou must specify the ACPI HID and UID when using -i.\n\n");
return 1;
}
diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h
index a1cbcec..87c83bb 100644
--- a/src/include/efibootmgr.h
+++ b/src/include/efibootmgr.h
@@ -40,8 +40,8 @@ typedef struct {
int bootnext;
int verbose;
int active;
- uint32_t acpi_hid;
- uint32_t acpi_uid;
+ int64_t acpi_hid;
+ int64_t acpi_uid;
unsigned int delete_boot:1;
unsigned int delete_bootorder:1;
unsigned int delete_bootnext:1;
diff --git a/src/lib/disk.c b/src/lib/disk.c
index eb2f54c..636b509 100644
--- a/src/lib/disk.c
+++ b/src/lib/disk.c
@@ -165,7 +165,8 @@ disk_info_from_fd(int fd, struct disk_info *info)
return 0;
}
- if (get_virtblk_major() != -1 && get_virtblk_major() == info->major) {
+ if (get_virtblk_major() >= 0 &&
+ (uint64_t)get_virtblk_major() == info->major) {
info->interface_type = virtblk;
info->disknum = info->minor >> 4;
info->part = info->minor & 0xF;
@@ -184,7 +185,7 @@ disk_get_virt_pci(const struct disk_info *info, unsigned char *bus,
ssize_t lnksz;
if (snprintf(inbuf, sizeof inbuf, "/sys/dev/block/%" PRIu64 ":%u",
- info->major, info->minor) >= sizeof inbuf) {
+ info->major, info->minor) >= (ssize_t)(sizeof inbuf)) {
return 1;
}
@@ -544,7 +545,7 @@ disk_get_partition_info (int fd,
offset = lseek(fd, 0, SEEK_SET);
this_bytes_read = read(fd, mbr_sector, mbr_size);
- if (this_bytes_read < sizeof(*mbr)) {
+ if (this_bytes_read < (ssize_t)sizeof(*mbr)) {
rc=1;
goto error_free_mbr;
}
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 6e9a01f..078bbc5 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -557,7 +557,7 @@ get_virt_pci(char *name, unsigned char *bus,
ssize_t lnksz;
if (snprintf(inbuf, sizeof inbuf, "/sys/bus/virtio/devices/%s",
- name) >= sizeof inbuf) {
+ name) >= (ssize_t)(sizeof inbuf)) {
return -1;
}
diff --git a/src/lib/efichar.c b/src/lib/efichar.c
index 831c759..b49b5a0 100644
--- a/src/lib/efichar.c
+++ b/src/lib/efichar.c
@@ -71,7 +71,7 @@ efichar_strcmp(const efi_char16_t *s1, const efi_char16_t *s2)
unsigned long
efichar_from_char(efi_char16_t *dest, const char *src, size_t dest_len)
{
- int i, src_len = strlen(src);
+ unsigned int i, src_len = strlen(src);
for (i=0; i < src_len && i < (dest_len/sizeof(*dest)) - 1; i++) {
dest[i] = src[i];
}
@@ -82,7 +82,7 @@ efichar_from_char(efi_char16_t *dest, const char *src, size_t dest_len)
unsigned long
efichar_to_char(char *dest, const efi_char16_t *src, size_t dest_len)
{
- int i, src_len = efichar_strlen(src, -1);
+ unsigned int i, src_len = efichar_strlen(src, -1);
for (i=0; i < src_len && i < (dest_len/sizeof(*dest)) - 1; i++) {
dest[i] = src[i];
}
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index 054ef9d..27e1dbb 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -505,7 +505,7 @@ unparse_path(char *buffer, size_t buffer_size,
buf_offset += needed;
if (path->length + sizeof (END_DEVICE_PATH)
- > pathsize - parsed_length) {
+ > (uint64_t)(pathsize - parsed_length)){
needed = snprintf(p + buf_offset,
buffer_size == 0
? 0
--
1.9.3

View File

@ -1,60 +0,0 @@
From a160ad75532ee551c4ac21372e2e9a11394f14d4 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 14 Apr 2014 16:49:12 -0400
Subject: [PATCH 03/22] Add support for displaying NVME device paths.
This doesn't actually let you /use/ them yet, but it does show them if
they're there.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/include/efi.h | 8 ++++++++
src/lib/unparse_path.c | 6 ++++++
2 files changed, 14 insertions(+)
diff --git a/src/include/efi.h b/src/include/efi.h
index fcc52ec..954b4a6 100644
--- a/src/include/efi.h
+++ b/src/include/efi.h
@@ -225,6 +225,14 @@ typedef struct {
uint8_t type;
uint8_t subtype;
uint16_t length;
+ uint32_t namespace_id;
+ uint64_t ieee_extended_unique_identifier;
+} __attribute__((packed)) NVME_DEVICE_PATH;
+
+typedef struct {
+ uint8_t type;
+ uint8_t subtype;
+ uint16_t length;
uint32_t reserved;
uint64_t node_guid;
uint64_t ioc_guid;
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index 27e1dbb..ffeda8e 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -196,6 +196,7 @@ unparse_messaging_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
I2O_DEVICE_PATH *i2o = (I2O_DEVICE_PATH *)path;
IPv4_DEVICE_PATH *ipv4 = (IPv4_DEVICE_PATH *)path;
/* IPv6_DEVICE_PATH *ipv6 = (IPv6_DEVICE_PATH *)path; */
+ NVME_DEVICE_PATH *nvme = (NVME_DEVICE_PATH *)path;
char a[16], b[16], c[16], d[16], e[16];
size_t needed;
@@ -304,6 +305,11 @@ unparse_messaging_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
get(a, sata->port),
get(b, sata->port_multiplier),
get(c, sata->lun));
+ case 23:
+ return snprintf(buffer, buffer_size,
+ "NVME(%x,%lx)",
+ get(a, nvme->namespace_id),
+ get(b, nvme->ieee_extended_unique_identifier));
default:
return unparse_raw(buffer, buffer_size,
(uint8_t *)path, path->length);
--
1.9.3

View File

@ -1,188 +0,0 @@
From 47b2772a8e419ebadcf54182bfbd6170f7ab24f1 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 14 Apr 2014 17:19:57 -0400
Subject: [PATCH 04/22] Make nvme work with "-e 3".
This will force a long-form NVME device path.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/include/disk.h | 2 +-
src/include/scsi_ioctls.h | 1 +
src/lib/disk.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/lib/efi.c | 29 +++++++++++++++++++++++++++--
src/lib/scsi_ioctls.c | 7 +++++++
5 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/src/include/disk.h b/src/include/disk.h
index 720248c..3b3370d 100644
--- a/src/include/disk.h
+++ b/src/include/disk.h
@@ -65,7 +65,7 @@ enum _bus_type {bus_type_unknown, isa, pci};
enum _interface_type {interface_type_unknown,
ata, atapi, scsi, usb,
i1394, fibre, i2o, md,
- virtblk};
+ virtblk, nvme};
unsigned int lcm(unsigned int x, unsigned int y);
diff --git a/src/include/scsi_ioctls.h b/src/include/scsi_ioctls.h
index ba4c8bb..995cbbd 100644
--- a/src/include/scsi_ioctls.h
+++ b/src/include/scsi_ioctls.h
@@ -38,6 +38,7 @@ typedef struct scsi_idlun {
} Scsi_Idlun;
+int get_nvme_ns_id(int fd, uint32_t *ns_id);
inline int get_scsi_idlun(int fd, Scsi_Idlun *idlun);
int get_scsi_pci(int fd, char *slot_name, size_t size);
int idlun_to_components (Scsi_Idlun *idlun,
diff --git a/src/lib/disk.c b/src/lib/disk.c
index 636b509..ad95fd4 100644
--- a/src/lib/disk.c
+++ b/src/lib/disk.c
@@ -75,6 +75,45 @@ get_virtblk_major(void)
return cached;
}
+static int
+get_nvme_major(void)
+{
+ static int cached;
+ FILE *f;
+ char line[256];
+
+ if (cached != 0) {
+ return cached;
+ }
+
+ cached = -1;
+ f = fopen("/proc/devices", "r");
+ if (f == NULL) {
+ fprintf(stderr, "%s: opening /proc/devices: %s\n", __func__,
+ strerror(errno));
+ return cached;
+ }
+ while (fgets(line, sizeof line, f) != NULL) {
+ size_t len = strlen(line);
+ int major, scanned;
+
+ if (len == 0 || line[len - 1] != '\n') {
+ break;
+ }
+ if (sscanf(line, "%d %n", &major, &scanned) == 1 &&
+ strcmp(line + scanned, "nvme\n") == 0) {
+ cached = major;
+ break;
+ }
+ }
+ fclose(f);
+ if (cached == -1) {
+ fprintf(stderr, "%s: nvme driver unavailable\n",
+ __func__);
+ }
+ return cached;
+}
+
int
disk_info_from_fd(int fd, struct disk_info *info)
{
@@ -165,6 +204,12 @@ disk_info_from_fd(int fd, struct disk_info *info)
return 0;
}
+ if (get_nvme_major() >= 0 &&
+ (uint64_t)get_nvme_major() == info->major) {
+ info->interface_type = nvme;
+ return 0;
+ }
+
if (get_virtblk_major() >= 0 &&
(uint64_t)get_virtblk_major() == info->major) {
info->interface_type = virtblk;
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 078bbc5..7b5e7fd 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -352,6 +352,20 @@ make_pci_device_path(uint8_t bus, uint8_t device, uint8_t function,
}
static ssize_t
+make_nvme_device_path(uint32_t ns_id, uint8_t *buf, size_t size)
+{
+ NVME_DEVICE_PATH p;
+ memset(&p, 0, sizeof(p));
+ p.type = 3;
+ p.subtype = 23;
+ p.length = sizeof(p);
+ p.namespace_id = ns_id;
+ if (size >= p.length)
+ memcpy(buf, &p, p.length);
+ return p.length;
+}
+
+static ssize_t
make_scsi_device_path(uint16_t id, uint16_t lun, uint8_t *buf, size_t size)
{
SCSI_DEVICE_PATH p;
@@ -420,13 +434,18 @@ make_edd30_device_path(int fd, uint8_t *buf, size_t size)
int rc=0, interface_type;
unsigned char bus=0, device=0, function=0;
Scsi_Idlun idlun;
+ uint32_t ns_id;
unsigned char host=0, channel=0, id=0, lun=0;
size_t needed;
off_t buf_offset = 0;
rc = disk_get_pci(fd, &interface_type, &bus, &device, &function);
if (rc) return 0;
- if (interface_type != virtblk) {
+ if (interface_type == nvme) {
+ rc = get_nvme_ns_id(fd, &ns_id);
+ if (rc)
+ return 0;
+ } else if (interface_type != virtblk) {
memset(&idlun, 0, sizeof(idlun));
rc = get_scsi_idlun(fd, &idlun);
if (rc) return 0;
@@ -444,7 +463,13 @@ make_edd30_device_path(int fd, uint8_t *buf, size_t size)
return needed;
buf_offset += needed;
- if (interface_type != virtblk) {
+ if (interface_type == nvme) {
+ needed = make_nvme_device_path(ns_id, buf + buf_offset,
+ size == 0 ? 0 : size - buf_offset);
+ if (needed < 0)
+ return needed;
+ buf_offset += needed;
+ } else if (interface_type != virtblk) {
needed = make_scsi_device_path(id, lun, buf + buf_offset,
size == 0 ? 0 : size - buf_offset);
if (needed < 0)
diff --git a/src/lib/scsi_ioctls.c b/src/lib/scsi_ioctls.c
index 615b48f..e013a6f 100644
--- a/src/lib/scsi_ioctls.c
+++ b/src/lib/scsi_ioctls.c
@@ -24,9 +24,16 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#include <linux/nvme.h>
#include "scsi_ioctls.h"
int
+get_nvme_ns_id(int fd, uint32_t *ns_id)
+{
+ return ioctl(fd, NVME_IOCTL_ID, &ns_id);
+}
+
+int
idlun_to_components (Scsi_Idlun *idlun,
unsigned char *host,
unsigned char *channel,
--
1.9.3

View File

@ -1,34 +0,0 @@
From cadc90a7efc977a8bfb835a5ade5333e0800648a Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 29 Apr 2014 11:31:15 -0400
Subject: [PATCH 05/22] Remove bogus test for optional data length bounds.
We're getting the size from subtracting from the actual limit; it can't
be over the limit, and it's not related to the variable we're comparing
it to anyway.
Not sure how I came up with that logic, but it sure is wrong.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 1bc48b2..e2ec5cd 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -693,10 +693,6 @@ show_boot_vars()
printf("\n");
continue;
}
- if (optional_data_len > (uint64_t)(path->length + 4)) {
- printf("(invalid optional data length)\n");
- continue;
- }
rc = unparse_raw_text(text_path, text_path_len,
((uint8_t *)path)
--
1.9.3

View File

@ -1,28 +0,0 @@
From 2fbeee2c3f7e8714610cb9fcd2f6d3d7daa62767 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 5 May 2014 16:09:09 -0400
Subject: [PATCH 06/22] Only free hard drive signatures if we've allocated
them.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/unparse_path.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index ffeda8e..030e7c8 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -352,7 +352,8 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size,
get(b, hd->start),
get(c, hd->size),
sig);
- free(sig);
+ if (hd->signature_type == 0x02)
+ free(sig);
return rc;
}
--
1.9.3

View File

@ -1,486 +0,0 @@
From 1f39dc1100b58db9ffa6c5486d40521fddb064dd Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 16 Jun 2014 14:26:05 -0400
Subject: [PATCH 07/22] We don't actually have docbook hooked up to the builds,
so ditch it.
Frankly I'm more comfortable maintaining groff anyway, but right now
they just get out of sync all the time.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/man/man8/efibootmgr.8.docbook | 462 --------------------------------------
1 file changed, 462 deletions(-)
delete mode 100644 src/man/man8/efibootmgr.8.docbook
diff --git a/src/man/man8/efibootmgr.8.docbook b/src/man/man8/efibootmgr.8.docbook
deleted file mode 100644
index 3438d56..0000000
--- a/src/man/man8/efibootmgr.8.docbook
+++ /dev/null
@@ -1,462 +0,0 @@
-<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
-
-<!-- This manpage was compiled by dann frazier <email>dannf@debian.org</email>,
- and was based on an example constructed by Colin Watson
- <email>cjwatson@debian.org</email>, which was based on a man page template
- provided by Tom Christiansen <email>tchrist@jhereg.perl.com</email>
- and a DocBook man page example by Craig Small
- <email>csmall@debian.org</email>.
-
- The content was mostly taken from the efibootmgr README file in the
- Debian package, which was written by Matt Domsch
- <email>Matt_Domsch@dell.com</email>.
- -->
-
- <!-- Fill in the various UPPER CASE things here. -->
- <!ENTITY manfirstname "<firstname>dann</firstname>">
- <!ENTITY mansurname "<surname>frazier</surname>">
- <!-- Please adjust the date whenever revising the manpage. -->
- <!ENTITY mandate "<date>2005-08-11</date>">
- <!-- SECTION should be 1-8, maybe with subsection. Other parameters are
- allowed: see man(7), man(1). -->
- <!ENTITY mansection "<manvolnum>8</manvolnum>">
- <!ENTITY manemail "<email>dannf@debian.org</email>">
- <!ENTITY manusername "dann frazier">
- <!ENTITY manucpackage "<refentrytitle>EFIBOOTMGR</refentrytitle>">
- <!ENTITY manpackage "efibootmgr">
-]>
-
-<refentry>
- <refentryinfo>
- <address>
- &manemail;
- </address>
- <author>
- &manfirstname;
- &mansurname;
- </author>
- <copyright>
- <year>2002, 2003, 2004</year>
- <holder>&manusername;</holder>
- </copyright>
- &mandate;
- </refentryinfo>
- <refmeta>
- &manucpackage;
-
- &mansection;
- </refmeta>
- <refnamediv>
- <refname>&manpackage;</refname>
-
- <refpurpose>manipulate the EFI Boot Manager</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>&manpackage;</command>
-
- <arg>-a</arg>
- <arg>-A</arg>
- <arg>-b <replaceable>XXXX</replaceable></arg>
- <arg>-B <replaceable>XXXX</replaceable></arg>
- <arg>-c</arg>
- <arg>-d <replaceable>DISK</replaceable></arg>
- <arg>-e <replaceable>1|3|-1</replaceable></arg>
- <arg>-E <replaceable>NUM</replaceable></arg>
- <arg>-g</arg>
- <arg>-H <replaceable>XXXX</replaceable></arg>
- <arg>-i <replaceable>NAME</replaceable></arg>
- <arg>-l <replaceable>NAME</replaceable></arg>
- <arg>-L <replaceable>LABEL</replaceable></arg>
- <arg>-n <replaceable>XXXX</replaceable></arg>
- <arg>-N</arg>
- <arg rep="repeat">-o <replaceable>XXXX</replaceable>,<replaceable>YYYY</replaceable>,<replaceable>ZZZZ</replaceable></arg>
- <arg>-O</arg>
- <arg>-p <replaceable>PART</replaceable></arg>
- <arg>-q</arg>
- <arg>-t <replaceable>seconds</replaceable></arg>
- <arg>-T</arg>
- <arg>-u</arg>
- <arg>-U <replaceable>XXXX</replaceable></arg>
- <arg>-v</arg>
- <arg>-V</arg>
- <arg>-w</arg>
- <arg>-@ <replaceable>file</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
- <refsect1>
- <title>DESCRIPTION</title>
-
- <para><command>&manpackage;</command> is a userspace application used to
- modify the Intel Extensible Firmware Interface (EFI) Boot Manager. This
- application can create and destroy boot entries, change the boot order,
- change the next running boot option, and more.</para>
-
- <para>
- Details on the EFI Boot Manager are available from the EFI
- Specification, v1.02 or later, available from:
- <ulink url="http://developer.intel.com"></ulink>
- </para>
-
- <note>
- <para>
- &manpackage; requires that the kernel support access to EFI
- non-volatile variables (through
- <filename>/proc/efi/vars</filename> on 2.4 kernels,
- <filename>/sys/firmware/efi/vars</filename> on 2.6 kernels).
- <command>modprobe efivars</command> should do the trick.
- </para>
- </note>
- </refsect1>
- <refsect1>
- <title>OPTIONS</title>
-
- <para>The following is a list of options accepted by &manpackage;:</para>
-
- <variablelist>
- <varlistentry>
- <term><option>-a</option> | <option>--active</option></term>
- <listitem>
- <para>Sets bootnum active</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-A</option> | <option>--inactive</option></term>
- <listitem>
- <para>Sets bootnum inactive</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-b</option> | <option>--bootnum</option> <replaceable>XXXX</replaceable></term>
- <listitem>
- <para>Modify Boot<replaceable>XXXX</replaceable> (hex)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-B</option> | <option>--delete-bootnum</option></term>
- <listitem>
- <para>Delete bootnum (hex)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-c</option> | <option>--create</option></term>
- <listitem>
- <para>Create new variable bootnum and add to bootorder</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-d</option> | <option>--disk</option> <replaceable>DISK</replaceable></term>
- <listitem>
- <para>The disk containing the loader (defaults to
- <filename>/dev/sda</filename>)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-e</option> | <option>--edd</option> <replaceable>1|3|-1</replaceable></term>
- <listitem>
- <para>Force EDD 1.0 or 3.0 creation variables, or guess.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-E</option> | <option>--device</option> <replaceable>NUM</replaceable></term>
- <listitem>
- <para>EDD 1.0 device number (defaults to 0x80)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-g</option> | <option>--gpt</option></term>
- <listitem>
- <para>Force disk with invalid PMBR to be treated as GPT</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-H</option> | <option>--acpi_hid</option> <replaceable>XXXX</replaceable></term>
- <listitem>
- <para>set the ACPI HID (used with <option>-i</option>)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-i</option> | <option>--iface</option> <replaceable>NAME</replaceable></term>
- <listitem>
- <para>create a netboot entry for the named interface</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-l</option> | <option>--loader</option> <replaceable>NAME</replaceable></term>
- <listitem>
- <para>Specify a loader (defaults to <filename>\\elilo.efi</filename>)
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-L</option> | <option>--label</option> <replaceable>LABEL</replaceable></term>
- <listitem>
- <para>Boot manager display label (defaults to "Linux")</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-n</option> | <option>--bootnext</option> <replaceable>XXXX</replaceable></term>
- <listitem>
- <para>Set BootNext to XXXX (hex)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-N</option> | <option>--delete-bootnext</option></term>
- <listitem>
- <para>Delete BootNext</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-o</option> | <option>--bootorder</option> <replaceable>XXXX</replaceable>,<replaceable>YYYY</replaceable>,<replaceable>ZZZZ</replaceable></term>
- <listitem>
- <para>Explicitly set BootOrder (hex)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-O</option> | <option>--delete-bootorder</option></term>
- <listitem>
- <para>Delete BootOrder</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-p</option> | <option>--part</option> <replaceable>PART</replaceable></term>
- <listitem>
- <para>Partition number containing the bootloader (defaults to 1)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-q</option> | <option>--quiet</option></term>
- <listitem>
- <para>Quiet mode - supresses output.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--test</option> <replaceable>filename</replaceable></term>
- <listitem>
- <para>Don't write to NVRAM, write to <replaceable>filename</replaceable>.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-t</option> | <option>--timeout</option> <replaceable>seconds</replaceable></term>
- <listitem>
- <para>Boot Manager timeout, in <replaceable>seconds</replaceable>.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-T</option> | <option>--delete-timeout</option></term>
- <listitem>
- <para>Delete Timeout variable.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-u</option> | <option>--unicode</option> | <option>--UCS-2</option> </term>
- <listitem>
- <para>pass extra command line arguments as UCS-2 (default is
- ASCII)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-U</option> | <option>--acpi_uid</option> <replaceable>XXXX</replaceable></term>
- <listitem>
- <para>set the ACPI UID (used with <option>-i</option>)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-v</option> | <option>--verbose</option></term>
- <listitem>
- <para>Verbose mode - prints additional information</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-V</option> | <option>--version</option></term>
- <listitem>
- <para>Just print version string and exit.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-w</option> | <option>--write-signature</option></term>
- <listitem>
- <para>write unique signature to the MBR if needed</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-@</option> |
- <option>--append-binary-args</option>
- </term>
- <listitem>
- <para>append extra variable args from file (use - to read
- from stdin). Data in file is appended as command line
- arguments to the boot loader command, with no modification to
- the data, so you can pass any binary or text data necessary.</para>
- </listitem>
- </varlistentry>
- </variablelist>
-
- </refsect1>
-
- <refsect1>
- <title>EXAMPLES</title>
- <orderedlist>
- <listitem>
- <example>
- <title>Displaying the current settings (must be root).</title>
-
- <para>
- <programlisting>
- [root@localhost ~]# efibootmgr
- BootCurrent: 0004
- BootNext: 0003
- BootOrder: 0004,0000,0001,0002,0003
- Timeout: 30 seconds
- Boot0000* Diskette Drive(device:0)
- Boot0001* CD-ROM Drive(device:FF)
- Boot0002* Hard Drive(Device:80)/HD(Part1,Sig00112233)
- Boot0003* PXE Boot: MAC(00D0B7C15D91)
- Boot0004* Linux
- </programlisting>
- </para>
- <para>This shows:</para>
- <itemizedlist>
- <listitem>
- <para>BootCurrent - the boot entry used to start the currently
- running system</para>
- </listitem>
- <listitem>
- <para>
- BootOrder - the boot order as would appear in the boot manager.
- The boot manager tries to boot the first active entry in this
- list. If unsuccessful, it tries the next entry, and so on.
- </para>
- </listitem>
- <listitem>
- <para>
- BootNext - the boot entry which is scheduled to be run on next
- boot. This supercedes BootOrder for one boot only, and is
- deleted by the boot manager after first use. This allows you
- to change the next boot behavior without changing BootOrder.
- </para>
- </listitem>
- <listitem>
- <para>
- Timeout - the time in seconds between when the boot
- manager appears on the screen until when it
- automatically chooses the startup value from BootNext
- or BootOrder.
- </para>
- </listitem>
- <listitem>
- <para>
- Five boot entries (0000 - 0004), along with the active/inactive
- flag (* means active) and the name displayed on the screen.
- </para>
- </listitem>
- </itemizedlist>
- </example>
- </listitem>
- <listitem>
- <example>
- <title>Creating a new boot option</title>
- <para>
- An OS installer would call <command>&manpackage; -c</command>.
- This assumes that <filename>/boot/efi</filename> is your EFI System
- Partition, and is mounted at <filename>/dev/sda1</filename>. This
- creates a new boot option, called "Linux", and puts it at the top of
- the boot order list. Options may be passed to modify the default
- behavior. The default OS Loader is <filename>elilo.efi</filename>.
- </para>
- </example>
- </listitem>
- <listitem>
- <example>
- <title>Changing the Boot Order</title>
- <para>
- Assuming the configuration in Example #1,
- <command>&manpackage; -o 3,4</command> could be called to specify
- PXE boot first, then Linux boot.
- </para>
- </example>
- </listitem>
- <listitem>
- <example>
- <title>Changing the Boot Order for the Next Boot Only</title>
- <para>
- Assuming the configuration in Example #1,
- <command>&manpackage; -n 4</command> could be called to specify
- that the Linux entry be taken on next boot.
- </para>
- </example>
- </listitem>
- <listitem>
- <example>
- <title>Deleting a boot option</title>
- <para>
- Assuming the configuration in Example #1,
- <command>&manpackage; -b 4 -B</command> could be called to delete
- entry 4 and remove it from the BootOrder.
- </para>
- </example>
- </listitem>
- <listitem>
- <example>
- <title>Creating network boot entries</title>
- <para>
- A system administrator wants to create a boot option to network
- boot (PXE). Unfortunately, this requires knowing a little more
- information about your system than can be easily found by
- efibootmgr, so you've got to pass additional information - the ACPI
- HID and UID values. These can generally be found by using the EFI
- Boot Manager (in the EFI environment) to create a network boot
- entry, then using efibootmgr to print it verbosely. Here's one example:
- <computeroutput>
- Boot003* Acpi(PNP0A03,0)/PCI(5|0)/Mac(00D0B7F9F510) \
- ACPI(a0341d0,0)PCI(0,5)MAC(00d0b7f9f510,0)
-
- In this case, the ACPI HID is "0A0341d0" and the UID is "0".
- For the zx2000 gigE, the HID is "222F" and the UID is "500".
- For the rx2000 gigE, the HID is "0002" and the UID is "100".
- </computeroutput>
- You create the boot entry with:
- <command>efibootmgr -c -i eth0 -H 222F -U 500 -L netboot</command>
- </para>
- </example>
- </listitem>
- </orderedlist>
- </refsect1>
-
- <refsect1>
- <title>BUGS</title>
-
- <para>Please direct any bugs, features, patches, etc. to Peter Jones:
- <ulink url="https://github.com/vathpela"></ulink>.
- </para>
- </refsect1>
-
- <refsect1>
- <title>AUTHOR</title>
- <para>This man page was generated by dann frazier &manemail; for the
- Debian GNU/Linux operating system, but may be used by others.</para>
- </refsect1>
-
- <refsect1>
- <title>SEE ALSO</title>
-
- <para>elilo(1)</para>
- </refsect1>
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
--
1.9.3

View File

@ -1,65 +0,0 @@
From 15a46a8023c9925a78ddbacc8534af17db611edb Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 17 Jun 2014 14:05:31 -0400
Subject: [PATCH 08/22] Mitigate apple setting invalid attribute bits in boot
variables.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index e2ec5cd..f596d99 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -115,6 +115,13 @@ read_vars(char **namelist,
&entry->attributes);
if (rc < 0)
goto err;
+
+ /* latest apple firmware sets high bit which appears
+ * invalid to the linux kernel if we write it back so
+ * lets zero it out if it is set since it would be
+ * invalid to set it anyway */
+ entry->attributes = entry->attributes & ~(1 << 31);
+
entry->name = namelist[i];
list_add_tail(&entry->list, head);
}
@@ -299,6 +306,11 @@ read_boot_order(efi_variable_t **boot_order)
free(new);
*boot_order = NULL;
}
+
+ /* latest apple firmware sets high bit which appears invalid
+ * to the linux kernel if we write it back so lets zero it out
+ * if it is set since it would be invalid to set it anyway */
+ bo->attributes = bo->attributes & ~(1 << 31);
return rc;
}
@@ -404,7 +416,7 @@ read_boot_u16(const char *name)
static int
set_boot_u16(const char *name, uint16_t num)
{
- return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_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);
@@ -577,6 +589,11 @@ construct_boot_order(char *bootorder, int keep,
return 0;
}
+ /* latest apple firmware sets high bit which appears invalid
+ * to the linux kernel if we write it back so lets zero it out
+ * if it is set since it would be invalid to set it anyway */
+ bo.attributes = bo.attributes & ~(1 << 31);
+
size_t new_data_size = data_size + bo.data_size;
uint16_t *new_data = calloc(1, new_data_size);
if (!new_data)
--
1.9.3

View File

@ -1,30 +0,0 @@
From 517edfe7905b6294b304f0a196e852f39b772f0f Mon Sep 17 00:00:00 2001
From: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Date: Mon, 7 Jul 2014 13:58:56 -0500
Subject: [PATCH 09/22] Remove unused function var_num_from_name.
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
---
src/efibootmgr/efibootmgr.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index f596d99..03613ab 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -72,12 +72,6 @@ static LIST_HEAD(boot_entry_list);
static LIST_HEAD(blk_list);
efibootmgr_opt_t opts;
-static inline void
-var_num_from_name(const char *pattern, char *name, uint16_t *num)
-{
- sscanf(name, pattern, num);
-}
-
static void
free_vars(list_t *head)
{
--
1.9.3

View File

@ -1,26 +0,0 @@
From 78920cfc3828389cb61de4ca06bf70d6fa959c0d Mon Sep 17 00:00:00 2001
From: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Date: Mon, 7 Jul 2014 14:02:22 -0500
Subject: [PATCH 10/22] Fix typo in compare function.
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
---
src/efibootmgr/efibootmgr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 03613ab..a59d071 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -149,7 +149,7 @@ compare(const void *a, const void *b)
memcpy(&n2, b, sizeof(n2));
if (n1 < n2) rc = -1;
if (n1 == n2) rc = 0;
- if (n2 > n2) rc = 1;
+ if (n1 > n2) rc = 1;
return rc;
}
--
1.9.3

View File

@ -1,36 +0,0 @@
From a16e5dce59d8cf50b1262e3d2358b556095a4e96 Mon Sep 17 00:00:00 2001
From: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Date: Mon, 7 Jul 2014 14:09:15 -0500
Subject: [PATCH 11/22] data_size in construct_boot_order/set_boot_order is of
type size_t, so fix a couple of comparisons involving it.
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
---
src/efibootmgr/efibootmgr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index a59d071..ba5f54f 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -566,7 +566,7 @@ construct_boot_order(char *bootorder, int keep,
size_t data_size = 0;
rc = parse_boot_order(bootorder, (uint16_t **)&data, &data_size);
- if (rc < 0 || data_size <= 0)
+ if (rc < 0 || data_size == 0)
return rc;
if (!keep) {
@@ -631,7 +631,7 @@ set_boot_order(int keep_old_entries)
rc = construct_boot_order(opts.bootorder, keep_old_entries,
(uint16_t **)&data, &data_size);
- if (rc < 0 || data_size < 0)
+ if (rc < 0 || data_size == 0)
return rc;
return efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", data, data_size,
--
1.9.3

View File

@ -1,113 +0,0 @@
From fd1ccafe0b9b33e460947487858371daec26f9a9 Mon Sep 17 00:00:00 2001
From: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Date: Mon, 7 Jul 2014 14:18:27 -0500
Subject: [PATCH 12/22] Variable "needed" should be of type ssize_t as that's
how it's used.
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
---
src/lib/efi.c | 8 ++++----
src/lib/unparse_path.c | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 7b5e7fd..74df42a 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -309,7 +309,7 @@ make_pci_device_path(uint8_t bus, uint8_t device, uint8_t function,
struct pci_access *pacc;
struct list_head *pos, *n;
LIST_HEAD(pci_parent_list);
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
pacc = pci_alloc();
@@ -436,7 +436,7 @@ make_edd30_device_path(int fd, uint8_t *buf, size_t size)
Scsi_Idlun idlun;
uint32_t ns_id;
unsigned char host=0, channel=0, id=0, lun=0;
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
rc = disk_get_pci(fd, &interface_type, &bus, &device, &function);
@@ -508,7 +508,7 @@ make_disk_load_option(char *disk, uint8_t *buf, size_t size)
uint8_t mbr_type=0, signature_type=0;
uint64_t part_start=0, part_size=0;
efi_char16_t *os_loader_path;
- size_t needed = 0;
+ ssize_t needed = 0;
off_t buf_offset = 0;
memset(signature, 0, sizeof(signature));
@@ -615,7 +615,7 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size)
unsigned char bus, slot, func;
struct ifreq ifr;
struct ethtool_drvinfo drvinfo;
- size_t needed;
+ ssize_t needed;
off_t buf_offset;
memset(&ifr, 0, sizeof(ifr));
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index 030e7c8..c39a49a 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -43,7 +43,7 @@ unparse_raw(char *buffer, size_t buffer_size, uint8_t *p, uint64_t length)
uint64_t i;
char a[1];
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
for (i=0; i < length; i++) {
@@ -62,7 +62,7 @@ unparse_raw_text(char *buffer, size_t buffer_size, uint8_t *p, uint64_t length)
{
uint64_t i; unsigned char c;
- size_t needed;
+ ssize_t needed;
size_t buf_offset = 0;
for (i=0; i < length; i++) {
@@ -116,7 +116,7 @@ unparse_vendor_path(char *buffer, size_t buffer_size, char *prefix,
unsigned char *q = (uint8_t *)path + 20;
int rc;
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
rc = efi_guid_to_str(&path->vendor_guid, &text_guid);
@@ -199,7 +199,7 @@ unparse_messaging_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
NVME_DEVICE_PATH *nvme = (NVME_DEVICE_PATH *)path;
char a[16], b[16], c[16], d[16], e[16];
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
switch (path->subtype) {
@@ -417,7 +417,7 @@ unparse_bios_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
unsigned char *q = (uint8_t *)path + 8;
char a[16], b[16];
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
needed = snprintf(p + buf_offset,
@@ -451,7 +451,7 @@ unparse_path(char *buffer, size_t buffer_size,
{
uint16_t parsed_length = 0;
char *p = buffer;
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0;
int exit_now = 0;
--
1.9.3

View File

@ -1,42 +0,0 @@
From 0d92b6b342959ce1b7528087f066bdada2e4aefb Mon Sep 17 00:00:00 2001
From: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Date: Mon, 7 Jul 2014 20:50:50 -0500
Subject: [PATCH 13/22] Clang uses C99 semantics by default for inline keyword.
It's most straightforward not to state get_scsi_idlun is inline.
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
---
src/include/scsi_ioctls.h | 2 +-
src/lib/scsi_ioctls.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/include/scsi_ioctls.h b/src/include/scsi_ioctls.h
index 995cbbd..331bb14 100644
--- a/src/include/scsi_ioctls.h
+++ b/src/include/scsi_ioctls.h
@@ -39,7 +39,7 @@ typedef struct scsi_idlun {
int get_nvme_ns_id(int fd, uint32_t *ns_id);
-inline int get_scsi_idlun(int fd, Scsi_Idlun *idlun);
+int get_scsi_idlun(int fd, Scsi_Idlun *idlun);
int get_scsi_pci(int fd, char *slot_name, size_t size);
int idlun_to_components (Scsi_Idlun *idlun,
unsigned char *host,
diff --git a/src/lib/scsi_ioctls.c b/src/lib/scsi_ioctls.c
index e013a6f..c04f12a 100644
--- a/src/lib/scsi_ioctls.c
+++ b/src/lib/scsi_ioctls.c
@@ -50,7 +50,7 @@ idlun_to_components (Scsi_Idlun *idlun,
}
-inline int
+int
get_scsi_idlun(int fd, Scsi_Idlun *idlun)
{
return ioctl(fd, SCSI_IOCTL_GET_IDLUN, idlun);
--
1.9.3

View File

@ -1,29 +0,0 @@
From ea6dccaed60caf11006f8a816113e4b0d39deefb Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 22 Jul 2014 10:11:39 -0400
Subject: [PATCH 14/22] Use PRIx64 in nvme parsing.
This should fix https://github.com/vathpela/efibootmgr/issues/6 , though
I don't know if it'll actually make nvme work.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/unparse_path.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index c39a49a..b164758 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -307,7 +307,7 @@ unparse_messaging_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
get(c, sata->lun));
case 23:
return snprintf(buffer, buffer_size,
- "NVME(%x,%lx)",
+ "NVME(%x,%" PRIx64 ")",
get(a, nvme->namespace_id),
get(b, nvme->ieee_extended_unique_identifier));
default:
--
1.9.3

View File

@ -1,26 +0,0 @@
From 895b702ac316a618f32fbdd74a6767277d48284a Mon Sep 17 00:00:00 2001
From: groxxda <ried@mytum.de>
Date: Thu, 31 Jul 2014 18:37:37 +0200
Subject: [PATCH 15/22] Compare should respect the size of the data it
compares.
---
src/efibootmgr/efibootmgr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index ba5f54f..6b03c84 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -144,7 +144,7 @@ static int
compare(const void *a, const void *b)
{
int rc = -1;
- uint32_t n1, n2;
+ uint16_t n1, n2;
memcpy(&n1, a, sizeof(n1));
memcpy(&n2, b, sizeof(n2));
if (n1 < n2) rc = -1;
--
1.9.3

View File

@ -1,51 +0,0 @@
From 099e1107489a24e019e8900f1c44da646945c343 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 04:56:18 -0400
Subject: [PATCH 16/22] Don't pass around a format specifier when we don't need
to.
Current code has the format specifier in a function that doesn't
otherwise know about the format, and passes it in to a function that
does.
And it's always been like this.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 6b03c84..0d7224a 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -452,7 +452,7 @@ delete_boot_var(uint16_t num)
static void
-set_var_nums(const char *pattern, list_t *list)
+set_var_nums(list_t *list)
{
list_t *pos;
efi_variable_t *var;
@@ -462,7 +462,7 @@ set_var_nums(const char *pattern, list_t *list)
list_for_each(pos, list) {
var = list_entry(pos, efi_variable_t, list);
- rc = sscanf(var->name, pattern, &num);
+ rc = sscanf(var->name, "Boot%04X-%*s", &num);
if (rc == 1) {
var->num = num;
name = var->name; /* shorter name */
@@ -1105,7 +1105,7 @@ main(int argc, char **argv)
read_boot_var_names(&boot_names);
read_vars(boot_names, &boot_entry_list);
- set_var_nums("Boot%04X-%*s", &boot_entry_list);
+ set_var_nums(&boot_entry_list);
if (opts.delete_boot) {
if (opts.bootnum == -1) {
--
1.9.3

View File

@ -1,29 +0,0 @@
From 1f2c2f35d34c4da42afa803fd16687b8bed27162 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 05:37:05 -0400
Subject: [PATCH 17/22] Don't leak memory in remove_from_boot_order()
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 0d7224a..d3448da 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -381,8 +381,10 @@ remove_from_boot_order(uint16_t num)
boot_order->data = (uint8_t *)new_data;
boot_order->data_size = new_data_size;
efi_del_variable(EFI_GLOBAL_GUID, "BootOrder");
- return efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
+ rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
boot_order->data_size, boot_order->attributes);
+ free(boot_order->data);
+ return rc;
}
static int
--
1.9.3

View File

@ -1,96 +0,0 @@
From 1f4bc63d8cc81747bf2685256c384e17450ca9c8 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 08:03:49 -0400
Subject: [PATCH 18/22] Fix some leaked memory that shows up in valgrind.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index d3448da..c8cb6fd 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -44,6 +44,7 @@
#include <unistd.h>
#include <getopt.h>
#include <efivar.h>
+#include <inttypes.h>
#include "list.h"
#include "efi.h"
#include "efichar.h"
@@ -283,7 +284,7 @@ static int
read_boot_order(efi_variable_t **boot_order)
{
int rc;
- efi_variable_t *new = NULL, *bo;
+ efi_variable_t *new = NULL, *bo = NULL;
if (*boot_order == NULL) {
new = calloc(1, sizeof (**boot_order));
@@ -299,12 +300,15 @@ read_boot_order(efi_variable_t **boot_order)
if (rc < 0 && new != NULL) {
free(new);
*boot_order = NULL;
+ bo = NULL;
}
- /* latest apple firmware sets high bit which appears invalid
- * to the linux kernel if we write it back so lets zero it out
- * if it is set since it would be invalid to set it anyway */
- bo->attributes = bo->attributes & ~(1 << 31);
+ if (bo) {
+ /* latest apple firmware sets high bit which appears invalid
+ * to the linux kernel if we write it back so lets zero it out
+ * if it is set since it would be invalid to set it anyway */
+ bo->attributes = bo->attributes & ~(1 << 31);
+ }
return rc;
}
@@ -401,11 +405,15 @@ read_boot_u16(const char *name)
if (rc < 0)
return rc;
if (data_size != 2) {
+ if (data != NULL)
+ free(data);
errno = EINVAL;
return -1;
}
rc = data[0];
+ if (data != NULL)
+ free(data);
return rc;
}
@@ -746,6 +754,11 @@ show_boot_order()
rc = read_boot_order(&boot_order);
+ if (rc < 0 && errno == ENOENT) {
+ boot_order = calloc(1, sizeof (*boot_order));
+ rc = boot_order ? 0 : -1;
+ }
+
if (rc < 0) {
perror("show_boot_order()");
return;
@@ -755,9 +768,11 @@ show_boot_order()
boot order. First add our entry, then copy the old array.
*/
data = (uint16_t *)boot_order->data;
- if (boot_order->data_size)
+ if (boot_order->data_size) {
unparse_boot_order(data, boot_order->data_size / sizeof(uint16_t));
-
+ free(boot_order->data);
+ }
+ free(boot_order);
}
static int
--
1.9.3

View File

@ -1,164 +0,0 @@
From 683831290c50f64d8964bef2a5d8d0092b32ca15 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 08:23:34 -0400
Subject: [PATCH 19/22] Add the ability to clean up duplicates in BootOrder
This adds -D (--remove-dups), which iterates BootOrder and keeps only
the first of any number it finds. Duplicate entries can happen as a
result of an interaction between fallback.efi and some system firmware,
and this option provides an easy workaround to fix it.
Resolves: rhbz#1097396
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-
src/include/efibootmgr.h | 1 +
src/man/man8/efibootmgr.8 | 5 +++-
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index c8cb6fd..40be505 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -347,6 +347,57 @@ add_to_boot_order(uint16_t num)
}
static int
+remove_dupes_from_boot_order(void)
+{
+ efi_variable_t *boot_order = NULL;
+ uint64_t new_data_size;
+ uint16_t *new_data, *old_data;
+ unsigned int old_i,new_i;
+ int rc;
+
+ rc = read_boot_order(&boot_order);
+ if (rc < 0)
+ return rc;
+
+ old_data = (uint16_t *)(boot_order->data);
+ /* Start with the same size */
+ new_data_size = boot_order->data_size;
+ new_data = malloc(new_data_size);
+ if (!new_data)
+ return -1;
+
+ unsigned int old_max = boot_order->data_size / sizeof(*new_data);
+ for (old_i = 0, new_i = 0; old_i < old_max; old_i++) {
+ int copies = 0;
+ unsigned int j;
+ for (j = 0; j < new_i; j++) {
+ if (new_data[j] == old_data[old_i]) {
+ copies++;
+ break;
+ }
+ }
+ if (copies == 0) {
+ /* Copy this value */
+ new_data[new_i] = old_data[old_i];
+ new_i++;
+ }
+ }
+ /* Adjust the size if we didn't copy everything. */
+ new_data_size = sizeof(new_data[0]) * new_i;
+
+ /* Now new_data has what we need */
+ free(boot_order->data);
+ boot_order->data = (uint8_t *)new_data;
+ boot_order->data_size = new_data_size;
+ efi_del_variable(EFI_GLOBAL_GUID, "BootOrder");
+ rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
+ boot_order->data_size, boot_order->attributes);
+ free(boot_order->data);
+ free(boot_order);
+ return rc;
+}
+
+static int
remove_from_boot_order(uint16_t num)
{
efi_variable_t *boot_order = NULL;
@@ -835,6 +886,7 @@ usage()
printf("\t-b | --bootnum XXXX modify BootXXXX (hex)\n");
printf("\t-B | --delete-bootnum delete bootnum (hex)\n");
printf("\t-c | --create create new variable bootnum and add to bootorder\n");
+ printf("\t-D | --remove-dups remove duplicate values from BootOrder\n");
printf("\t-d | --disk disk (defaults to /dev/sda) containing loader\n");
printf("\t-e | --edd [1|3|-1] force EDD 1.0 or 3.0 creation variables, or guess\n");
printf("\t-E | --device num EDD 1.0 device number (defaults to 0x80)\n");
@@ -894,6 +946,7 @@ parse_opts(int argc, char **argv)
{"bootnum", required_argument, 0, 'b'},
{"delete-bootnum", no_argument, 0, 'B'},
{"create", no_argument, 0, 'c'},
+ {"remove-dups", no_argument, 0, 'D'},
{"disk", required_argument, 0, 'd'},
{"iface", required_argument, 0, 'i'},
{"acpi_hid", required_argument, 0, 'H'},
@@ -923,7 +976,7 @@ parse_opts(int argc, char **argv)
};
c = getopt_long (argc, argv,
- "AaBb:cd:e:E:gH:i:l:L:n:No:Op:qt:TuU:v::Vw"
+ "AaBb:cDd:e:E:gH:i:l:L:n:No:Op:qt:TuU:v::Vw"
"@:h",
long_options, &option_index);
if (c == -1)
@@ -955,6 +1008,9 @@ parse_opts(int argc, char **argv)
case 'c':
opts.create = 1;
break;
+ case 'D':
+ opts.deduplicate = 1;
+ break;
case 'd':
opts.disk = optarg;
break;
@@ -1163,6 +1219,9 @@ main(int argc, char **argv)
ret = set_boot_order(opts.keep_old_entries);
}
+ if (opts.deduplicate) {
+ ret = remove_dupes_from_boot_order();
+ }
if (opts.delete_bootnext) {
ret = efi_del_variable(EFI_GLOBAL_GUID, "BootNext");
diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h
index 87c83bb..b978caf 100644
--- a/src/include/efibootmgr.h
+++ b/src/include/efibootmgr.h
@@ -40,6 +40,7 @@ typedef struct {
int bootnext;
int verbose;
int active;
+ int deduplicate;
int64_t acpi_hid;
int64_t acpi_uid;
unsigned int delete_boot:1;
diff --git a/src/man/man8/efibootmgr.8 b/src/man/man8/efibootmgr.8
index 61631df..5c0ea70 100644
--- a/src/man/man8/efibootmgr.8
+++ b/src/man/man8/efibootmgr.8
@@ -9,7 +9,7 @@
efibootmgr \- manipulate the EFI Boot Manager
.SH SYNOPSIS
-\fBefibootmgr\fR [ \fB-a\fR ] [ \fB-A\fR ] [ \fB-b \fIXXXX\fB\fR ] [ \fB-B \fIXXXX\fB\fR ] [ \fB-c\fR ] [ \fB-d \fIDISK\fB\fR ] [ \fB-e \fI1|3|-1\fB\fR ] [ \fB-E \fINUM\fB\fR ] [ \fB-g\fR ] [ \fB-H \fIXXXX\fB\fR ] [ \fB-i \fINAME\fB\fR ] [ \fB-l \fINAME\fB\fR ] [ \fB-L \fILABEL\fB\fR ] [ \fB-n \fIXXXX\fB\fR ] [ \fB-N\fR ] [ \fB-o \fIXXXX\fB,\fIYYYY\fB,\fIZZZZ\fB\fR\fI ...\fR ] [ \fB-O\fR ] [ \fB-p \fIPART\fB\fR ] [ \fB-q\fR ] [ \fB-t \fIseconds\fB\fR ] [ \fB-T\fR ] [ \fB-u\fR ] [ \fB-U \fIXXXX\fB\fR ] [ \fB-v\fR ] [ \fB-V\fR ] [ \fB-w\fR ] [ \fB-@ \fIfile\fB\fR ]
+\fBefibootmgr\fR [ \fB-a\fR ] [ \fB-A\fR ] [ \fB-b \fIXXXX\fB\fR ] [ \fB-B \fIXXXX\fB\fR ] [ \fB-c\fR ] [ \fB-d \fIDISK\fB\fR ] [ \fB-D\fR ] [ \fB-e \fI1|3|-1\fB\fR ] [ \fB-E \fINUM\fB\fR ] [ \fB-g\fR ] [ \fB-H \fIXXXX\fB\fR ] [ \fB-i \fINAME\fB\fR ] [ \fB-l \fINAME\fB\fR ] [ \fB-L \fILABEL\fB\fR ] [ \fB-n \fIXXXX\fB\fR ] [ \fB-N\fR ] [ \fB-o \fIXXXX\fB,\fIYYYY\fB,\fIZZZZ\fB\fR\fI ...\fR ] [ \fB-O\fR ] [ \fB-p \fIPART\fB\fR ] [ \fB-q\fR ] [ \fB-t \fIseconds\fB\fR ] [ \fB-T\fR ] [ \fB-u\fR ] [ \fB-U \fIXXXX\fB\fR ] [ \fB-v\fR ] [ \fB-V\fR ] [ \fB-w\fR ] [ \fB-@ \fIfile\fB\fR ]
.SH "DESCRIPTION"
.PP
@@ -51,6 +51,9 @@ Create new variable bootnum and add to bootorder
The disk containing the loader (defaults to
\fI/dev/sda\fR)
.TP
+\fB-D | --remove-dups\fR
+Remove duplicated entries from BootOrder
+.TP
\fB-e | --edd \fI1|3|-1\fB\fR
Force EDD 1.0 or 3.0 creation variables, or guess.
.TP
--
1.9.3

View File

@ -1,337 +0,0 @@
From e56d305380334d17bd0701fb5f8347542e293b14 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 08:36:49 -0400
Subject: [PATCH 20/22] Clean up some whitespace.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/include/efi.h | 2 +-
src/include/scsi_ioctls.h | 6 +++---
src/lib/disk.c | 42 ++++++++++++++++++------------------------
src/lib/efi.c | 6 +++---
src/lib/scsi_ioctls.c | 12 ++++++------
src/lib/unparse_path.c | 8 +++-----
6 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/src/include/efi.h b/src/include/efi.h
index 954b4a6..ec25be9 100644
--- a/src/include/efi.h
+++ b/src/include/efi.h
@@ -236,7 +236,7 @@ typedef struct {
uint32_t reserved;
uint64_t node_guid;
uint64_t ioc_guid;
- uint64_t id;
+ uint64_t id;
} __attribute__((packed)) INFINIBAND_DEVICE_PATH;
typedef struct {
diff --git a/src/include/scsi_ioctls.h b/src/include/scsi_ioctls.h
index 331bb14..d355534 100644
--- a/src/include/scsi_ioctls.h
+++ b/src/include/scsi_ioctls.h
@@ -1,8 +1,8 @@
/*
scsi_ioctls.[ch]
-
+
Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -19,7 +19,7 @@
*/
#ifndef _SCSI_IOCTLS_H
-#define _SCSI_IOCTLS_H
+#define _SCSI_IOCTLS_H
#include <stdint.h>
#include <stddef.h>
diff --git a/src/lib/disk.c b/src/lib/disk.c
index ad95fd4..904010b 100644
--- a/src/lib/disk.c
+++ b/src/lib/disk.c
@@ -1,8 +1,8 @@
/*
disk.[ch]
-
+
Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -179,7 +179,7 @@ disk_info_from_fd(int fd, struct disk_info *info)
info->part = info->minor & 0x3F;
return 0;
}
-
+
/* I2O disks can have up to 16 partitions, or 4 bits worth. */
if (info->major >= 80 && info->major <= 87) {
info->interface_type = i2o;
@@ -248,7 +248,7 @@ disk_get_virt_pci(const struct disk_info *info, unsigned char *bus,
}
static int
-disk_get_scsi_pci(int fd,
+disk_get_scsi_pci(int fd,
const struct disk_info *info,
unsigned char *bus,
unsigned char *device,
@@ -265,7 +265,7 @@ disk_get_scsi_pci(int fd,
return 1;
}
if (S_ISREG(buf.st_mode)) {
- /* can't call ioctl() on this file and have it succeed.
+ /* can't call ioctl() on this file and have it succeed.
* instead, need to open the block device
* from /dev/.
*/
@@ -320,13 +320,13 @@ disk_get_ide_pci(int fd,
char procname[80], infoline[80];
size_t read_count __attribute__((unused));
int rc;
-
+
rc = disk_info_from_fd(fd, &info);
if (rc) return rc;
sprintf(procname, "/proc/ide/ide%d/config", info.controllernum);
-
+
procfd = open(procname, O_RDONLY);
if (!procfd) {
perror("opening /proc/ide/ide*/config");
@@ -334,11 +334,11 @@ disk_get_ide_pci(int fd,
}
read_count = read(procfd, infoline, sizeof(infoline)-1);
close(procfd);
-
+
num_scanned = sscanf(infoline,
"pci bus %x device %x vid %*x did %*x channel %*x",
&b, &d);
-
+
if (num_scanned == 2) {
*bus = b;
*device = PCI_SLOT(d);
@@ -376,7 +376,7 @@ disk_get_pci(int fd,
break;
}
return 1;
-}
+}
int
disk_get_size(int fd, long *size)
@@ -441,12 +441,12 @@ msdos_disk_get_partition_info (int fd, legacy_mbr *mbr,
uint64_t *start, uint64_t *size,
char *signature,
uint8_t *mbr_type, uint8_t *signature_type)
-{
+{
int rc;
long disk_size=0;
struct stat stat;
struct timeval tv;
-
+
if (!mbr) return 1;
if (!is_mbr_valid(mbr)) return 1;
@@ -454,7 +454,6 @@ msdos_disk_get_partition_info (int fd, legacy_mbr *mbr,
*signature_type = 0x01;
if (!mbr->unique_mbr_signature && !opts.write_signature) {
-
printf("\n\n******************************************************\n");
printf("Warning! This MBR disk does not have a unique signature.\n");
printf("If this is not the first disk found by EFI, you may not be able\n");
@@ -462,14 +461,11 @@ msdos_disk_get_partition_info (int fd, legacy_mbr *mbr,
printf("Run efibootmgr with the -w flag to write a unique signature\n");
printf("to the disk.\n");
printf("******************************************************\n\n");
-
}
else if (!mbr->unique_mbr_signature && opts.write_signature) {
-
- /* MBR Signatures must be unique for the
+ /* MBR Signatures must be unique for the
EFI Boot Manager
to find the right disk to boot from */
-
rc = fstat(fd, &stat);
if (rc == -1) {
perror("stat disk");
@@ -479,19 +475,18 @@ msdos_disk_get_partition_info (int fd, legacy_mbr *mbr,
if (rc == -1) {
perror("gettimeofday");
}
-
+
/* Write the device type to the signature.
This should be unique per disk per system */
mbr->unique_mbr_signature = tv.tv_usec << 16;
mbr->unique_mbr_signature |= stat.st_rdev & 0xFFFF;
-
+
/* Write it to the disk */
lseek(fd, 0, SEEK_SET);
rc = write(fd, mbr, sizeof(*mbr));
}
*(uint32_t *)signature = mbr->unique_mbr_signature;
-
-
+
if (num > 4) {
/* Extended partition */
return msdos_disk_get_extended_partition_info(fd, mbr, num,
@@ -507,7 +502,6 @@ msdos_disk_get_partition_info (int fd, legacy_mbr *mbr,
/* Primary partition */
*start = mbr->partition[num-1].starting_lba;
*size = mbr->partition[num-1].size_in_lba;
-
}
return 0;
}
@@ -561,13 +555,13 @@ lcm(unsigned int x, unsigned int y)
* @signature - partition signature returned
* @mbr_type - partition type returned
* @signature_type - signature type returned
- *
+ *
* Description: Finds partition table info for given partition on given disk.
* Both GPT and MSDOS partition tables are tested for.
* Returns 0 on success, non-zero on failure
*/
int
-disk_get_partition_info (int fd,
+disk_get_partition_info (int fd,
uint32_t num,
uint64_t *start, uint64_t *size,
char *signature,
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 74df42a..133b8bb 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -611,7 +611,7 @@ static ssize_t
make_net_load_option(char *iface, uint8_t *buf, size_t size)
{
/* copied pretty much verbatim from the ethtool source */
- int fd = 0, err;
+ int fd = 0, err;
unsigned char bus, slot, func;
struct ifreq ifr;
struct ethtool_drvinfo drvinfo;
@@ -681,7 +681,7 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size)
return needed;
buf_offset += needed;
- needed = make_end_device_path(buf + buf_offset,
+ needed = make_end_device_path(buf + buf_offset,
size == 0 ? 0 : size - buf_offset);
if (needed < 0)
return needed;
@@ -857,7 +857,7 @@ append_extra_args_file(uint8_t **data, size_t *data_size)
ssize_t num_read=0;
unsigned long appended=0;
size_t maxchars = 0;
- char *buffer;
+ char *buffer;
if (!data) {
fprintf(stderr, "internal error\n");
diff --git a/src/lib/scsi_ioctls.c b/src/lib/scsi_ioctls.c
index c04f12a..3aaa933 100644
--- a/src/lib/scsi_ioctls.c
+++ b/src/lib/scsi_ioctls.c
@@ -1,8 +1,8 @@
/*
scsi_ioctls.[ch]
-
+
Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -41,7 +41,7 @@ idlun_to_components (Scsi_Idlun *idlun,
unsigned char *lun)
{
if (!idlun || !host || !channel || !id || !lun) return 1;
-
+
*host = (idlun->dev_id >> 24) & 0xFF;
*channel = (idlun->dev_id >> 16) & 0xFF;
*id = (idlun->dev_id ) & 0xFF;
@@ -56,7 +56,7 @@ get_scsi_idlun(int fd, Scsi_Idlun *idlun)
return ioctl(fd, SCSI_IOCTL_GET_IDLUN, idlun);
}
-int
+int
get_scsi_pci(int fd, char *slot_name, size_t size)
{
char buf[SLOT_NAME_SIZE] = "";
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
memset(&idlun, 0, sizeof(idlun));
if (argc < 2) {usage(argv); exit(1);}
-
+
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("Unable to open file");
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
if (rc) {
perror("Unable to get_scsi_idlun()");
}
-
+
printf("Device: %s\n", argv[1]);
printf("PCI: %s\n", slot_name);
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index b164758..431dc06 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -1,8 +1,8 @@
/*
unparse_path.[ch]
-
+
Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -582,7 +582,6 @@ main(int argc, char **argv)
exit(-1);
}
-
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("Failed to open file.");
@@ -595,8 +594,7 @@ main(int argc, char **argv)
exit(-1);
}
unparse_var(&var);
-
-
+
return 0;
}
#endif
--
1.9.3

View File

@ -1,32 +0,0 @@
From ecd7e9e84a63582c7a9b78cce5a2a1cfe5eb1f4b Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 08:44:46 -0400
Subject: [PATCH 21/22] Move TODO stuff to 0.9
Wound up doing some work that's more important than the stuff in the
TODO, so it's all getting moved out to 0.9
Signed-off-by: Peter Jones <pjones@redhat.com>
---
doc/TODO | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/TODO b/doc/TODO
index 8767c78..6340ac7 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,9 +1,10 @@
-For 0.8:
+For 0.9:
- support for setting hotkeys
- support for driver variables, not just boot variables.
- support for arbitrary device paths with -c (including guid parsing)
- audit for missing unparse_*_path() types.
+ - verify/debug NVME code
- maintain a list of known GUIDs and print {vendor} instead of the full GUID
- accept these for arbitrary paths as well.
- MS-DOS style extended partitions
--
1.9.3

View File

@ -1,45 +0,0 @@
From b1afcbbdcaf1c7b485e4e9273ff0d09580ff20df Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 1 Aug 2014 08:57:17 -0400
Subject: [PATCH 22/22] Fix some minor errors cppcheck found.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr/efibootmgr.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 40be505..5af2cad 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -933,7 +933,8 @@ set_default_opts()
static void
parse_opts(int argc, char **argv)
{
- int c, num, rc;
+ int c, rc;
+ unsigned int num;
int option_index = 0;
while (1)
@@ -1015,7 +1016,7 @@ parse_opts(int argc, char **argv)
opts.disk = optarg;
break;
case 'e':
- rc = sscanf(optarg, "%d", &num);
+ rc = sscanf(optarg, "%u", &num);
if (rc == 1) opts.edd_version = num;
else {
fprintf (stderr,"invalid numeric value %s\n",optarg);
@@ -1118,7 +1119,7 @@ parse_opts(int argc, char **argv)
if (optarg) {
if (!strcmp(optarg, "v")) opts.verbose = 2;
if (!strcmp(optarg, "vv")) opts.verbose = 3;
- rc = sscanf(optarg, "%d", &num);
+ rc = sscanf(optarg, "%u", &num);
if (rc == 1) opts.verbose = num;
else {
fprintf (stderr,"invalid numeric value %s\n",optarg);
--
1.9.3

View File

@ -1,7 +1,7 @@
Summary: EFI Boot Manager
Name: efibootmgr
Version: 0.7.0
Release: 5%{?dist}
Version: 0.9.0
Release: 1%{?dist}
Group: System Environment/Base
License: GPLv2+
URL: https://github.com/vathpela/%{name}/
@ -16,29 +16,8 @@ Requires: efivar-libs >= 0.8
Conflicts: elilo < 3.6-6
Obsoletes: elilo < 3.6-6
Source0: https://github.com/vathpela/%{name}/archive/%{name}-%{version}.tar.bz2
Patch0001: 0001-Filenames-and-github-the-worst-of-both-worlds.patch
Patch0002: 0002-Get-a-lot-more-picky-with-our-compiler-warnings.patch
Patch0003: 0003-Add-support-for-displaying-NVME-device-paths.patch
Patch0004: 0004-Make-nvme-work-with-e-3.patch
Patch0005: 0005-Remove-bogus-test-for-optional-data-length-bounds.patch
Patch0006: 0006-Only-free-hard-drive-signatures-if-we-ve-allocated-t.patch
Patch0007: 0007-We-don-t-actually-have-docbook-hooked-up-to-the-buil.patch
Patch0008: 0008-Mitigate-apple-setting-invalid-attribute-bits-in-boo.patch
Patch0009: 0009-Remove-unused-function-var_num_from_name.patch
Patch0010: 0010-Fix-typo-in-compare-function.patch
Patch0011: 0011-data_size-in-construct_boot_order-set_boot_order-is-.patch
Patch0012: 0012-Variable-needed-should-be-of-type-ssize_t-as-that-s-.patch
Patch0013: 0013-Clang-uses-C99-semantics-by-default-for-inline-keywo.patch
Patch0014: 0014-Use-PRIx64-in-nvme-parsing.patch
Patch0015: 0015-Compare-should-respect-the-size-of-the-data-it-compa.patch
Patch0016: 0016-Don-t-pass-around-a-format-specifier-when-we-don-t-n.patch
Patch0017: 0017-Don-t-leak-memory-in-remove_from_boot_order.patch
Patch0018: 0018-Fix-some-leaked-memory-that-shows-up-in-valgrind.patch
Patch0019: 0019-Add-the-ability-to-clean-up-duplicates-in-BootOrder.patch
Patch0020: 0020-Clean-up-some-whitespace.patch
Patch0021: 0021-Move-TODO-stuff-to-0.9.patch
Patch0022: 0022-Fix-some-minor-errors-cppcheck-found.patch
Source0: https://github.com/vathpela/%{name}/releases/download/%{name}-%{version}/%{name}-%{version}.tar.bz2
Patch0: 0001-Make-a-few-more-return-paths-print-some-modicum-of-e.patch
%description
%{name} displays and allows the user to edit the Intel Extensible
@ -49,7 +28,7 @@ http://developer.intel.com/technology/efi/efi.htm and http://uefi.org/.
%prep
%setup -q
git init
git config user.email "shim-owner@fedoraproject.org"
git config user.email "%{name}-owner@fedoraproject.org"
git config user.name "Fedora Ninjas"
git add .
git commit -a -q -m "%{version} baseline."
@ -75,6 +54,9 @@ rm -rf %{buildroot}
%doc README INSTALL COPYING
%changelog
* Tue Oct 14 2014 Peter Jones <pjones@redhat.com> - 0.9.0-1
- Update to 0.9.0
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

View File

@ -1 +1 @@
c973dd88352498f574c3dd8a43654cd2 efibootmgr-0.7.0.tar.bz2
cee2d8fd87cdc2ea4839455f00e38248 efibootmgr-0.9.0.tar.bz2