diff --git a/0001-Move-the-syntastic-file-I-use-out-of-the-repo.patch b/0001-Move-the-syntastic-file-I-use-out-of-the-repo.patch deleted file mode 100644 index a024d0c..0000000 --- a/0001-Move-the-syntastic-file-I-use-out-of-the-repo.patch +++ /dev/null @@ -1,56 +0,0 @@ -From d5f88bb1d594451733261d62eac4b4f97d39e3f4 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 12 Jun 2018 14:36:20 -0400 -Subject: [PATCH 01/34] Move the syntastic file I use out of the repo - -Signed-off-by: Peter Jones ---- - src/.syntastic_c_config | 36 ------------------------------------ - 1 file changed, 36 deletions(-) - delete mode 100644 src/.syntastic_c_config - -diff --git a/src/.syntastic_c_config b/src/.syntastic_c_config -deleted file mode 100644 -index 3f3f0ca67c7..00000000000 ---- a/src/.syntastic_c_config -+++ /dev/null -@@ -1,36 +0,0 @@ ---g3 ---Og ---Werror=format-security ---Wp,-D_FORTIFY_SOURCE=2 ---fexceptions ---fstack-protector-strong ----param=ssp-buffer-size=4 ---grecord-gcc-switches ---DFWUPDATE_HAVE_LIBSMBIOS__ ---Wall ---Wextra ---Werror ---Wno-error=cpp ---Wno-unused-result ---Wno-unused-function ---Wsign-compare ---Werror=sign-compare ---fshort-wchar ----std=gnu11 ---D_GNU_SOURCE ---Isrc/include ---Isrc/include/efivar ---Iinclude ---Iinclude/efivar ---fPIC ---fmath-errno ---fsigned-zeros ---ftrapping-math ---fno-trapv ---fno-openmp ---fno-openacc ---mtune=generic ---march=x86-64 ---flto ---fno-merge-constants ---fvisibility=hidden --- -2.17.1 - diff --git a/0002-Move-verbosity-headers-to-be-public.patch b/0002-Move-verbosity-headers-to-be-public.patch deleted file mode 100644 index e9c1b8e..0000000 --- a/0002-Move-verbosity-headers-to-be-public.patch +++ /dev/null @@ -1,53 +0,0 @@ -From daf3b6c6ae8a766f362c87dc80e40005428a1b2a Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 12 Jun 2018 14:36:20 -0400 -Subject: [PATCH 02/34] Move verbosity headers to be public - -Signed-off-by: Peter Jones ---- - src/include/efivar/efivar.h | 8 ++++++++ - src/util.h | 4 ---- - 2 files changed, 8 insertions(+), 4 deletions(-) - -diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h -index ddcc6771bdb..316891ccae9 100644 ---- a/src/include/efivar/efivar.h -+++ b/src/include/efivar/efivar.h -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -227,6 +228,13 @@ efi_error_clear(void) - #define efi_error_val(errval, msg, args...) \ - efi_error_real__(errval, __FILE__, __func__, __LINE__, (fmt), ## args) - -+extern void efi_set_verbose(int verbosity, FILE *errlog) -+ __attribute__((__visibility__("default"))); -+extern int efi_get_verbose(void) -+ __attribute__((__visibility__("default"))); -+extern FILE * efi_get_logfile(void) -+ __attribute__((__visibility__("default"))); -+ - #include - - #endif /* EFIVAR_H */ -diff --git a/src/util.h b/src/util.h -index 96ca66bd54d..cc5f669e6ec 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -369,8 +369,4 @@ swizzle_guid_to_uuid(efi_guid_t *guid) - - #define DEBUG 1 - --extern void PUBLIC efi_set_verbose(int verbosity, FILE *errlog); --extern int PUBLIC efi_get_verbose(void); --extern FILE PUBLIC *efi_get_logfile(void); -- - #endif /* EFIVAR_UTIL_H */ --- -2.17.1 - diff --git a/0003-Pacify-some-coverity-nits.patch b/0003-Pacify-some-coverity-nits.patch deleted file mode 100644 index 9fd863c..0000000 --- a/0003-Pacify-some-coverity-nits.patch +++ /dev/null @@ -1,45 +0,0 @@ -From bd609a59369574c95f7f31b15caae8bb86b71f39 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 12 Jun 2018 14:36:20 -0400 -Subject: [PATCH 03/34] Pacify some coverity nits. - -Coverity has trouble tracking data flow sometimes, and believes that -sysfs_readlink() and read_sysfs_file() will sometimes return >= 0 when -the buffer has not been filled out. This changes the check to also test -for a NULL pointer, hopefully pacifying it. - -Signed-off-by: Peter Jones ---- - src/linux-pci.c | 2 +- - src/linux.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/linux-pci.c b/src/linux-pci.c -index 87878c39c94..0d2a90ab166 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -166,7 +166,7 @@ parse_pci(struct device *dev, const char *current) - tmp[devpart - current] = '\0'; - rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp); - free(tmp); -- if (rc < 0) { -+ if (rc < 0 || !linkbuf) { - efi_error("Could not find driver for pci device"); - return -1; - } -diff --git a/src/linux.c b/src/linux.c -index c8d1b3a9285..fe45c6004b9 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -356,7 +356,7 @@ struct device HIDDEN - - if (dev->part == -1) { - rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link); -- if (rc < 0) { -+ if (rc < 0 || !tmpbuf) { - efi_error("device has no /partition node; not a partition"); - } else { - rc = sscanf((char *)tmpbuf, "%d\n", &dev->part); --- -2.17.1 - diff --git a/0004-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch b/0004-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch deleted file mode 100644 index 6985420..0000000 --- a/0004-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 4becb1303fee8bd7b377292c74589d6ec69009ae Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 12 Jun 2018 14:36:20 -0400 -Subject: [PATCH 04/34] efivar: Fix some types in -L behavior to pacify - coverity. - -Coverity doesn't realize that efi_well_known_guids is /actually/ an -array, because we didn't tell it so. So fix the declaration so we've -told it so. - -Signed-off-by: Peter Jones ---- - src/efivar.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/efivar.c b/src/efivar.c -index 9ee3b397e29..228bdb745a7 100644 ---- a/src/efivar.c -+++ b/src/efivar.c -@@ -485,13 +485,13 @@ int main(int argc, char *argv[]) - case ACTION_LIST_GUIDS: { - efi_guid_t sentinal = {0xffffffff,0xffff,0xffff,0xffff, - {0xff,0xff,0xff,0xff,0xff,0xff}}; -- extern struct guidname efi_well_known_guids; -+ extern struct guidname efi_well_known_guids[]; - extern struct guidname efi_well_known_guids_end; - intptr_t start = (intptr_t)&efi_well_known_guids; - intptr_t end = (intptr_t)&efi_well_known_guids_end; - unsigned int i; - -- struct guidname *guid = &efi_well_known_guids; -+ struct guidname *guid = &efi_well_known_guids[0]; - for (i = 0; i < (end-start) / sizeof(*guid); i++) { - if (!efi_guid_cmp(&sentinal, &guid[i].guid)) - break; --- -2.17.1 - diff --git a/0005-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch b/0005-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch deleted file mode 100644 index 783dab2..0000000 --- a/0005-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch +++ /dev/null @@ -1,88 +0,0 @@ -From bd8fc0ebe86da82468b40a4998c3000819e73afe Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 12 Jun 2018 14:36:20 -0400 -Subject: [PATCH 05/34] Promote _make_hd_dn() to make_hd_dn() and get rid of - the wrapper. - -The wrapper is just hiding what the code's doing, and all the other code -around where we use it does the same thing anyway. This hopefully -convinces coverity we're not really dereferencing "buf" there unless -it's nonzero. - -Signed-off-by: Peter Jones ---- - src/creator.c | 3 ++- - src/disk.c | 4 ++-- - src/dp-media.c | 2 ++ - src/disk.h | 7 ++----- - 4 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/src/creator.c b/src/creator.c -index 93f185fc0bc..76c1c1f7a99 100644 ---- a/src/creator.c -+++ b/src/creator.c -@@ -281,7 +281,8 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - goto err; - } - -- sz = make_hd_dn(buf, size, off, disk_fd, dev->part, options); -+ sz = make_hd_dn(buf+off, size?size-off:0, -+ disk_fd, dev->part, options); - saved_errno = errno; - close(disk_fd); - errno = saved_errno; -diff --git a/src/disk.c b/src/disk.c -index deac512cf71..3efee03b804 100644 ---- a/src/disk.c -+++ b/src/disk.c -@@ -257,8 +257,8 @@ is_partitioned(int fd) - } - - ssize_t HIDDEN --_make_hd_dn(uint8_t *buf, ssize_t size, int fd, int32_t partition, -- uint32_t options) -+make_hd_dn(uint8_t *buf, ssize_t size, int fd, int32_t partition, -+ uint32_t options) - { - uint64_t part_start=0, part_size = 0; - uint8_t signature[16]="", format=0, signature_type=0; -diff --git a/src/dp-media.c b/src/dp-media.c -index 0a0993ec3f4..cec6b8bb58d 100644 ---- a/src/dp-media.c -+++ b/src/dp-media.c -@@ -161,6 +161,7 @@ efidp_make_file(uint8_t *buf, ssize_t size, char *filepath) - ssize_t sz; - ssize_t len = utf8len(lf, -1) + 1; - ssize_t req = sizeof (*file) + len * sizeof (uint16_t); -+ - sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_FILE, - req); - if (size && sz == req) { -@@ -182,6 +183,7 @@ efidp_make_hd(uint8_t *buf, ssize_t size, uint32_t num, uint64_t part_start, - efidp_hd *hd = (efidp_hd *)buf; - ssize_t sz; - ssize_t req = sizeof (*hd); -+ - sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_HD, - req); - if (size && sz == req) { -diff --git a/src/disk.h b/src/disk.h -index c040cc92a91..f0fa7f9f42d 100644 ---- a/src/disk.h -+++ b/src/disk.h -@@ -23,10 +23,7 @@ - - extern bool HIDDEN is_partitioned(int fd); - --extern HIDDEN ssize_t _make_hd_dn(uint8_t *buf, ssize_t size, int fd, -- int32_t partition, uint32_t options); --#define make_hd_dn(buf, size, off, fd, partition, option) \ -- _make_hd_dn(((buf)+(off)), ((size)?((size)-(off)):0), (fd),\ -- (partition), (options)) -+extern HIDDEN ssize_t make_hd_dn(uint8_t *buf, ssize_t size, int fd, -+ int32_t partition, uint32_t options); - - #endif /* _EFIBOOT_DISK_H */ --- -2.17.1 - diff --git a/0006-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch b/0006-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch deleted file mode 100644 index 7dc47df..0000000 --- a/0006-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 5e2174acaf1a51ead0a079776229e0df89c7fd81 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 13 Jun 2018 09:15:17 -0400 -Subject: [PATCH 06/34] Try to convince covscan that sysfs_read_file() doesn't - leak on error. - -Basically, covscan gets confused about some of our return paths and -doesn't think the error condition correlates with not having allocated -(or having freed) the ram we're using to pass the file data back. - -Signed-off-by: Peter Jones ---- - src/linux.h | 5 +++++ - src/util.h | 38 ++++++++++++++++++++------------------ - 2 files changed, 25 insertions(+), 18 deletions(-) - -diff --git a/src/linux.h b/src/linux.h -index 2f9eb0fe66f..39826224a53 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -173,6 +173,11 @@ extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size, - free(buf_); \ - *(buf) = (__typeof__(*(buf)))buf2_; \ - errno = error_; \ -+ } else if (buf_) { \ -+ /* covscan is _sure_ we leak buf_ if bufsize_ */\ -+ /* is <= 0, which is wrong, but appease it. */\ -+ free(buf_); \ -+ buf_ = NULL; \ - } \ - bufsize_; \ - }) -diff --git a/src/util.h b/src/util.h -index cc5f669e6ec..ef85a4c277e 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -149,22 +149,24 @@ - #endif - - static inline int UNUSED --read_file(int fd, uint8_t **buf, size_t *bufsize) -+read_file(int fd, uint8_t **result, size_t *bufsize) - { - uint8_t *p; - size_t size = 4096; - size_t filesize = 0; - ssize_t s = 0; -+ uint8_t *buf, *newbuf; - -- uint8_t *newbuf; - if (!(newbuf = calloc(size, sizeof (uint8_t)))) { - efi_error("could not allocate memory"); -+ *result = buf = NULL; -+ *bufsize = 0; - return -1; - } -- *buf = newbuf; -+ buf = newbuf; - - do { -- p = *buf + filesize; -+ p = buf + filesize; - /* size - filesize shouldn't exceed SSIZE_MAX because we're - * only allocating 4096 bytes at a time and we're checking that - * before doing so. */ -@@ -179,8 +181,8 @@ read_file(int fd, uint8_t **buf, size_t *bufsize) - continue; - } else if (s < 0) { - int saved_errno = errno; -- free(*buf); -- *buf = NULL; -+ free(buf); -+ *result = buf = NULL; - *bufsize = 0; - errno = saved_errno; - efi_error("could not read from file"); -@@ -194,38 +196,38 @@ read_file(int fd, uint8_t **buf, size_t *bufsize) - /* See if we're going to overrun and return an error - * instead. */ - if (size > (size_t)-1 - 4096) { -- free(*buf); -- *buf = NULL; -+ free(buf); -+ *result = buf = NULL; - *bufsize = 0; - errno = ENOMEM; - efi_error("could not read from file"); - return -1; - } -- newbuf = realloc(*buf, size + 4096); -+ newbuf = realloc(buf, size + 4096); - if (newbuf == NULL) { - int saved_errno = errno; -- free(*buf); -- *buf = NULL; -+ free(buf); -+ *result = buf = NULL; - *bufsize = 0; - errno = saved_errno; - efi_error("could not allocate memory"); - return -1; - } -- *buf = newbuf; -- memset(*buf + size, '\0', 4096); -+ buf = newbuf; -+ memset(buf + size, '\0', 4096); - size += 4096; - } - } while (1); - -- newbuf = realloc(*buf, filesize+1); -+ newbuf = realloc(buf, filesize+1); - if (!newbuf) { -- free(*buf); -- *buf = NULL; -+ free(buf); -+ *result = buf = NULL; - efi_error("could not allocate memory"); - return -1; - } - newbuf[filesize] = '\0'; -- *buf = newbuf; -+ *result = newbuf; - *bufsize = filesize+1; - return 0; - } -@@ -329,7 +331,7 @@ get_file(uint8_t **result, const char * const fmt, ...) - close(fd); - errno = error; - -- if (rc < 0) { -+ if (rc < 0 || bufsize < 1) { - efi_error("could not read file \"%s\"", path); - return -1; - } --- -2.17.1 - diff --git a/0007-Make-efidp_make_file-have-even-more-better-input-con.patch b/0007-Make-efidp_make_file-have-even-more-better-input-con.patch deleted file mode 100644 index f50af84..0000000 --- a/0007-Make-efidp_make_file-have-even-more-better-input-con.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 9bc1e24859630c933410bfb77658bd69ee400e16 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 13 Jun 2018 09:25:58 -0400 -Subject: [PATCH 07/34] Make efidp_make_file() have even more, better input - constraints. - -This is all in the effort to convince coverity that it doesn't -dereference buf when size==0, which it already doesn't. - -Signed-off-by: Peter Jones ---- - src/dp-media.c | 6 ++++++ - src/dp.c | 10 +++++++++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/src/dp-media.c b/src/dp-media.c -index cec6b8bb58d..96a576fdc2a 100644 ---- a/src/dp-media.c -+++ b/src/dp-media.c -@@ -162,6 +162,12 @@ efidp_make_file(uint8_t *buf, ssize_t size, char *filepath) - ssize_t len = utf8len(lf, -1) + 1; - ssize_t req = sizeof (*file) + len * sizeof (uint16_t); - -+ if (len == 0) { -+ errno = EINVAL; -+ efi_error("%s() called with %s file path", __func__, -+ filepath == NULL ? "NULL" : "empty"); -+ return -1; -+ } - sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_FILE, - req); - if (size && sz == req) { -diff --git a/src/dp.c b/src/dp.c -index 4e76e25b1a1..82d60b4f9be 100644 ---- a/src/dp.c -+++ b/src/dp.c -@@ -443,9 +443,17 @@ efidp_make_generic(uint8_t *buf, ssize_t size, uint8_t type, uint8_t subtype, - - if (!size) - return total_size; -+ -+ if (!buf) { -+ errno = EINVAL; -+ efi_error("%s was called with nonzero size and NULL buffer", -+ __func__); -+ return -1; -+ } -+ - if (size < total_size) { -+ errno = ENOSPC; - efi_error("total size is bigger than size limit"); -- errno = ENOSPC; - return -1; - } - --- -2.17.1 - diff --git a/0008-Make-path-helpers.c-also-import-fix_coverity.h.patch b/0008-Make-path-helpers.c-also-import-fix_coverity.h.patch deleted file mode 100644 index 8e18612..0000000 --- a/0008-Make-path-helpers.c-also-import-fix_coverity.h.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 025f791b57c988d33249c5c33250229fa0e7e8f1 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 14 Jun 2018 12:15:03 -0400 -Subject: [PATCH 08/34] Make path-helpers.c also import fix_coverity.h - -Signed-off-by: Peter Jones ---- - src/path-helpers.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/path-helpers.c b/src/path-helpers.c -index 1de00860d92..1b328071587 100644 ---- a/src/path-helpers.c -+++ b/src/path-helpers.c -@@ -16,6 +16,7 @@ - * License along with this library; if not, see - * . - */ -+#include "fix_coverity.h" - - #include "efivar.h" - --- -2.17.1 - diff --git a/0009-Fix-a-makeguids-building-problem-with-generics.h.patch b/0009-Fix-a-makeguids-building-problem-with-generics.h.patch deleted file mode 100644 index 1cc44aa..0000000 --- a/0009-Fix-a-makeguids-building-problem-with-generics.h.patch +++ /dev/null @@ -1,34 +0,0 @@ -From bf5225b0445cc1b7b69c2a80162d3c1b514a27cf Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 14:12:42 -0400 -Subject: [PATCH 09/34] Fix a makeguids building problem with generics.h. - -Guard generics.h with EFIVAR_BUILD_ENVIRONMENT to keep it from -interfering with the makeguids build if libefivar.so isn't around -already. - -Signed-off-by: Peter Jones ---- - src/generics.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/generics.h b/src/generics.h -index e6af2fad79e..66be4bd76ab 100644 ---- a/src/generics.h -+++ b/src/generics.h -@@ -17,6 +17,7 @@ - * - */ - -+#ifndef EFIVAR_BUILD_ENVIRONMENT - #ifndef LIBEFIVAR_GENERIC_NEXT_VARIABLE_NAME_H - #define LIBEFIVAR_GENERIC_NEXT_VARIABLE_NAME_H 1 - -@@ -182,3 +183,4 @@ generic_append_variable(efi_guid_t guid, const char *name, - } - - #endif /* LIBEFIVAR_GENERIC_NEXT_VARIABLE_NAME_H */ -+#endif /* EFIVAR_BUILD_ENVIRONMENT */ --- -2.17.1 - diff --git a/0010-Improve-ACPI-device-path-formatting.patch b/0010-Improve-ACPI-device-path-formatting.patch deleted file mode 100644 index bf4c60d..0000000 --- a/0010-Improve-ACPI-device-path-formatting.patch +++ /dev/null @@ -1,402 +0,0 @@ -From eb7db33c6cf4172551fe0f9f7cf4aa047dc16d88 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 14:27:11 -0400 -Subject: [PATCH 10/34] Improve ACPI device path formatting - -This factors a bunch of the duplication out to another function, which -also does a better job of it. - -Signed-off-by: Peter Jones ---- - src/dp-acpi.c | 296 ++++++++++++++++++--------------- - src/include/efivar/efivar-dp.h | 2 +- - 2 files changed, 159 insertions(+), 139 deletions(-) - -diff --git a/src/dp-acpi.c b/src/dp-acpi.c -index 70162f320dc..a49ef38488c 100644 ---- a/src/dp-acpi.c -+++ b/src/dp-acpi.c -@@ -44,6 +44,59 @@ _format_acpi_adr(char *buf, size_t size, - #define format_acpi_adr(buf, size, off, dp) \ - format_helper(_format_acpi_adr, buf, size, off, "AcpiAdr", dp) - -+static ssize_t -+_format_acpi_hid_ex(char *buf, size_t size, const char *dp_type UNUSED, -+ const_efidp dp, -+ const char *hidstr, const char *cidstr, const char *uidstr) -+{ -+ ssize_t off = 0; -+ -+ debug(DEBUG, "hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr); -+ debug(DEBUG, "cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr); -+ debug(DEBUG, "uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr); -+ -+ if (!hidstr && !cidstr && (uidstr || dp->acpi_hid_ex.uid)) { -+ format(buf, size, off, "AcpiExp", -+ "AcpiExp(0x%"PRIx32",0x%"PRIx32",", -+ dp->acpi_hid_ex.hid, dp->acpi_hid_ex.cid); -+ if (uidstr) { -+ format(buf, size, off, "AcpiExp", "%s)", uidstr); -+ } else { -+ format(buf, size, off, "AcpiExp", "0x%"PRIx32")", -+ dp->acpi_hid_ex.uid); -+ } -+ return off; -+ } -+ -+ format(buf, size, off, "AcpiEx", "AcpiEx("); -+ if (hidstr) { -+ format(buf, size, off, "AcpiEx", "%s,", hidstr); -+ } else { -+ format(buf, size, off, "AcpiEx", "0x%"PRIx32",", -+ dp->acpi_hid_ex.hid); -+ } -+ -+ if (cidstr) { -+ format(buf, size, off, "AcpiEx", "%s,", cidstr); -+ } else { -+ format(buf, size, off, "AcpiEx", "0x%"PRIx32",", -+ dp->acpi_hid_ex.cid); -+ } -+ -+ if (uidstr) { -+ format(buf, size, off, "AcpiEx", "%s)", uidstr); -+ } else { -+ format(buf, size, off, "AcpiEx", "0x%"PRIx32")", -+ dp->acpi_hid_ex.uid); -+ } -+ -+ return off; -+} -+ -+#define format_acpi_hid_ex(buf, size, off, dp, hidstr, cidstr, uidstr) \ -+ format_helper(_format_acpi_hid_ex, buf, size, off, "AcpiEx", dp,\ -+ hidstr, cidstr, uidstr) -+ - ssize_t - _format_acpi_dn(char *buf, size_t size, const_efidp dp) - { -@@ -53,13 +106,15 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - const char *uidstr = NULL; - size_t uidlen = 0; - const char *cidstr = NULL; -- size_t cidlen = 0; -+ // size_t cidlen = 0; - - if (dp->subtype == EFIDP_ACPI_ADR) { -+ debug(DEBUG, "formatting ACPI _ADR"); - format_acpi_adr(buf, size, off, dp); - return off; - } else if (dp->subtype != EFIDP_ACPI_HID_EX && - dp->subtype != EFIDP_ACPI_HID) { -+ debug(DEBUG, "DP subtype %d, formatting as ACPI Path", dp->subtype); - format(buf, size, off, "AcpiPath", "AcpiPath(%d,", dp->subtype); - format_hex(buf, size, off, "AcpiPath", (uint8_t *)dp+4, - (efidp_node_size(dp)-4) / 2); -@@ -69,6 +124,7 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - ssize_t limit = efidp_node_size(dp) - - offsetof(efidp_acpi_hid_ex, hidstr); - -+ debug(DEBUG, "formatting ACPI HID EX"); - hidstr = dp->acpi_hid_ex.hidstr; - hidlen = strnlen(hidstr, limit); - limit -= hidlen + 1; -@@ -81,7 +137,7 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - - if (limit) { - cidstr = uidstr + uidlen + 1; -- cidlen = strnlen(cidstr, limit); -+ // cidlen = strnlen(cidstr, limit); - // limit -= cidlen + 1; - } - -@@ -96,143 +152,102 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - "PcieRoot(%s)", uidstr); - return off; - default: -- format(buf, size, off, "AcpiEx", "AcpiEx("); -- if (hidlen) -- format(buf, size, off, "AcpiEx", "%s", -- hidstr); -- else -- format(buf, size, off, "AcpiEx", "0x%"PRIx32, -- dp->acpi_hid_ex.hid); -- if (cidlen) -- format(buf, size, off, "AcpiEx", ",%s", -- cidstr); -- else -- format(buf, size, off, "AcpiEx", ",0x%"PRIx32, -- dp->acpi_hid_ex.cid); -- if (uidlen) -- format(buf, size, off, "AcpiEx", ",%s", -- uidstr); -- else -- format(buf, size, off, "AcpiEx", ",0x%"PRIx32, -- dp->acpi_hid_ex.uid); -- format(buf, size, off, "AcpiEx", ")"); -- break; -+ format_acpi_hid_ex(buf, size, off, dp, -+ hidstr, cidstr, uidstr); -+ return off; - } - } -- } -- -- switch (dp->acpi_hid.hid) { -- case EFIDP_ACPI_PCI_ROOT_HID: -- format(buf, size, off, "PciRoot", "PciRoot(0x%"PRIx32")", -- dp->acpi_hid.uid); -- break; -- case EFIDP_ACPI_PCIE_ROOT_HID: -- format(buf, size, off, "PcieRoot", "PcieRoot(0x%"PRIx32")", -- dp->acpi_hid.uid); -- break; -- case EFIDP_ACPI_FLOPPY_HID: -- format(buf, size, off, "Floppy", "Floppy(0x%"PRIx32")", -- dp->acpi_hid.uid); -- break; -- case EFIDP_ACPI_KEYBOARD_HID: -- format(buf, size, off, "Keyboard", "Keyboard(0x%"PRIx32")", -- dp->acpi_hid.uid); -- break; -- case EFIDP_ACPI_SERIAL_HID: -- format(buf, size, off, "Keyboard", "Serial(0x%"PRIx32")", -- dp->acpi_hid.uid); -- break; -- case EFIDP_ACPI_NVDIMM_HID: { -- int rc; -- const_efidp next = NULL; -- efidp_acpi_adr *adrdp; -- int end; -- -- format(buf, size, off, "NvRoot()", "NvRoot()"); -- -- rc = efidp_next_node(dp, &next); -- if (rc < 0 || !next) { -- efi_error("could not format DP"); -- return rc; -- } -+ } else if (dp->subtype == EFIDP_ACPI_HID_EX) { -+ switch (dp->acpi_hid.hid) { -+ case EFIDP_ACPI_PCI_ROOT_HID: -+ format(buf, size, off, "PciRoot", -+ "PciRoot(0x%"PRIx32")", -+ dp->acpi_hid.uid); -+ break; -+ case EFIDP_ACPI_PCIE_ROOT_HID: -+ format(buf, size, off, "PcieRoot", -+ "PcieRoot(0x%"PRIx32")", -+ dp->acpi_hid.uid); -+ break; -+ case EFIDP_ACPI_FLOPPY_HID: -+ format(buf, size, off, "Floppy", -+ "Floppy(0x%"PRIx32")", -+ dp->acpi_hid.uid); -+ break; -+ case EFIDP_ACPI_KEYBOARD_HID: -+ format(buf, size, off, "Keyboard", -+ "Keyboard(0x%"PRIx32")", -+ dp->acpi_hid.uid); -+ break; -+ case EFIDP_ACPI_SERIAL_HID: -+ format(buf, size, off, "Serial", -+ "Serial(0x%"PRIx32")", -+ dp->acpi_hid.uid); -+ break; -+ case EFIDP_ACPI_NVDIMM_HID: { -+ int rc; -+ const_efidp next = NULL; -+ efidp_acpi_adr *adrdp; -+ int end; - -- if (efidp_type(next) != EFIDP_ACPI_TYPE || -- efidp_subtype(next) != EFIDP_ACPI_ADR) { -- efi_error("Invalid child node type (0x%02x,0x%02x)", -- efidp_type(next), efidp_subtype(next)); -- return -EINVAL; -- } -- adrdp = (efidp_acpi_adr *)next; -+ format(buf, size, off, "NvRoot()", "NvRoot()"); - -- end = efidp_size_after(adrdp, header) -- / sizeof(adrdp->adr[0]); -+ rc = efidp_next_node(dp, &next); -+ if (rc < 0 || !next) { -+ efi_error("could not format DP"); -+ return rc; -+ } - -- for (int i = 0; i < end; i++) { -- uint32_t node_controller, socket, memory_controller; -- uint32_t memory_channel, dimm; -- uint32_t adr = adrdp->adr[i]; -+ if (efidp_type(next) != EFIDP_ACPI_TYPE || -+ efidp_subtype(next) != EFIDP_ACPI_ADR) { -+ efi_error("Invalid child node type (0x%02x,0x%02x)", -+ efidp_type(next), efidp_subtype(next)); -+ return -EINVAL; -+ } -+ adrdp = (efidp_acpi_adr *)next; - -- efidp_decode_acpi_nvdimm_adr(adr, &node_controller, -- &socket, -- &memory_controller, -- &memory_channel, &dimm); -+ end = efidp_size_after(adrdp, header) -+ / sizeof(adrdp->adr[0]); - -- if (i != 0) -- format(buf, size, off, "NvDimm", ","); -+ for (int i = 0; i < end; i++) { -+ uint32_t node_controller, socket, memory_controller; -+ uint32_t memory_channel, dimm; -+ uint32_t adr = adrdp->adr[i]; - -- format(buf, size, off, "NvDimm", -- "NvDimm(0x%03x,0x%01x,0x%01x,0x%01x,0x%01x)", -- node_controller, socket, memory_controller, -- memory_channel, dimm); -- } -- break; -- } -- default: -- switch (dp->subtype) { -- case EFIDP_ACPI_HID_EX: -- if (!hidstr && !cidstr && -- (uidstr || dp->acpi_hid_ex.uid)){ -- format(buf, size, off, "AcpiExp", -- "AcpiExp(0x%"PRIx32",0x%"PRIx32",", -- dp->acpi_hid_ex.hid, -- dp->acpi_hid_ex.cid); -- if (uidstr) { -- format(buf, size, off, "AcpiExp", -- "%s)", uidstr); -- } else { -- format(buf, size, off, "AcpiExp", -- "0x%"PRIx32")", -- dp->acpi_hid.uid); -- } -- break; -- } -- format(buf, size, off, "AcpiEx", "AcpiEx("); -- if (hidstr) { -- format(buf, size, off, "AcpiEx", "%s,", hidstr); -- } else { -- format(buf, size, off, "AcpiEx", "0x%"PRIx32",", -- dp->acpi_hid.hid); -- } -+ efidp_decode_acpi_nvdimm_adr(adr, -+ &node_controller, &socket, -+ &memory_controller, &memory_channel, -+ &dimm); - -- if (cidstr) { -- format(buf, size, off, "AcpiEx", "%s,", cidstr); -- } else { -- format(buf, size, off, "AcpiEx", "0x%"PRIx32",", -- dp->acpi_hid_ex.cid); -- } -+ if (i != 0) -+ format(buf, size, off, "NvDimm", ","); - -- if (uidstr) { -- format(buf, size, off, "AcpiEx", "%s)", uidstr); -- } else { -- format(buf, size, off, "AcpiEx", "0x%"PRIx32")", -- dp->acpi_hid.uid); -+ format(buf, size, off, "NvDimm", -+ "NvDimm(0x%03x,0x%01x,0x%01x,0x%01x,0x%01x)", -+ node_controller, socket, memory_controller, -+ memory_channel, dimm); - } - break; -- case EFIDP_ACPI_HID: -- format(buf, size, off, "Acpi", -- "Acpi(0x%"PRIx32",0x%"PRIx32")", -- dp->acpi_hid.hid, dp->acpi_hid.uid); -- break; -+ } -+ default: -+ debug(DEBUG, "Decoding non-well-known HID"); -+ switch (dp->subtype) { -+ case EFIDP_ACPI_HID_EX: -+ format_acpi_hid_ex(buf, size, off, dp, -+ hidstr, cidstr, uidstr); -+ break; -+ case EFIDP_ACPI_HID: -+ debug(DEBUG, "Decoding ACPI HID"); -+ format(buf, size, off, "Acpi", -+ "Acpi(0x%08x,0x%"PRIx32")", -+ dp->acpi_hid.hid, dp->acpi_hid.uid); -+ break; -+ default: -+ debug(DEBUG, "ACPI subtype %d???", -+ dp->subtype); -+ errno = EINVAL; -+ return -1; -+ } - } - } - -@@ -259,7 +274,7 @@ efidp_make_acpi_hid(uint8_t *buf, ssize_t size, uint32_t hid, uint32_t uid) - return sz; - } - --ssize_t PUBLIC NONNULL(6, 7, 8) -+ssize_t PUBLIC - efidp_make_acpi_hid_ex(uint8_t *buf, ssize_t size, - uint32_t hid, uint32_t uid, uint32_t cid, - const char *hidstr, const char *uidstr, -@@ -268,21 +283,26 @@ efidp_make_acpi_hid_ex(uint8_t *buf, ssize_t size, - efidp_acpi_hid_ex *acpi_hid = (efidp_acpi_hid_ex *)buf; - ssize_t req; - ssize_t sz; -+ size_t hidlen = hidstr ? strlen(hidstr) : 0; -+ size_t uidlen = uidstr ? strlen(uidstr) : 0; -+ size_t cidlen = cidstr ? strlen(cidstr) : 0; - -- req = sizeof (*acpi_hid) + 3 + -- strlen(hidstr) + strlen(uidstr) + strlen(cidstr); -+ req = sizeof (*acpi_hid) + 3 + hidlen + uidlen + cidlen; - sz = efidp_make_generic(buf, size, EFIDP_ACPI_TYPE, EFIDP_ACPI_HID_EX, - req); - if (size && sz == req) { -- acpi_hid->uid = uid; -- acpi_hid->hid = hid; -- acpi_hid->cid = cid; -+ acpi_hid->hid = hidlen ? 0 : hid; -+ acpi_hid->uid = uidlen ? 0 : uid; -+ acpi_hid->cid = cidlen ? 0 : cid; - char *next = (char *)buf+offsetof(efidp_acpi_hid_ex, hidstr); -- strcpy(next, hidstr); -- next += strlen(hidstr) + 1; -- strcpy(next, uidstr); -- next += strlen(uidstr) + 1; -- strcpy(next, cidstr); -+ if (hidlen) -+ strcpy(next, hidstr); -+ next += hidlen + 1; -+ if (uidlen) -+ strcpy(next, uidstr); -+ next += uidlen + 1; -+ if (cidlen) -+ strcpy(next, cidstr); - } - - if (sz < 0) -diff --git a/src/include/efivar/efivar-dp.h b/src/include/efivar/efivar-dp.h -index 106d3645e21..1b05775ae7e 100644 ---- a/src/include/efivar/efivar-dp.h -+++ b/src/include/efivar/efivar-dp.h -@@ -133,7 +133,7 @@ typedef struct { - /* three ascii string fields follow */ - char hidstr[]; - } EFIVAR_PACKED efidp_acpi_hid_ex; --extern ssize_t __attribute__((__nonnull__ (6,7,8))) -+extern ssize_t - efidp_make_acpi_hid_ex(uint8_t *buf, ssize_t size, - uint32_t hid, uint32_t uid, uint32_t cid, - const char *hidstr, const char *uidstr, --- -2.17.1 - diff --git a/0011-Give-linux-s-parse-functions-the-unmodified-device-l.patch b/0011-Give-linux-s-parse-functions-the-unmodified-device-l.patch deleted file mode 100644 index c6c079a..0000000 --- a/0011-Give-linux-s-parse-functions-the-unmodified-device-l.patch +++ /dev/null @@ -1,177 +0,0 @@ -From ba0655c62978ba64c227f1f87d9da3e1dea4f821 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 14:37:14 -0400 -Subject: [PATCH 11/34] Give linux-*'s ->parse() functions the unmodified - device link as well - -Signed-off-by: Peter Jones ---- - src/linux-ata.c | 2 +- - src/linux-i2o.c | 2 +- - src/linux-nvme.c | 2 +- - src/linux-pci.c | 2 +- - src/linux-pmem.c | 2 +- - src/linux-sas.c | 2 +- - src/linux-sata.c | 2 +- - src/linux-scsi.c | 2 +- - src/linux-virtblk.c | 2 +- - src/linux.c | 4 ++-- - src/linux.h | 3 ++- - 11 files changed, 13 insertions(+), 12 deletions(-) - -diff --git a/src/linux-ata.c b/src/linux-ata.c -index 6a47ff3f279..dab02f3d224 100644 ---- a/src/linux-ata.c -+++ b/src/linux-ata.c -@@ -58,7 +58,7 @@ is_pata(struct device *dev) - * 11:0 -> ../../devices/pci0000:00/0000:00:11.5/ata3/host2/target2:0:0/2:0:0:0/block/sr0 - */ - static ssize_t --parse_ata(struct device *dev, const char *current) -+parse_ata(struct device *dev, const char *current, const char *root UNUSED) - { - uint32_t scsi_host, scsi_bus, scsi_device, scsi_target; - uint64_t scsi_lun; -diff --git a/src/linux-i2o.c b/src/linux-i2o.c -index e57c0cb344f..4fe79e5719f 100644 ---- a/src/linux-i2o.c -+++ b/src/linux-i2o.c -@@ -33,7 +33,7 @@ - * ... probably doesn't work. - */ - static ssize_t --parse_i2o(struct device *dev, const char *current UNUSED) -+parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSED) - { - debug(DEBUG, "entry"); - /* I2O disks can have up to 16 partitions, or 4 bits worth. */ -diff --git a/src/linux-nvme.c b/src/linux-nvme.c -index 6d5196fc082..00f53d5a9a7 100644 ---- a/src/linux-nvme.c -+++ b/src/linux-nvme.c -@@ -48,7 +48,7 @@ - */ - - static ssize_t --parse_nvme(struct device *dev, const char *current) -+parse_nvme(struct device *dev, const char *current, const char *root UNUSED) - { - int rc; - int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition; -diff --git a/src/linux-pci.c b/src/linux-pci.c -index 0d2a90ab166..4fbd108e3ed 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -41,7 +41,7 @@ - * - */ - static ssize_t --parse_pci(struct device *dev, const char *current) -+parse_pci(struct device *dev, const char *current, const char *root UNUSED) - { - int rc; - int pos; -diff --git a/src/linux-pmem.c b/src/linux-pmem.c -index 045650bc471..9a075716f7f 100644 ---- a/src/linux-pmem.c -+++ b/src/linux-pmem.c -@@ -70,7 +70,7 @@ - */ - - static ssize_t --parse_pmem(struct device *dev, const char *current) -+parse_pmem(struct device *dev, const char *current, const char *root UNUSED) - { - uint8_t *filebuf = NULL; - uint8_t system, sysbus, acpi_id; -diff --git a/src/linux-sas.c b/src/linux-sas.c -index 4a11147aef1..5f44f2c1f7b 100644 ---- a/src/linux-sas.c -+++ b/src/linux-sas.c -@@ -45,7 +45,7 @@ - * I'm not sure at the moment if they're the same or not. - */ - static ssize_t --parse_sas(struct device *dev, const char *current) -+parse_sas(struct device *dev, const char *current, const char *root UNUSED) - { - struct stat statbuf = { 0, }; - int rc; -diff --git a/src/linux-sata.c b/src/linux-sata.c -index a670ad9907e..d9a62efdbe6 100644 ---- a/src/linux-sata.c -+++ b/src/linux-sata.c -@@ -138,7 +138,7 @@ sysfs_sata_get_port_info(uint32_t print_id, struct device *dev) - } - - static ssize_t --parse_sata(struct device *dev, const char *devlink) -+parse_sata(struct device *dev, const char *devlink, const char *root UNUSED) - { - const char *current = devlink; - uint32_t print_id; -diff --git a/src/linux-scsi.c b/src/linux-scsi.c -index 87f2f7f7c92..153a4ff87ad 100644 ---- a/src/linux-scsi.c -+++ b/src/linux-scsi.c -@@ -160,7 +160,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - } - - static ssize_t --parse_scsi(struct device *dev, const char *current) -+parse_scsi(struct device *dev, const char *current, const char *root UNUSED) - { - uint32_t scsi_host, scsi_bus, scsi_device, scsi_target; - uint64_t scsi_lun; -diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c -index 6dedf0f27ee..9ee7994aeb3 100644 ---- a/src/linux-virtblk.c -+++ b/src/linux-virtblk.c -@@ -45,7 +45,7 @@ - * But usually we just write the HD() entry, of course. - */ - static ssize_t --parse_virtblk(struct device *dev, const char *current) -+parse_virtblk(struct device *dev, const char *current, const char *root UNUSED) - { - uint32_t tosser; - int pos; -diff --git a/src/linux.c b/src/linux.c -index fe45c6004b9..ef560753481 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -352,7 +352,7 @@ struct device HIDDEN - efi_error("strdup(\"%s\") failed", linkbuf); - goto err; - } -- debug(DEBUG, "dev->link: %s\n", dev->link); -+ debug(DEBUG, "dev->link: %s", dev->link); - - if (dev->part == -1) { - rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link); -@@ -431,7 +431,7 @@ struct device HIDDEN - } - - debug(DEBUG, "trying %s", probe->name); -- pos = probe->parse(dev, current); -+ pos = probe->parse(dev, current, dev->link); - if (pos < 0) { - efi_error("parsing %s failed", probe->name); - goto err; -diff --git a/src/linux.h b/src/linux.h -index 39826224a53..35951bb4d16 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -244,7 +244,8 @@ struct dev_probe { - char *name; - enum interface_type *iftypes; - uint32_t flags; -- ssize_t (*parse)(struct device *dev, const char * const current); -+ ssize_t (*parse)(struct device *dev, -+ const char * const current, const char * const root); - ssize_t (*create)(struct device *dev, - uint8_t *buf, ssize_t size, ssize_t off); - char *(*make_part_name)(struct device *dev); --- -2.17.1 - diff --git a/0012-Move-ACPI-ID-parsing-to-a-shared-location.patch b/0012-Move-ACPI-ID-parsing-to-a-shared-location.patch deleted file mode 100644 index d0c9680..0000000 --- a/0012-Move-ACPI-ID-parsing-to-a-shared-location.patch +++ /dev/null @@ -1,391 +0,0 @@ -From e2f68c8f9f4fab48f1ef3a4585932f757593fa92 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 14:43:32 -0400 -Subject: [PATCH 12/34] Move ACPI ID parsing to a shared location. - -This is getting out of PCI because we have some other platforms that do -ACPI root parsing, but don't use the PCI roots. - -Signed-off-by: Peter Jones ---- - src/linux-acpi.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++ - src/linux-pci.c | 112 +++++--------------------------------------- - src/linux.c | 11 ++++- - src/linux.h | 19 +++++--- - 4 files changed, 152 insertions(+), 109 deletions(-) - create mode 100644 src/linux-acpi.c - -diff --git a/src/linux-acpi.c b/src/linux-acpi.c -new file mode 100644 -index 00000000000..cb93a113ee2 ---- /dev/null -+++ b/src/linux-acpi.c -@@ -0,0 +1,119 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+int HIDDEN -+parse_acpi_hid_uid(struct device *dev, const char *fmt, ...) -+{ -+ int rc; -+ char *path = NULL; -+ va_list ap; -+ char *fbuf = NULL; -+ uint16_t tmp16; -+ uint32_t acpi_hid = 0; -+ uint64_t acpi_uid_int = 0; -+ -+ debug(DEBUG, "entry"); -+ -+ va_start(ap, fmt); -+ rc = vasprintfa(&path, fmt, ap); -+ va_end(ap); -+ debug(DEBUG, "path:%s rc:%d", path, rc); -+ if (rc < 0 || path == NULL) -+ return -1; -+ -+ rc = read_sysfs_file(&fbuf, "%s/firmware_node/path", path); -+ if (rc > 0) { -+ size_t l = strlen(fbuf); -+ if (l > 1) { -+ fbuf[l-1] = 0; -+ dev->acpi_root.acpi_cid_str = strdup(fbuf); -+ debug(DEBUG, "Setting ACPI root path to \"%s\"", fbuf); -+ } -+ } -+ -+ rc = read_sysfs_file(&fbuf, "%s/firmware_node/hid", path); -+ if (rc < 0 || fbuf == NULL) { -+ efi_error("could not read %s/firmware_node/hid", path); -+ return -1; -+ } -+ -+ rc = strlen(fbuf); -+ if (rc < 4) { -+hid_err: -+ efi_error("could not parse %s/firmware_node/hid", path); -+ return -1; -+ } -+ rc -= 4; -+ -+ rc = sscanf((char *)fbuf + rc, "%04hx", &tmp16); -+ debug(DEBUG, "rc:%d hid:0x%08x\n", rc, tmp16); -+ if (rc != 1) -+ goto hid_err; -+ -+ acpi_hid = EFIDP_EFI_PNP_ID(tmp16); -+ -+ /* -+ * Apparently basically nothing can look up a PcieRoot() node, -+ * because they just check _CID. So since _CID for the root pretty -+ * much always has to be PNP0A03 anyway, just use that no matter -+ * what. -+ */ -+ if (acpi_hid == EFIDP_ACPI_PCIE_ROOT_HID) -+ acpi_hid = EFIDP_ACPI_PCI_ROOT_HID; -+ dev->acpi_root.acpi_hid = acpi_hid; -+ debug(DEBUG, "acpi root HID:0x%08x", acpi_hid); -+ -+ errno = 0; -+ fbuf = NULL; -+ rc = read_sysfs_file(&fbuf, "%s/firmware_node/uid", path); -+ if ((rc <= 0 && errno != ENOENT) || fbuf == NULL) { -+ efi_error("could not read %s/firmware_node/uid", path); -+ return -1; -+ } -+ if (rc > 0) { -+ rc = sscanf((char *)fbuf, "%"PRIu64"\n", &acpi_uid_int); -+ if (rc == 1) { -+ dev->acpi_root.acpi_uid = acpi_uid_int; -+ } else { -+ /* kernel uses "%s\n" to print it, so there -+ * should always be some value and a newline... */ -+ int l = strlen((char *)fbuf); -+ if (l >= 1) { -+ fbuf[l-1] = '\0'; -+ dev->acpi_root.acpi_uid_str = strdup(fbuf); -+ } -+ } -+ } -+ debug(DEBUG, "acpi root UID:0x%"PRIx64" uidstr:\"%s\"", -+ dev->acpi_root.acpi_uid, dev->acpi_root.acpi_uid_str); -+ -+ errno = 0; -+ return 0; -+} -diff --git a/src/linux-pci.c b/src/linux-pci.c -index 4fbd108e3ed..aa3e40c0f7c 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -37,21 +37,17 @@ - * ^ root hub ^device ^device - * - * for network devices, we also get: -- * /sys/class/net/$IFACE -> ../../devices/$PCI_STUFF/net/$IFACE -+ * /sys/class/net/$IFACE -> ../../devices/$PCI_DEVICES/net/$IFACE -+ * -+ * In both cases our "current" pointer should be at $PCI_DEVICES. - * - */ - static ssize_t --parse_pci(struct device *dev, const char *current, const char *root UNUSED) -+parse_pci(struct device *dev, const char *current, const char *root) - { - int rc; - int pos; -- uint16_t root_domain; -- uint8_t root_bus; -- uint32_t acpi_hid = 0; -- uint64_t acpi_uid_int = 0; - const char *devpart = current; -- char *fbuf = NULL; -- uint16_t tmp16 = 0; - char *spaces; - - pos = strlen(current); -@@ -62,66 +58,6 @@ parse_pci(struct device *dev, const char *current, const char *root UNUSED) - - debug(DEBUG, "entry"); - -- /* -- * find the pci root domain and port; they basically look like: -- * pci0000:00/ -- * ^d ^p -- */ -- rc = sscanf(devpart, "../../devices/pci%hx:%hhx/%n", &root_domain, &root_bus, &pos); -- /* -- * If we can't find that, it's not a PCI device. -- */ -- if (rc != 2) -- return 0; -- devpart += pos; -- -- dev->pci_root.pci_root_domain = root_domain; -- dev->pci_root.pci_root_bus = root_bus; -- -- rc = read_sysfs_file(&fbuf, -- "devices/pci%04hx:%02hhx/firmware_node/hid", -- root_domain, root_bus); -- if (rc < 0 || fbuf == NULL) -- return -1; -- -- rc = sscanf((char *)fbuf, "PNP%hx", &tmp16); -- if (rc != 1) -- return -1; -- acpi_hid = EFIDP_EFI_PNP_ID(tmp16); -- -- /* -- * Apparently basically nothing can look up a PcieRoot() node, -- * because they just check _CID. So since _CID for the root pretty -- * much always has to be PNP0A03 anyway, just use that no matter -- * what. -- */ -- if (acpi_hid == EFIDP_ACPI_PCIE_ROOT_HID) -- acpi_hid = EFIDP_ACPI_PCI_ROOT_HID; -- dev->pci_root.pci_root_acpi_hid = acpi_hid; -- -- errno = 0; -- fbuf = NULL; -- rc = read_sysfs_file(&fbuf, -- "devices/pci%04hx:%02hhx/firmware_node/uid", -- root_domain, root_bus); -- if ((rc <= 0 && errno != ENOENT) || fbuf == NULL) -- return -1; -- if (rc > 0) { -- rc = sscanf((char *)fbuf, "%"PRIu64"\n", &acpi_uid_int); -- if (rc == 1) { -- dev->pci_root.pci_root_acpi_uid = acpi_uid_int; -- } else { -- /* kernel uses "%s\n" to print it, so there -- * should always be some value and a newline... */ -- int l = strlen((char *)fbuf); -- if (l >= 1) { -- fbuf[l-1] = '\0'; -- dev->pci_root.pci_root_acpi_uid_str = fbuf; -- } -- } -- } -- errno = 0; -- - /* find the pci domain/bus/device/function: - * 0000:00:01.0/0000:01:00.0/ - * ^d ^b ^d ^f (of the last one in the series) -@@ -136,7 +72,7 @@ parse_pci(struct device *dev, const char *current, const char *root UNUSED) - debug(DEBUG, "searching for 0000:00:00.0/"); - rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n", - &domain, &bus, &device, &function, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", devpart, rc, pos); -+ debug(DEBUG, "current:\"%s\" rc:%d pos:%d", devpart, rc, pos); - arrow(DEBUG, spaces, 9, pos, rc, 3); - if (rc != 4) - break; -@@ -157,24 +93,26 @@ parse_pci(struct device *dev, const char *current, const char *root UNUSED) - dev->pci_dev[i].pci_bus = bus; - dev->pci_dev[i].pci_device = device; - dev->pci_dev[i].pci_function = function; -- char *tmp = strndup(current, devpart-current+1); -+ char *tmp = strndup(root, devpart-root+1); - char *linkbuf = NULL; - if (!tmp) { - efi_error("could not allocate memory"); - return -1; - } -- tmp[devpart - current] = '\0'; -+ tmp[devpart - root] = '\0'; - rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp); -- free(tmp); - if (rc < 0 || !linkbuf) { -- efi_error("Could not find driver for pci device"); -+ efi_error("Could not find driver for pci device %s", tmp); -+ free(tmp); - return -1; - } -+ free(tmp); - dev->pci_dev[i].driverlink = strdup(linkbuf); - debug(DEBUG, "driver:%s\n", linkbuf); - dev->n_pci_devs += 1; - } - -+ debug(DEBUG, "next:\"%s\"", devpart); - return devpart - current; - } - -@@ -186,34 +124,6 @@ dp_create_pci(struct device *dev, - - debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); - -- if (dev->pci_root.pci_root_acpi_uid_str) { -- debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"", -- dev->pci_root.pci_root_acpi_hid, -- dev->pci_root.pci_root_acpi_uid_str); -- new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0, -- dev->pci_root.pci_root_acpi_hid, -- 0, 0, "", -- dev->pci_root.pci_root_acpi_uid_str, -- ""); -- if (new < 0) { -- efi_error("efidp_make_acpi_hid_ex() failed"); -- return new; -- } -- } else { -- debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, -- dev->pci_root.pci_root_acpi_hid, -- dev->pci_root.pci_root_acpi_uid); -- new = efidp_make_acpi_hid(buf + off, size ? size - off : 0, -- dev->pci_root.pci_root_acpi_hid, -- dev->pci_root.pci_root_acpi_uid); -- if (new < 0) { -- efi_error("efidp_make_acpi_hid() failed"); -- return new; -- } -- } -- off += new; -- sz += new; -- - debug(DEBUG, "creating PCI device path nodes"); - for (unsigned int i = 0; i < dev->n_pci_devs; i++) { - debug(DEBUG, "creating PCI device path node %u", i); -diff --git a/src/linux.c b/src/linux.c -index ef560753481..9f3a22f7025 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -272,6 +272,13 @@ device_free(struct device *dev) - if (dev->probes) - free(dev->probes); - -+ if (dev->acpi_root.acpi_hid_str) -+ free(dev->acpi_root.acpi_hid_str); -+ if (dev->acpi_root.acpi_uid_str) -+ free(dev->acpi_root.acpi_uid_str); -+ if (dev->acpi_root.acpi_cid_str) -+ free(dev->acpi_root.acpi_cid_str); -+ - if (dev->interface_type == network) { - if (dev->ifname) - free(dev->ifname); -@@ -325,8 +332,8 @@ struct device HIDDEN - goto err; - } - -- dev->pci_root.pci_root_domain = 0xffff; -- dev->pci_root.pci_root_bus = 0xff; -+ dev->pci_root.pci_domain = 0xffff; -+ dev->pci_root.pci_bus = 0xff; - - if (S_ISBLK(dev->stat.st_mode)) { - dev->major = major(dev->stat.st_rdev); -diff --git a/src/linux.h b/src/linux.h -index 35951bb4d16..aa9e3d14a83 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -21,12 +21,18 @@ - #ifndef _EFIBOOT_LINUX_H - #define _EFIBOOT_LINUX_H - -+struct acpi_root_info { -+ uint32_t acpi_hid; -+ uint64_t acpi_uid; -+ uint32_t acpi_cid; -+ char *acpi_hid_str; -+ char *acpi_uid_str; -+ char *acpi_cid_str; -+}; -+ - struct pci_root_info { -- uint16_t pci_root_domain; -- uint8_t pci_root_bus; -- uint32_t pci_root_acpi_hid; -- uint64_t pci_root_acpi_uid; -- char *pci_root_acpi_uid_str; -+ uint16_t pci_domain; -+ uint8_t pci_bus; - }; - - struct pci_dev_info { -@@ -121,6 +127,7 @@ struct device { - char *disk_name; - char *part_name; - -+ struct acpi_root_info acpi_root; - struct pci_root_info pci_root; - unsigned int n_pci_devs; - struct pci_dev_info *pci_dev; -@@ -147,7 +154,7 @@ extern int HIDDEN set_disk_name(struct device *dev, const char * const fmt, ...) - extern bool HIDDEN is_pata(struct device *dev); - extern int HIDDEN make_blockdev_path(uint8_t *buf, ssize_t size, - struct device *dev); -- -+extern int HIDDEN parse_acpi_hid_uid(struct device *dev, const char *fmt, ...); - extern int HIDDEN eb_nvme_ns_id(int fd, uint32_t *ns_id); - - int HIDDEN get_sector_size(int filedes); --- -2.17.1 - diff --git a/0013-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch b/0013-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch deleted file mode 100644 index 235851f..0000000 --- a/0013-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch +++ /dev/null @@ -1,425 +0,0 @@ -From 6b62aa40cfa1feb924609a065098da98c99e925c Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 14:45:14 -0400 -Subject: [PATCH 13/34] Make a platform ACPI root parser separate from PCI - roots. - -Because apparently PNP0A03 and PNP0A0C weren't good enough. - -Signed-off-by: Peter Jones ---- - src/linux-acpi-root.c | 199 ++++++++++++++++++++++++++++++++++++++++++ - src/linux-pci-root.c | 136 +++++++++++++++++++++++++++++ - src/linux-pci.c | 1 - - src/linux.c | 4 +- - src/linux.h | 4 +- - 5 files changed, 341 insertions(+), 3 deletions(-) - create mode 100644 src/linux-acpi-root.c - create mode 100644 src/linux-pci-root.c - -diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c -new file mode 100644 -index 00000000000..c7d8276a642 ---- /dev/null -+++ b/src/linux-acpi-root.c -@@ -0,0 +1,199 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+/* -+ * support for ACPI-like platform root hub and devices -+ * -+ * various devices /sys/dev/block/$major:$minor start with: -+ * maj:min -> ../../devices/ACPI0000:00/$PCI_DEVICES/$BLOCKDEV_STUFF/block/$DISK/$PART -+ * i.e.: APMC0D0D:00/ata1/host0/target0:0:0/0:0:0:0/block/sda -+ * ^ root hub ^blockdev stuff -+ * or: -+ * maj:min -> ../../devices/ACPI0000:00/$PCI_DEVICES/$BLOCKDEV_STUFF/block/$DISK/$PART -+ * i.e.: APMC0D0D:00/0000:00:1d.0/0000:05:00.0/ata1/host0/target0:0:0/0:0:0:0/block/sda -+ * ^ root hub ^pci dev ^pci dev ^ blockdev stuff -+ */ -+static ssize_t -+parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED) -+{ -+ int rc; -+ int pos; -+ uint16_t pad0; -+ uint8_t pad1; -+ char *acpi_header = NULL; -+ char *colon; -+ -+ const char *devpart = current; -+ char *spaces; -+ -+ pos = strlen(current); -+ spaces = alloca(pos+1); -+ memset(spaces, ' ', pos+1); -+ spaces[pos] = '\0'; -+ pos = 0; -+ -+ debug(DEBUG, "entry"); -+ -+ /* -+ * find the ACPI root dunno0 and dunno1; they basically look like: -+ * ABCD0000:00/ -+ * ^d0 ^d1 -+ * This is annoying because "/%04ms%h:%hhx/" won't bind from the right -+ * side in sscanf. -+ */ -+ rc = sscanf(devpart, "../../devices/platform/%n", &pos); -+ debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); -+ if (rc != 0 || pos < 1) -+ return 0; -+ devpart += pos; -+ -+ /* -+ * If it's too short to be A0000:00, it's not an ACPI string -+ */ -+ if (strlen(devpart) < 8) -+ return 0; -+ -+ colon = strchr(devpart, ':'); -+ if (!colon) -+ return 0; -+ pos = colon - devpart; -+ -+ /* -+ * If colon doesn't point at something between one of these: -+ * A0000:00 ACPI0000:00 -+ * ^ 5 ^ 8 -+ * Then it's not an ACPI string. -+ */ -+ if (pos < 5 || pos > 8) -+ return 0; -+ -+ dev->acpi_root.acpi_hid_str = strndup(devpart, pos + 1); -+ if (!dev->acpi_root.acpi_hid_str) { -+ efi_error("Could not allocate memory"); -+ return -1; -+ } -+ dev->acpi_root.acpi_hid_str[pos] = 0; -+ debug(DEBUG, "acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str); -+ -+ pos -= 4; -+ debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); -+ acpi_header = strndupa(devpart, pos); -+ if (!acpi_header) -+ return 0; -+ acpi_header[pos] = 0; -+ debug(DEBUG, "devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header); -+ devpart += pos; -+ -+ /* -+ * If we can't find these numbers, it's not an ACPI string -+ */ -+ rc = sscanf(devpart, "%hx:%hhx/%n", &pad0, &pad1, &pos); -+ if (rc != 2) { -+ efi_error("Could not parse ACPI path \"%s\"", devpart); -+ return 0; -+ } -+ debug(DEBUG, "devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d", -+ devpart, pad0, pad1, pos, rc); -+ -+ devpart += pos; -+ -+ rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hX:%02hhX", -+ acpi_header, pad0, pad1); -+ debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX", -+ rc, acpi_header, pad0, pad1); -+ if (rc < 0 && errno == ENOENT) { -+ rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hx:%02hhx", -+ acpi_header, pad0, pad1); -+ debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx", -+ rc, acpi_header, pad0, pad1); -+ } -+ if (rc < 0) { -+ efi_error("Could not parse hid/uid"); -+ return rc; -+ } -+ debug(DEBUG, "Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"", -+ dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid, -+ dev->acpi_root.acpi_uid_str, -+ dev->acpi_root.acpi_cid_str); -+ -+ return devpart - current; -+} -+ -+static ssize_t -+dp_create_acpi_root(struct device *dev, -+ uint8_t *buf, ssize_t size, ssize_t off) -+{ -+ ssize_t sz = 0, new = 0; -+ -+ debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -+ -+ if (dev->acpi_root.acpi_uid_str || dev->acpi_root.acpi_cid_str) { -+ debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"", -+ dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid, -+ dev->acpi_root.acpi_uid_str, dev->acpi_root.acpi_cid_str); -+ new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0, -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid, -+ dev->acpi_root.acpi_cid, -+ dev->acpi_root.acpi_hid_str, -+ dev->acpi_root.acpi_uid_str, -+ dev->acpi_root.acpi_cid_str); -+ if (new < 0) { -+ efi_error("efidp_make_acpi_hid_ex() failed"); -+ return new; -+ } -+ } else { -+ debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid); -+ new = efidp_make_acpi_hid(buf + off, size ? size - off : 0, -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid); -+ if (new < 0) { -+ efi_error("efidp_make_acpi_hid() failed"); -+ return new; -+ } -+ } -+ off += new; -+ sz += new; -+ -+ debug(DEBUG, "returning %zd", sz); -+ return sz; -+} -+ -+enum interface_type acpi_root_iftypes[] = { acpi_root, unknown }; -+ -+struct dev_probe HIDDEN acpi_root_parser = { -+ .name = "acpi_root", -+ .iftypes = acpi_root_iftypes, -+ .flags = DEV_PROVIDES_ROOT, -+ .parse = parse_acpi_root, -+ .create = dp_create_acpi_root, -+}; -diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c -new file mode 100644 -index 00000000000..8f556a066f3 ---- /dev/null -+++ b/src/linux-pci-root.c -@@ -0,0 +1,136 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+/* -+ * support for PCI root hub and devices -+ * -+ * various devices /sys/dev/block/$major:$minor start with: -+ * maj:min -> ../../devices/pci$PCIROOT/$PCI_DEVICES/$BLOCKDEV_STUFF/block/$DISK/$PART -+ * i.e.: pci0000:00/0000:00:1d.0/0000:05:00.0/ -+ * ^ root hub ^device ^device -+ * -+ * for network devices, we also get: -+ * /sys/class/net/$IFACE -> ../../devices/$PCI_STUFF/net/$IFACE -+ * -+ */ -+static ssize_t -+parse_pci_root(struct device *dev, const char *current, const char *root UNUSED) -+{ -+ int rc; -+ int pos; -+ uint16_t root_domain; -+ uint8_t root_bus; -+ const char *devpart = current; -+ char *spaces; -+ -+ pos = strlen(current); -+ spaces = alloca(pos+1); -+ memset(spaces, ' ', pos+1); -+ spaces[pos] = '\0'; -+ pos = 0; -+ -+ debug(DEBUG, "entry"); -+ -+ /* -+ * find the pci root domain and port; they basically look like: -+ * pci0000:00/ -+ * ^d ^p -+ */ -+ rc = sscanf(devpart, "../../devices/pci%hx:%hhx/%n", &root_domain, &root_bus, &pos); -+ /* -+ * If we can't find that, it's not a PCI device. -+ */ -+ if (rc != 2) -+ return 0; -+ devpart += pos; -+ -+ dev->pci_root.pci_domain = root_domain; -+ dev->pci_root.pci_bus = root_bus; -+ -+ rc = parse_acpi_hid_uid(dev, "devices/pci%04hx:%02hhx", -+ root_domain, root_bus); -+ if (rc < 0) -+ return -1; -+ -+ errno = 0; -+ return devpart - current; -+} -+ -+static ssize_t -+dp_create_pci_root(struct device *dev UNUSED, -+ uint8_t *buf, ssize_t size, ssize_t off) -+{ -+ debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -+ debug(DEBUG, "returning 0"); -+#if 0 -+ if (dev->acpi_root.acpi_uid_str) { -+ debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"", -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid_str); -+ new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0, -+ dev->acpi_root.acpi_hid, -+ 0, 0, "", -+ dev->acpi_root.acpi_uid_str, -+ ""); -+ if (new < 0) { -+ efi_error("efidp_make_acpi_hid_ex() failed"); -+ return new; -+ } -+ } else { -+ debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid); -+ new = efidp_make_acpi_hid(buf + off, size ? size - off : 0, -+ dev->acpi_root.acpi_hid, -+ dev->acpi_root.acpi_uid); -+ if (new < 0) { -+ efi_error("efidp_make_acpi_hid() failed"); -+ return new; -+ } -+ } -+ off += new; -+ sz += new; -+ -+ debug(DEBUG, "returning %zd", sz); -+ return sz; -+#else -+ return 0; -+#endif -+} -+ -+enum interface_type pci_root_iftypes[] = { pci_root, unknown }; -+ -+struct dev_probe HIDDEN pci_root_parser = { -+ .name = "pci_root", -+ .iftypes = pci_root_iftypes, -+ .flags = DEV_PROVIDES_ROOT, -+ .parse = parse_pci_root, -+ .create = dp_create_pci_root, -+}; -diff --git a/src/linux-pci.c b/src/linux-pci.c -index aa3e40c0f7c..0f59d3e840d 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -147,7 +147,6 @@ enum interface_type pci_iftypes[] = { pci, unknown }; - struct dev_probe HIDDEN pci_parser = { - .name = "pci", - .iftypes = pci_iftypes, -- .flags = DEV_PROVIDES_ROOT, - .parse = parse_pci, - .create = dp_create_pci, - }; -diff --git a/src/linux.c b/src/linux.c -index 9f3a22f7025..436fb882a98 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -235,6 +235,8 @@ static struct dev_probe *dev_probes[] = { - * be found first. - */ - &pmem_parser, -+ &acpi_root_parser, -+ &pci_root_parser, - &pci_parser, - &virtblk_parser, - &sas_parser, -@@ -447,7 +449,7 @@ struct device HIDDEN - } - debug(DEBUG, "%s matched %s", probe->name, current); - -- if (probe->flags & DEV_PROVIDES_HD) -+ if (probe->flags & DEV_PROVIDES_HD || probe->flags & DEV_PROVIDES_ROOT) - needs_root = false; - dev->probes[n++] = dev_probes[i]; - current += pos; -diff --git a/src/linux.h b/src/linux.h -index aa9e3d14a83..7b18bda31c6 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -95,7 +95,7 @@ struct nvdimm_info { - - enum interface_type { - unknown, -- isa, pci, network, -+ isa, acpi_root, pci_root, pci, network, - ata, atapi, scsi, sata, sas, - usb, i1394, fibre, i2o, - md, virtblk, -@@ -264,6 +264,8 @@ extern ssize_t parse_scsi_link(const char *current, uint32_t *host, - - /* device support implementations */ - extern struct dev_probe pmem_parser; -+extern struct dev_probe pci_root_parser; -+extern struct dev_probe acpi_root_parser; - extern struct dev_probe pci_parser; - extern struct dev_probe sas_parser; - extern struct dev_probe sata_parser; --- -2.17.1 - diff --git a/0014-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch b/0014-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch deleted file mode 100644 index d6743d6..0000000 --- a/0014-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch +++ /dev/null @@ -1,71 +0,0 @@ -From ca71ba77abee7cea805e71a7faded706d19e4c58 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 16:16:00 -0400 -Subject: [PATCH 14/34] Make a way to say "-e 3" isn't viable for a kind of - device. - -Signed-off-by: Peter Jones ---- - src/creator.c | 7 +++++++ - src/linux.c | 5 ++++- - src/linux.h | 2 ++ - 3 files changed, 13 insertions(+), 1 deletion(-) - -diff --git a/src/creator.c b/src/creator.c -index 76c1c1f7a99..55b411ee3da 100644 ---- a/src/creator.c -+++ b/src/creator.c -@@ -243,6 +243,13 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - va_end(aq); - } - -+ if (!(options & (EFIBOOT_ABBREV_FILE|EFIBOOT_ABBREV_HD)) && -+ (dev->flags & DEV_ABBREV_ONLY)) { -+ errno = EINVAL; -+ efi_error("Device must use File() or HD() device path"); -+ goto err; -+ } -+ - if ((options & EFIBOOT_ABBREV_EDD10) - && (!(options & EFIBOOT_ABBREV_FILE) - && !(options & EFIBOOT_ABBREV_HD))) { -diff --git a/src/linux.c b/src/linux.c -index 436fb882a98..83adc510944 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -448,8 +448,11 @@ struct device HIDDEN - continue; - } - debug(DEBUG, "%s matched %s", probe->name, current); -+ dev->flags |= probe->flags; - -- if (probe->flags & DEV_PROVIDES_HD || probe->flags & DEV_PROVIDES_ROOT) -+ if (probe->flags & DEV_PROVIDES_HD || -+ probe->flags & DEV_PROVIDES_ROOT || -+ probe->flags & DEV_ABBREV_ONLY) - needs_root = false; - dev->probes[n++] = dev_probes[i]; - current += pos; -diff --git a/src/linux.h b/src/linux.h -index 7b18bda31c6..ef7dba769bd 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -106,6 +106,7 @@ struct dev_probe; - - struct device { - enum interface_type interface_type; -+ uint32_t flags; - char *link; - char *device; - char *driver; -@@ -246,6 +247,7 @@ extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size, - - #define DEV_PROVIDES_ROOT 1 - #define DEV_PROVIDES_HD 2 -+#define DEV_ABBREV_ONLY 4 - - struct dev_probe { - char *name; --- -2.17.1 - diff --git a/0015-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch b/0015-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch deleted file mode 100644 index 836535a..0000000 --- a/0015-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch +++ /dev/null @@ -1,131 +0,0 @@ -From d8637ea2b540fc9d16f1d1c1312e49a24082eefe Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 16:16:35 -0400 -Subject: [PATCH 15/34] Make a linux device root for SOC devices that use FDT. - -Add parsing for FDT devices in sysfs. These devices have to use HD() or -File() because we don't have a way to express FDT nodes in a Device -Path. - -Signed-off-by: Peter Jones ---- - src/linux-soc-root.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ - src/linux.c | 1 + - src/linux.h | 3 +- - 3 files changed, 75 insertions(+), 1 deletion(-) - create mode 100644 src/linux-soc-root.c - -diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c -new file mode 100644 -index 00000000000..57dd9b04f2c ---- /dev/null -+++ b/src/linux-soc-root.c -@@ -0,0 +1,72 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+/* -+ * support for soc platforms -+ * -+ * various devices /sys/dev/block/$major:$minor start with: -+ * maj:min -> ../../devices/platform/soc/$DEVICETREE_NODE/$BLOCKDEV_STUFF/block/$DISK/$PART -+ * i.e.: soc/1a400000.sata/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1 -+ * ^ dt node ^ blockdev stuff ^ disk -+ * I don't *think* the devicetree nodes stack. -+ */ -+static ssize_t -+parse_soc_root(struct device *dev UNUSED, const char *current, const char *root UNUSED) -+{ -+ int rc; -+ int pos; -+ const char *devpart = current; -+ char *spaces; -+ -+ pos = strlen(current); -+ spaces = alloca(pos+1); -+ memset(spaces, ' ', pos+1); -+ spaces[pos] = '\0'; -+ pos = 0; -+ -+ debug(DEBUG, "entry"); -+ -+ rc = sscanf(devpart, "../../devices/platform/soc/%*[^/]/%n", &pos); -+ if (rc != 0) -+ return 0; -+ devpart += pos; -+ debug(DEBUG, "new position is \"%s\"", devpart); -+ -+ return devpart - current; -+} -+ -+enum interface_type soc_root_iftypes[] = { soc_root, unknown }; -+ -+struct dev_probe HIDDEN soc_root_parser = { -+ .name = "soc_root", -+ .iftypes = soc_root_iftypes, -+ .flags = DEV_ABBREV_ONLY|DEV_PROVIDES_ROOT, -+ .parse = parse_soc_root, -+}; -diff --git a/src/linux.c b/src/linux.c -index 83adc510944..1e7db4e3f61 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -237,6 +237,7 @@ static struct dev_probe *dev_probes[] = { - &pmem_parser, - &acpi_root_parser, - &pci_root_parser, -+ &soc_root_parser, - &pci_parser, - &virtblk_parser, - &sas_parser, -diff --git a/src/linux.h b/src/linux.h -index ef7dba769bd..99d61013e02 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -95,7 +95,7 @@ struct nvdimm_info { - - enum interface_type { - unknown, -- isa, acpi_root, pci_root, pci, network, -+ isa, acpi_root, pci_root, soc_root, pci, network, - ata, atapi, scsi, sata, sas, - usb, i1394, fibre, i2o, - md, virtblk, -@@ -268,6 +268,7 @@ extern ssize_t parse_scsi_link(const char *current, uint32_t *host, - extern struct dev_probe pmem_parser; - extern struct dev_probe pci_root_parser; - extern struct dev_probe acpi_root_parser; -+extern struct dev_probe soc_root_parser; - extern struct dev_probe pci_parser; - extern struct dev_probe sas_parser; - extern struct dev_probe sata_parser; --- -2.17.1 - diff --git a/0016-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch b/0016-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch deleted file mode 100644 index c72832f..0000000 --- a/0016-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch +++ /dev/null @@ -1,110 +0,0 @@ -From bc215d06720b346ba0d888a6149cf90f544a90ad Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 20 Jun 2018 17:00:24 -0400 -Subject: [PATCH 16/34] If we can't parse part of the device link, skip it and - set DEV_ABBREV_ONLY - -If we can't parse some part of the device symlink, we can't write a full -device path, but we can write an abbreviated HD() or File() path. So if -we've exausted all possibilities, skip to the next node, set -DEV_ABBREV_ONLY in the device's flags, and try parsing again. Then when -creator.c checks if that flag conflicts, it'll throw an error if it -does. - -Signed-off-by: Peter Jones ---- - src/linux.c | 62 ++++++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 47 insertions(+), 15 deletions(-) - -diff --git a/src/linux.c b/src/linux.c -index 1e7db4e3f61..8fe21f19f78 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -429,14 +429,17 @@ struct device HIDDEN - - const char *current = dev->link; - bool needs_root = true; -+ int last_successful_probe = -1; - - debug(DEBUG, "searching for device nodes in %s", dev->link); - for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) { - struct dev_probe *probe = dev_probes[i]; - ssize_t pos; - -- if (!needs_root && (probe->flags & DEV_PROVIDES_ROOT)) { -- debug(DEBUG, "not testing %s because flags is 0x%x", probe->name, probe->flags); -+ if (!needs_root && -+ (probe->flags & DEV_PROVIDES_ROOT)) { -+ debug(DEBUG, "not testing %s because flags is 0x%x", -+ probe->name, probe->flags); - continue; - } - -@@ -445,22 +448,51 @@ struct device HIDDEN - if (pos < 0) { - efi_error("parsing %s failed", probe->name); - goto err; -- } else if (pos == 0) { -+ } else if (pos > 0) { -+ debug(DEBUG, "%s matched %s", probe->name, current); -+ dev->flags |= probe->flags; -+ -+ if (probe->flags & DEV_PROVIDES_HD || -+ probe->flags & DEV_PROVIDES_ROOT || -+ probe->flags & DEV_ABBREV_ONLY) -+ needs_root = false; -+ -+ dev->probes[n++] = dev_probes[i]; -+ current += pos; -+ debug(DEBUG, "current:%s", current); -+ last_successful_probe = i; -+ -+ if (!*current || !strncmp(current, "block/", 6)) -+ break; -+ - continue; - } -- debug(DEBUG, "%s matched %s", probe->name, current); -- dev->flags |= probe->flags; - -- if (probe->flags & DEV_PROVIDES_HD || -- probe->flags & DEV_PROVIDES_ROOT || -- probe->flags & DEV_ABBREV_ONLY) -- needs_root = false; -- dev->probes[n++] = dev_probes[i]; -- current += pos; -- debug(DEBUG, "current:%s", current); -- -- if (!*current || !strncmp(current, "block/", 6)) -- break; -+ debug(DEBUG, "dev_probes[i+1]: %p dev->interface_type: %d\n", -+ dev_probes[i+1], dev->interface_type); -+ if (dev_probes[i+1] == NULL && dev->interface_type == unknown) { -+ int new_pos = 0; -+ rc = sscanf(current, "%*[^/]/%n", &new_pos); -+ if (rc < 0) { -+ efi_error( -+ "Cannot parse device link segment \"%s\"", -+ current); -+ goto err; -+ } -+ debug(DEBUG, -+ "Cannot parse device link segment \"%s\"", -+ current); -+ debug(DEBUG, "Skipping to \"%s\"", current + new_pos); -+ debug(DEBUG, -+ "This means we can only write abbreviated paths"); -+ if (rc < 0) -+ goto err; -+ if (new_pos == 0) -+ goto err; -+ dev->flags |= DEV_ABBREV_ONLY; -+ i = last_successful_probe; -+ current += new_pos; -+ } - } - - if (dev->interface_type == unknown) { --- -2.17.1 - diff --git a/0017-Pacify-clang-analyzer-just-a-little.patch b/0017-Pacify-clang-analyzer-just-a-little.patch deleted file mode 100644 index 22001b0..0000000 --- a/0017-Pacify-clang-analyzer-just-a-little.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 8f9c1406a2a50d0c67b1380ad6fddc2c266d39f6 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 11:13:39 -0400 -Subject: [PATCH 17/34] Pacify clang analyzer just a little. - -Signed-off-by: Peter Jones ---- - src/linux-acpi-root.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c -index c7d8276a642..e55af5fa385 100644 ---- a/src/linux-acpi-root.c -+++ b/src/linux-acpi-root.c -@@ -181,7 +181,6 @@ dp_create_acpi_root(struct device *dev, - return new; - } - } -- off += new; - sz += new; - - debug(DEBUG, "returning %zd", sz); --- -2.17.1 - diff --git a/0018-Try-even-harder-to-convince-coverity-that-get_file-i.patch b/0018-Try-even-harder-to-convince-coverity-that-get_file-i.patch deleted file mode 100644 index b918823..0000000 --- a/0018-Try-even-harder-to-convince-coverity-that-get_file-i.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 576b89de7d1a49d64efab9d494eeea5a296bdccd Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 12:23:20 -0400 -Subject: [PATCH 18/34] Try even harder to convince coverity that get_file - isn't leaking memory... - -Signed-off-by: Peter Jones ---- - src/util.h | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/src/util.h b/src/util.h -index ef85a4c277e..441ced84fcf 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -332,6 +332,13 @@ get_file(uint8_t **result, const char * const fmt, ...) - errno = error; - - if (rc < 0 || bufsize < 1) { -+ /* -+ * I don't think this can happen, but I can't convince -+ * cov-scan -+ */ -+ if (buf) -+ free(buf); -+ *result = NULL; - efi_error("could not read file \"%s\"", path); - return -1; - } --- -2.17.1 - diff --git a/0019-Make-the-debug-code-less-intrusive.patch b/0019-Make-the-debug-code-less-intrusive.patch deleted file mode 100644 index 0874e5f..0000000 --- a/0019-Make-the-debug-code-less-intrusive.patch +++ /dev/null @@ -1,1063 +0,0 @@ -From 154d0794827ffe9fd6adbbdf1cd3d04dba18e24d Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 13:32:28 -0400 -Subject: [PATCH 19/34] Make the debug() code less intrusive - -Signed-off-by: Peter Jones ---- - src/creator.c | 17 +++++++------- - src/dp-acpi.c | 18 +++++++-------- - src/linux-acpi-root.c | 26 ++++++++++----------- - src/linux-acpi.c | 12 +++++----- - src/linux-ata.c | 6 ++--- - src/linux-i2o.c | 2 +- - src/linux-nvme.c | 12 +++++----- - src/linux-pci-root.c | 12 +++++----- - src/linux-pci.c | 22 +++++++++--------- - src/linux-pmem.c | 6 ++--- - src/linux-sas.c | 4 ++-- - src/linux-sata.c | 30 ++++++++++++------------ - src/linux-scsi.c | 48 +++++++++++++++++++-------------------- - src/linux-soc-root.c | 4 ++-- - src/linux-virtblk.c | 8 +++---- - src/linux.c | 53 ++++++++++++++++++++----------------------- - src/loadopt.c | 13 +++++------ - src/util.h | 14 ++++++++---- - 18 files changed, 154 insertions(+), 153 deletions(-) - -diff --git a/src/creator.c b/src/creator.c -index 55b411ee3da..ef782e2b647 100644 ---- a/src/creator.c -+++ b/src/creator.c -@@ -178,7 +178,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - int fd = -1; - int saved_errno; - -- debug(DEBUG, "partition:%d", partition); -+ debug("partition:%d", partition); - - if (buf && size) - memset(buf, '\0', size); -@@ -198,7 +198,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - if (partition < 0) { - int disk_fd; - -- debug(DEBUG, "partition: %d", partition); -+ debug("partition: %d", partition); - disk_fd = open_disk(dev, - (options & EFIBOOT_OPTIONS_WRITE_SIGNATURE) - ? O_RDWR : O_RDONLY); -@@ -211,7 +211,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - partition = 1; - else - partition = 0; -- debug(DEBUG, "is_partitioned(): partition -> %d", partition); -+ debug("is_partitioned(): partition -> %d", partition); - - close(disk_fd); - } -@@ -226,13 +226,13 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - } - - if (options & EFIBOOT_ABBREV_NONE) -- debug(DEBUG, "EFIBOOT_ABBREV_NONE"); -+ debug("EFIBOOT_ABBREV_NONE"); - if (options & EFIBOOT_ABBREV_HD) -- debug(DEBUG, "EFIBOOT_ABBREV_HD"); -+ debug("EFIBOOT_ABBREV_HD"); - if (options & EFIBOOT_ABBREV_FILE) -- debug(DEBUG, "EFIBOOT_ABBREV_FILE"); -+ debug("EFIBOOT_ABBREV_FILE"); - if (options & EFIBOOT_ABBREV_EDD10) -- debug(DEBUG, "EFIBOOT_ABBREV_EDD10"); -+ debug("EFIBOOT_ABBREV_EDD10"); - - if (options & EFIBOOT_ABBREV_EDD10) { - va_list aq; -@@ -245,6 +245,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, - - if (!(options & (EFIBOOT_ABBREV_FILE|EFIBOOT_ABBREV_HD)) && - (dev->flags & DEV_ABBREV_ONLY)) { -+ efi_error_clear(); - errno = EINVAL; - efi_error("Device must use File() or HD() device path"); - goto err; -@@ -323,7 +324,7 @@ err: - if (fd >= 0) - close(fd); - errno = saved_errno; -- debug(DEBUG, "= %zd", ret); -+ debug("= %zd", ret); - return ret; - } - -diff --git a/src/dp-acpi.c b/src/dp-acpi.c -index a49ef38488c..6f3e94443e5 100644 ---- a/src/dp-acpi.c -+++ b/src/dp-acpi.c -@@ -51,9 +51,9 @@ _format_acpi_hid_ex(char *buf, size_t size, const char *dp_type UNUSED, - { - ssize_t off = 0; - -- debug(DEBUG, "hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr); -- debug(DEBUG, "cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr); -- debug(DEBUG, "uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr); -+ debug("hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr); -+ debug("cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr); -+ debug("uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr); - - if (!hidstr && !cidstr && (uidstr || dp->acpi_hid_ex.uid)) { - format(buf, size, off, "AcpiExp", -@@ -109,12 +109,12 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - // size_t cidlen = 0; - - if (dp->subtype == EFIDP_ACPI_ADR) { -- debug(DEBUG, "formatting ACPI _ADR"); -+ debug("formatting ACPI _ADR"); - format_acpi_adr(buf, size, off, dp); - return off; - } else if (dp->subtype != EFIDP_ACPI_HID_EX && - dp->subtype != EFIDP_ACPI_HID) { -- debug(DEBUG, "DP subtype %d, formatting as ACPI Path", dp->subtype); -+ debug("DP subtype %d, formatting as ACPI Path", dp->subtype); - format(buf, size, off, "AcpiPath", "AcpiPath(%d,", dp->subtype); - format_hex(buf, size, off, "AcpiPath", (uint8_t *)dp+4, - (efidp_node_size(dp)-4) / 2); -@@ -124,7 +124,7 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - ssize_t limit = efidp_node_size(dp) - - offsetof(efidp_acpi_hid_ex, hidstr); - -- debug(DEBUG, "formatting ACPI HID EX"); -+ debug("formatting ACPI HID EX"); - hidstr = dp->acpi_hid_ex.hidstr; - hidlen = strnlen(hidstr, limit); - limit -= hidlen + 1; -@@ -230,20 +230,20 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp) - break; - } - default: -- debug(DEBUG, "Decoding non-well-known HID"); -+ debug("Decoding non-well-known HID"); - switch (dp->subtype) { - case EFIDP_ACPI_HID_EX: - format_acpi_hid_ex(buf, size, off, dp, - hidstr, cidstr, uidstr); - break; - case EFIDP_ACPI_HID: -- debug(DEBUG, "Decoding ACPI HID"); -+ debug("Decoding ACPI HID"); - format(buf, size, off, "Acpi", - "Acpi(0x%08x,0x%"PRIx32")", - dp->acpi_hid.hid, dp->acpi_hid.uid); - break; - default: -- debug(DEBUG, "ACPI subtype %d???", -+ debug("ACPI subtype %d???", - dp->subtype); - errno = EINVAL; - return -1; -diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c -index e55af5fa385..06e69eebe78 100644 ---- a/src/linux-acpi-root.c -+++ b/src/linux-acpi-root.c -@@ -59,7 +59,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - /* - * find the ACPI root dunno0 and dunno1; they basically look like: -@@ -69,7 +69,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED - * side in sscanf. - */ - rc = sscanf(devpart, "../../devices/platform/%n", &pos); -- debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); -+ debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); - if (rc != 0 || pos < 1) - return 0; - devpart += pos; -@@ -100,15 +100,15 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED - return -1; - } - dev->acpi_root.acpi_hid_str[pos] = 0; -- debug(DEBUG, "acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str); -+ debug("acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str); - - pos -= 4; -- debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); -+ debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos); - acpi_header = strndupa(devpart, pos); - if (!acpi_header) - return 0; - acpi_header[pos] = 0; -- debug(DEBUG, "devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header); -+ debug("devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header); - devpart += pos; - - /* -@@ -119,26 +119,26 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED - efi_error("Could not parse ACPI path \"%s\"", devpart); - return 0; - } -- debug(DEBUG, "devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d", -+ debug("devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d", - devpart, pad0, pad1, pos, rc); - - devpart += pos; - - rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hX:%02hhX", - acpi_header, pad0, pad1); -- debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX", -+ debug("rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX", - rc, acpi_header, pad0, pad1); - if (rc < 0 && errno == ENOENT) { - rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hx:%02hhx", - acpi_header, pad0, pad1); -- debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx", -+ debug("rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx", - rc, acpi_header, pad0, pad1); - } - if (rc < 0) { - efi_error("Could not parse hid/uid"); - return rc; - } -- debug(DEBUG, "Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"", -+ debug("Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"", - dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid, - dev->acpi_root.acpi_uid_str, - dev->acpi_root.acpi_cid_str); -@@ -152,10 +152,10 @@ dp_create_acpi_root(struct device *dev, - { - ssize_t sz = 0, new = 0; - -- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -+ debug("entry buf:%p size:%zd off:%zd", buf, size, off); - - if (dev->acpi_root.acpi_uid_str || dev->acpi_root.acpi_cid_str) { -- debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"", -+ debug("creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"", - dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid, - dev->acpi_root.acpi_uid_str, dev->acpi_root.acpi_cid_str); - new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0, -@@ -170,7 +170,7 @@ dp_create_acpi_root(struct device *dev, - return new; - } - } else { -- debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, -+ debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, - dev->acpi_root.acpi_hid, - dev->acpi_root.acpi_uid); - new = efidp_make_acpi_hid(buf + off, size ? size - off : 0, -@@ -183,7 +183,7 @@ dp_create_acpi_root(struct device *dev, - } - sz += new; - -- debug(DEBUG, "returning %zd", sz); -+ debug("returning %zd", sz); - return sz; - } - -diff --git a/src/linux-acpi.c b/src/linux-acpi.c -index cb93a113ee2..3eac526525f 100644 ---- a/src/linux-acpi.c -+++ b/src/linux-acpi.c -@@ -39,12 +39,12 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...) - uint32_t acpi_hid = 0; - uint64_t acpi_uid_int = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - va_start(ap, fmt); - rc = vasprintfa(&path, fmt, ap); - va_end(ap); -- debug(DEBUG, "path:%s rc:%d", path, rc); -+ debug("path:%s rc:%d", path, rc); - if (rc < 0 || path == NULL) - return -1; - -@@ -54,7 +54,7 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...) - if (l > 1) { - fbuf[l-1] = 0; - dev->acpi_root.acpi_cid_str = strdup(fbuf); -- debug(DEBUG, "Setting ACPI root path to \"%s\"", fbuf); -+ debug("Setting ACPI root path to \"%s\"", fbuf); - } - } - -@@ -73,7 +73,7 @@ hid_err: - rc -= 4; - - rc = sscanf((char *)fbuf + rc, "%04hx", &tmp16); -- debug(DEBUG, "rc:%d hid:0x%08x\n", rc, tmp16); -+ debug("rc:%d hid:0x%08x\n", rc, tmp16); - if (rc != 1) - goto hid_err; - -@@ -88,7 +88,7 @@ hid_err: - if (acpi_hid == EFIDP_ACPI_PCIE_ROOT_HID) - acpi_hid = EFIDP_ACPI_PCI_ROOT_HID; - dev->acpi_root.acpi_hid = acpi_hid; -- debug(DEBUG, "acpi root HID:0x%08x", acpi_hid); -+ debug("acpi root HID:0x%08x", acpi_hid); - - errno = 0; - fbuf = NULL; -@@ -111,7 +111,7 @@ hid_err: - } - } - } -- debug(DEBUG, "acpi root UID:0x%"PRIx64" uidstr:\"%s\"", -+ debug("acpi root UID:0x%"PRIx64" uidstr:\"%s\"", - dev->acpi_root.acpi_uid, dev->acpi_root.acpi_uid_str); - - errno = 0; -diff --git a/src/linux-ata.c b/src/linux-ata.c -index dab02f3d224..32cb99361e5 100644 ---- a/src/linux-ata.c -+++ b/src/linux-ata.c -@@ -64,7 +64,7 @@ parse_ata(struct device *dev, const char *current, const char *root UNUSED) - uint64_t scsi_lun; - int pos; - -- debug(DEBUG, "entry"); -+ debug("entry"); - /* IDE disks can have up to 64 partitions, or 6 bits worth, - * and have one bit for the disk number. - * This leaves an extra bit at the top. -@@ -95,7 +95,7 @@ parse_ata(struct device *dev, const char *current, const char *root UNUSED) - dev->interface_type = ata; - set_part(dev, dev->minor & 0x3F); - } else { -- debug(DEBUG, "If this is ATA, it isn't using a traditional IDE inode."); -+ debug("If this is ATA, it isn't using a traditional IDE inode."); - } - - if (is_pata(dev)) { -@@ -136,7 +136,7 @@ dp_create_ata(struct device *dev, - { - ssize_t sz; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_atapi(buf + off, size ? size - off : 0, - dev->ata_info.scsi_device, -diff --git a/src/linux-i2o.c b/src/linux-i2o.c -index 4fe79e5719f..3ce25b957bf 100644 ---- a/src/linux-i2o.c -+++ b/src/linux-i2o.c -@@ -35,7 +35,7 @@ - static ssize_t - parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSED) - { -- debug(DEBUG, "entry"); -+ debug("entry"); - /* I2O disks can have up to 16 partitions, or 4 bits worth. */ - if (dev->major >= 80 && dev->major <= 87) { - dev->interface_type = i2o; -diff --git a/src/linux-nvme.c b/src/linux-nvme.c -index 00f53d5a9a7..ce931b7e237 100644 ---- a/src/linux-nvme.c -+++ b/src/linux-nvme.c -@@ -62,15 +62,15 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED) - spaces[pos0] = '\0'; - pos0 = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - -- debug(DEBUG, "searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1"); -+ debug("searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1"); - rc = sscanf(current, "nvme/nvme%d/nvme%dn%d%n/nvme%dn%dp%d%n", - &tosser0, &ctrl_id, &ns_id, &pos0, - &tosser1, &tosser2, &partition, &pos1); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -- arrow(DEBUG, spaces, 9, pos0, rc, 3); -- arrow(DEBUG, spaces, 9, pos1, rc, 6); -+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3); -+ arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6); - /* - * If it isn't of that form, it's not one of our nvme devices. - */ -@@ -130,7 +130,7 @@ dp_create_nvme(struct device *dev, - { - ssize_t sz; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_nvme(buf + off, size ? size - off : 0, - dev->nvme_info.ns_id, -diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c -index 8f556a066f3..269e30e2c31 100644 ---- a/src/linux-pci-root.c -+++ b/src/linux-pci-root.c -@@ -56,7 +56,7 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED) - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - /* - * find the pci root domain and port; they basically look like: -@@ -87,11 +87,11 @@ static ssize_t - dp_create_pci_root(struct device *dev UNUSED, - uint8_t *buf, ssize_t size, ssize_t off) - { -- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -- debug(DEBUG, "returning 0"); -+ debug("entry buf:%p size:%zd off:%zd", buf, size, off); -+ debug("returning 0"); - #if 0 - if (dev->acpi_root.acpi_uid_str) { -- debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"", -+ debug("creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"", - dev->acpi_root.acpi_hid, - dev->acpi_root.acpi_uid_str); - new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0, -@@ -104,7 +104,7 @@ dp_create_pci_root(struct device *dev UNUSED, - return new; - } - } else { -- debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, -+ debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64, - dev->acpi_root.acpi_hid, - dev->acpi_root.acpi_uid); - new = efidp_make_acpi_hid(buf + off, size ? size - off : 0, -@@ -118,7 +118,7 @@ dp_create_pci_root(struct device *dev UNUSED, - off += new; - sz += new; - -- debug(DEBUG, "returning %zd", sz); -+ debug("returning %zd", sz); - return sz; - #else - return 0; -diff --git a/src/linux-pci.c b/src/linux-pci.c -index 0f59d3e840d..e7c864b2d33 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -56,7 +56,7 @@ parse_pci(struct device *dev, const char *current, const char *root) - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - /* find the pci domain/bus/device/function: - * 0000:00:01.0/0000:01:00.0/ -@@ -69,16 +69,16 @@ parse_pci(struct device *dev, const char *current, const char *root) - unsigned int i = dev->n_pci_devs; - - pos = 0; -- debug(DEBUG, "searching for 0000:00:00.0/"); -+ debug("searching for 0000:00:00.0/"); - rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n", - &domain, &bus, &device, &function, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d", devpart, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 3); -+ debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3); - if (rc != 4) - break; - devpart += pos; - -- debug(DEBUG, "found pci domain %04hx:%02hhx:%02hhx.%02hhx", -+ debug("found pci domain %04hx:%02hhx:%02hhx.%02hhx", - domain, bus, device, function); - pci_dev = realloc(dev->pci_dev, - sizeof(*pci_dev) * (i + 1)); -@@ -108,11 +108,11 @@ parse_pci(struct device *dev, const char *current, const char *root) - } - free(tmp); - dev->pci_dev[i].driverlink = strdup(linkbuf); -- debug(DEBUG, "driver:%s\n", linkbuf); -+ debug("driver:%s\n", linkbuf); - dev->n_pci_devs += 1; - } - -- debug(DEBUG, "next:\"%s\"", devpart); -+ debug("next:\"%s\"", devpart); - return devpart - current; - } - -@@ -122,11 +122,11 @@ dp_create_pci(struct device *dev, - { - ssize_t sz = 0, new = 0; - -- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -+ debug("entry buf:%p size:%zd off:%zd", buf, size, off); - -- debug(DEBUG, "creating PCI device path nodes"); -+ debug("creating PCI device path nodes"); - for (unsigned int i = 0; i < dev->n_pci_devs; i++) { -- debug(DEBUG, "creating PCI device path node %u", i); -+ debug("creating PCI device path node %u", i); - new = efidp_make_pci(buf + off, size ? size - off : 0, - dev->pci_dev[i].pci_device, - dev->pci_dev[i].pci_function); -@@ -138,7 +138,7 @@ dp_create_pci(struct device *dev, - off += new; - } - -- debug(DEBUG, "returning %zd", sz); -+ debug("returning %zd", sz); - return sz; - } - -diff --git a/src/linux-pmem.c b/src/linux-pmem.c -index 9a075716f7f..4d981fc8ad3 100644 ---- a/src/linux-pmem.c -+++ b/src/linux-pmem.c -@@ -78,7 +78,7 @@ parse_pmem(struct device *dev, const char *current, const char *root UNUSED) - int ndbus, region, btt_region_id, btt_id, rc, pos; - char *namespace = NULL; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - if (!strcmp(dev->driver, "nd_pmem")) { - ; -@@ -121,7 +121,7 @@ parse_pmem(struct device *dev, const char *current, const char *root UNUSED) - return -1; - - filebuf = NULL; -- debug(DEBUG, "nvdimm namespace is \"%s\"", namespace); -+ debug("nvdimm namespace is \"%s\"", namespace); - rc = read_sysfs_file(&filebuf, "bus/nd/devices/%s/uuid", namespace); - free(namespace); - if (rc < 0 || filebuf == NULL) -@@ -165,7 +165,7 @@ dp_create_pmem(struct device *dev, - { - ssize_t sz, sz1; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_nvdimm(buf + off, size ? size - off : 0, - &dev->nvdimm_info.namespace_label); -diff --git a/src/linux-sas.c b/src/linux-sas.c -index 5f44f2c1f7b..4d77d39a24d 100644 ---- a/src/linux-sas.c -+++ b/src/linux-sas.c -@@ -55,7 +55,7 @@ parse_sas(struct device *dev, const char *current, const char *root UNUSED) - uint8_t *filebuf = NULL; - uint64_t sas_address; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - pos = parse_scsi_link(current, &scsi_host, - &scsi_bus, &scsi_device, -@@ -111,7 +111,7 @@ dp_create_sas(struct device *dev, - { - ssize_t sz; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_sas(buf + off, size ? size - off : 0, - dev->sas_info.sas_address); -diff --git a/src/linux-sata.c b/src/linux-sata.c -index d9a62efdbe6..85265022f89 100644 ---- a/src/linux-sata.c -+++ b/src/linux-sata.c -@@ -156,9 +156,9 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED) - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - if (is_pata(dev)) { -- debug(DEBUG, "This is a PATA device; skipping."); -+ debug("This is a PATA device; skipping."); - return 0; - } - -@@ -166,10 +166,10 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED) - * ata1/host0/target0:0:0/0:0:0:0 - * ^dev ^host x y z - */ -- debug(DEBUG, "searching for ata1/"); -+ debug("searching for ata1/"); - rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 1); -+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1); - /* - * If we don't find this one, it isn't an ata device, so return 0 not - * error. Later errors mean it is an ata device, but we can't parse -@@ -180,30 +180,30 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED) - current += pos; - pos = 0; - -- debug(DEBUG, "searching for host0/"); -+ debug("searching for host0/"); - rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 1); -+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1); - if (rc != 1) - return -1; - current += pos; - pos = 0; - -- debug(DEBUG, "searching for target0:0:0:0/"); -+ debug("searching for target0:0:0:0/"); - rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n", - &scsi_device, &scsi_target, &scsi_lun, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 3); -+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3); - if (rc != 3) - return -1; - current += pos; - pos = 0; - -- debug(DEBUG, "searching for 0:0:0:0/"); -+ debug("searching for 0:0:0:0/"); - rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n", - &tosser0, &tosser1, &tosser2, &tosser3, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 4); -+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 4); - if (rc != 4) - return -1; - current += pos; -@@ -229,7 +229,7 @@ dp_create_sata(struct device *dev, - { - ssize_t sz = -1; - -- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off); -+ debug("entry buf:%p size:%zd off:%zd", buf, size, off); - - if (dev->interface_type == ata || dev->interface_type == atapi) { - sz = efidp_make_atapi(buf + off, size ? size - off : 0, -diff --git a/src/linux-scsi.c b/src/linux-scsi.c -index 153a4ff87ad..80c2fb7d82e 100644 ---- a/src/linux-scsi.c -+++ b/src/linux-scsi.c -@@ -51,7 +51,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - spaces[sz] = '\0'; - sz = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - /* - * This structure is completely ridiculous. - * -@@ -82,21 +82,21 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - * host4/port-4:0 - * or host4/port-4:0:0 - */ -- debug(DEBUG, "searching for host4/"); -+ debug("searching for host4/"); - rc = sscanf(current, "host%d/%n", scsi_host, &pos0); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -- arrow(DEBUG, spaces, 9, pos0, rc, 1); -+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1); - if (rc != 1) - return -1; - sz += pos0; - pos0 = 0; - -- debug(DEBUG, "searching for port-4:0 or port-4:0:0"); -+ debug("searching for port-4:0 or port-4:0:0"); - rc = sscanf(current, "port-%d:%d%n:%d%n", &tosser0, - &tosser1, &pos0, &tosser2, &pos1); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1); -- arrow(DEBUG, spaces, 9, pos0, rc, 2); -- arrow(DEBUG, spaces, 9, pos1, rc, 3); -+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2); -+ arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3); - if (rc == 2 || rc == 3) { - sz += pos0; - pos0 = 0; -@@ -107,18 +107,18 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - * awesomely these are the exact same fields that go into port-blah, - * but we don't care for now about any of them anyway. - */ -- debug(DEBUG, "searching for /end_device-4:0/ or /end_device-4:0:0/"); -+ debug("searching for /end_device-4:0/ or /end_device-4:0:0/"); - rc = sscanf(current + sz, "/end_device-%d:%d%n", &tosser0, &tosser1, &pos0); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -- arrow(DEBUG, spaces, 9, pos0, rc, 2); -+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2); - if (rc != 2) - return -1; - sz += pos0; - pos0 = 0; - - rc = sscanf(current + sz, ":%d%n", &tosser0, &pos0); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -- arrow(DEBUG, spaces, 9, pos0, rc, 2); -+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2); - if (rc != 0 && rc != 1) - return -1; - sz += pos0; -@@ -134,11 +134,11 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - * /target4:0:0/ - */ - uint64_t tosser3; -- debug(DEBUG, "searching for target4:0:0/"); -+ debug("searching for target4:0:0/"); - rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1, - &tosser3, &pos0); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -- arrow(DEBUG, spaces, 9, pos0, rc, 3); -+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3); - if (rc != 3) - return -1; - sz += pos0; -@@ -147,11 +147,11 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - /* now: - * %d:%d:%d:%llu/ - */ -- debug(DEBUG, "searching for 4:0:0:0/"); -+ debug("searching for 4:0:0:0/"); - rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n", - scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -- arrow(DEBUG, spaces, 9, pos0, rc, 4); -+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4); - if (rc != 4) - return -1; - sz += pos0; -@@ -175,17 +175,17 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED) - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - -- debug(DEBUG, "searching for ../../../0:0:0:0"); -+ debug("searching for ../../../0:0:0:0"); - rc = sscanf(dev->device, "../../../%d:%d:%d:%"PRIu64"%n", - &dev->scsi_info.scsi_bus, - &dev->scsi_info.scsi_device, - &dev->scsi_info.scsi_target, - &dev->scsi_info.scsi_lun, - &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 3); -+ debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3); - if (rc != 4) - return 0; - -@@ -225,7 +225,7 @@ dp_create_scsi(struct device *dev, - { - ssize_t sz = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_scsi(buf + off, size ? size - off : 0, - dev->scsi_info.scsi_target, -diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c -index 57dd9b04f2c..394f496a453 100644 ---- a/src/linux-soc-root.c -+++ b/src/linux-soc-root.c -@@ -51,13 +51,13 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - rc = sscanf(devpart, "../../devices/platform/soc/%*[^/]/%n", &pos); - if (rc != 0) - return 0; - devpart += pos; -- debug(DEBUG, "new position is \"%s\"", devpart); -+ debug("new position is \"%s\"", devpart); - - return devpart - current; - } -diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c -index 9ee7994aeb3..c54a813a947 100644 ---- a/src/linux-virtblk.c -+++ b/src/linux-virtblk.c -@@ -58,12 +58,12 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED) - spaces[pos] = '\0'; - pos = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - -- debug(DEBUG, "searching for virtio0/"); -+ debug("searching for virtio0/"); - rc = sscanf(current, "virtio%x/%n", &tosser, &pos); -- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -- arrow(DEBUG, spaces, 9, pos, rc, 1); -+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos); -+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1); - /* - * If we couldn't find virtioX/ then it isn't a virtio device. - */ -diff --git a/src/linux.c b/src/linux.c -index 8fe21f19f78..f919dee5b67 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -178,12 +178,12 @@ set_disk_and_part_name(struct device *dev) - char *proximate = pathseg(dev->link, -4); - - errno = 0; -- debug(DEBUG, "dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name); -- debug(DEBUG, "dev->part:%d", dev->part); -- debug(DEBUG, "ultimate:\"%s\"", ultimate ? : ""); -- debug(DEBUG, "penultimate:\"%s\"", penultimate ? : ""); -- debug(DEBUG, "approximate:\"%s\"", approximate ? : ""); -- debug(DEBUG, "proximate:\"%s\"", proximate ? : ""); -+ debug("dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name); -+ debug("dev->part:%d", dev->part); -+ debug("ultimate:\"%s\"", ultimate ? : ""); -+ debug("penultimate:\"%s\"", penultimate ? : ""); -+ debug("approximate:\"%s\"", approximate ? : ""); -+ debug("proximate:\"%s\"", proximate ? : ""); - - if (ultimate && penultimate && - ((proximate && !strcmp(proximate, "nvme")) || -@@ -197,14 +197,14 @@ set_disk_and_part_name(struct device *dev) - */ - set_disk_name(dev, "%s", penultimate); - set_part_name(dev, "%s", ultimate); -- debug(DEBUG, "disk:%s part:%s", penultimate, ultimate); -+ debug("disk:%s part:%s", penultimate, ultimate); - } else if (ultimate && approximate && !strcmp(approximate, "nvme")) { - /* - * 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1 - */ - set_disk_name(dev, "%s", ultimate); - set_part_name(dev, "%sp%d", ultimate, dev->part); -- debug(DEBUG, "disk:%s part:%sp%d", ultimate, ultimate, dev->part); -+ debug("disk:%s part:%sp%d", ultimate, ultimate, dev->part); - } else if (ultimate && penultimate && !strcmp(penultimate, "block")) { - /* - * 253:0 -> ../../devices/virtual/block/dm-0 (... I guess) -@@ -217,13 +217,13 @@ set_disk_and_part_name(struct device *dev) - */ - set_disk_name(dev, "%s", ultimate); - set_part_name(dev, "%s%d", ultimate, dev->part); -- debug(DEBUG, "disk:%s part:%s%d", ultimate, ultimate, dev->part); -+ debug("disk:%s part:%s%d", ultimate, ultimate, dev->part); - } else if (ultimate && approximate && !strcmp(approximate, "mtd")) { - /* - * 31:0 -> ../../devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi32766/spi32766.0/mtd/mtd0/mtdblock0 - */ - set_disk_name(dev, "%s", ultimate); -- debug(DEBUG, "disk:%s", ultimate); -+ debug("disk:%s", ultimate); - } - - return 0; -@@ -321,7 +321,7 @@ struct device HIDDEN - } - - dev->part = partition; -- debug(DEBUG, "partition:%d dev->part:%d", partition, dev->part); -+ debug("partition:%d dev->part:%d", partition, dev->part); - dev->probes = calloc(nmemb, sizeof(struct dev_probe *)); - if (!dev->probes) { - efi_error("could not allocate %zd bytes", -@@ -362,7 +362,7 @@ struct device HIDDEN - efi_error("strdup(\"%s\") failed", linkbuf); - goto err; - } -- debug(DEBUG, "dev->link: %s", dev->link); -+ debug("dev->link: %s", dev->link); - - if (dev->part == -1) { - rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link); -@@ -380,8 +380,8 @@ struct device HIDDEN - efi_error("could not set disk and partition names"); - goto err; - } -- debug(DEBUG, "dev->disk_name: %s", dev->disk_name); -- debug(DEBUG, "dev->part_name: %s", dev->part_name); -+ debug("dev->disk_name: %s", dev->disk_name); -+ debug("dev->part_name: %s", dev->part_name); - - rc = sysfs_readlink(&tmpbuf, "block/%s/device", dev->disk_name); - if (rc < 0 || !tmpbuf) { -@@ -431,25 +431,25 @@ struct device HIDDEN - bool needs_root = true; - int last_successful_probe = -1; - -- debug(DEBUG, "searching for device nodes in %s", dev->link); -+ debug("searching for device nodes in %s", dev->link); - for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) { - struct dev_probe *probe = dev_probes[i]; - ssize_t pos; - - if (!needs_root && - (probe->flags & DEV_PROVIDES_ROOT)) { -- debug(DEBUG, "not testing %s because flags is 0x%x", -+ debug("not testing %s because flags is 0x%x", - probe->name, probe->flags); - continue; - } - -- debug(DEBUG, "trying %s", probe->name); -+ debug("trying %s", probe->name); - pos = probe->parse(dev, current, dev->link); - if (pos < 0) { - efi_error("parsing %s failed", probe->name); - goto err; - } else if (pos > 0) { -- debug(DEBUG, "%s matched %s", probe->name, current); -+ debug("%s matched %s", probe->name, current); - dev->flags |= probe->flags; - - if (probe->flags & DEV_PROVIDES_HD || -@@ -459,7 +459,7 @@ struct device HIDDEN - - dev->probes[n++] = dev_probes[i]; - current += pos; -- debug(DEBUG, "current:%s", current); -+ debug("current:%s", current); - last_successful_probe = i; - - if (!*current || !strncmp(current, "block/", 6)) -@@ -468,7 +468,7 @@ struct device HIDDEN - continue; - } - -- debug(DEBUG, "dev_probes[i+1]: %p dev->interface_type: %d\n", -+ debug("dev_probes[i+1]: %p dev->interface_type: %d\n", - dev_probes[i+1], dev->interface_type); - if (dev_probes[i+1] == NULL && dev->interface_type == unknown) { - int new_pos = 0; -@@ -479,12 +479,9 @@ struct device HIDDEN - current); - goto err; - } -- debug(DEBUG, -- "Cannot parse device link segment \"%s\"", -- current); -- debug(DEBUG, "Skipping to \"%s\"", current + new_pos); -- debug(DEBUG, -- "This means we can only write abbreviated paths"); -+ debug("Cannot parse device link segment \"%s\"", current); -+ debug("Skipping to \"%s\"", current + pos); -+ debug("This means we can only create abbreviated paths"); - if (rc < 0) - goto err; - if (new_pos == 0) -@@ -512,7 +509,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct device *dev) - { - ssize_t off = 0; - -- debug(DEBUG, "entry buf:%p size:%zd", buf, size); -+ debug("entry buf:%p size:%zd", buf, size); - - for (unsigned int i = 0; dev->probes[i] && - dev->probes[i]->parse; i++) { -@@ -531,7 +528,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct device *dev) - off += sz; - } - -- debug(DEBUG, "= %zd", off); -+ debug("= %zd", off); - - return off; - } -diff --git a/src/loadopt.c b/src/loadopt.c -index 23911f6e742..85fb646d107 100644 ---- a/src/loadopt.c -+++ b/src/loadopt.c -@@ -46,7 +46,7 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes, - + sizeof (uint16_t) + desc_len - + dp_size + optional_data_size; - -- debug(DEBUG, "entry buf:%p size:%zd dp:%p dp_size:%zd", -+ debug("entry buf:%p size:%zd dp:%p dp_size:%zd", - buf, size, dp, dp_size); - - if (size == 0) -@@ -57,31 +57,30 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes, - return -1; - } - -- debug(DEBUG, "testing buf"); -+ debug("testing buf"); - if (!buf) { - invalid: - errno = EINVAL; - return -1; - } - -- debug(DEBUG, "testing optional data presence"); -+ debug("testing optional data presence"); - if (!optional_data && optional_data_size != 0) - goto invalid; - -- debug(DEBUG, "testing dp presence"); -+ debug("testing dp presence"); - if ((!dp && dp_size == 0) || dp_size < 0) - goto invalid; - - if (dp) { -- debug(DEBUG, "testing dp validity"); -+ debug("testing dp validity"); - if (!efidp_is_valid(dp, dp_size)) { - if (efi_get_verbose() >= 1) - hexdump((void *)dp, dp_size); - goto invalid; - } - -- debug(DEBUG, -- "testing dp size: dp_size:%zd efidp_size(dp):%zd", -+ debug("testing dp size: dp_size:%zd efidp_size(dp):%zd", - dp_size, efidp_size(dp)); - if (efidp_size(dp) != dp_size) { - if (efi_get_verbose() >= 1) -diff --git a/src/util.h b/src/util.h -index 441ced84fcf..f63a8907611 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -360,7 +360,7 @@ swizzle_guid_to_uuid(efi_guid_t *guid) - u16[1] = __builtin_bswap16(u16[1]); - } - --#define debug_(file, line, func, level, fmt, args...) \ -+#define log_(file, line, func, level, fmt, args...) \ - ({ \ - if (efi_get_verbose() >= level) { \ - FILE *logfile_ = efi_get_logfile(); \ -@@ -373,9 +373,13 @@ swizzle_guid_to_uuid(efi_guid_t *guid) - } \ - }) - --#define debug(level, fmt, args...) debug_(__FILE__, __LINE__, __func__, level, fmt, ## args) --#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';debug(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}}) -- --#define DEBUG 1 -+#define LOG_VERBOSE 0 -+#define LOG_DEBUG 1 -+#ifdef log -+#undef log -+#endif -+#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args) -+#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';log(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}}) -+#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args) - - #endif /* EFIVAR_UTIL_H */ --- -2.17.1 - diff --git a/0020-efiboot-Make-the-device-node-skipping-code-pass-cove.patch b/0020-efiboot-Make-the-device-node-skipping-code-pass-cove.patch deleted file mode 100644 index 64c2bbc..0000000 --- a/0020-efiboot-Make-the-device-node-skipping-code-pass-cove.patch +++ /dev/null @@ -1,79 +0,0 @@ -From bc11451222cc77d8c1b4e752167adabd3c7f64c9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 13:33:26 -0400 -Subject: [PATCH 20/34] efiboot: Make the device node skipping code pass - coverity. - -Signed-off-by: Peter Jones ---- - src/linux.c | 31 ++++++++++++++++++------------- - 1 file changed, 18 insertions(+), 13 deletions(-) - -diff --git a/src/linux.c b/src/linux.c -index f919dee5b67..6d20c2dbe25 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -308,7 +308,8 @@ struct device HIDDEN - { - struct device *dev; - char *linkbuf = NULL, *tmpbuf = NULL; -- unsigned int i, n = 0; -+ int i = 0; -+ unsigned int n = 0; - int rc; - - size_t nmemb = (sizeof(dev_probes) -@@ -432,9 +433,11 @@ struct device HIDDEN - int last_successful_probe = -1; - - debug("searching for device nodes in %s", dev->link); -- for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) { -+ for (i = 0; -+ dev_probes[i] && dev_probes[i]->parse && *current; -+ i++) { - struct dev_probe *probe = dev_probes[i]; -- ssize_t pos; -+ int pos; - - if (!needs_root && - (probe->flags & DEV_PROVIDES_ROOT)) { -@@ -471,24 +474,26 @@ struct device HIDDEN - debug("dev_probes[i+1]: %p dev->interface_type: %d\n", - dev_probes[i+1], dev->interface_type); - if (dev_probes[i+1] == NULL && dev->interface_type == unknown) { -- int new_pos = 0; -- rc = sscanf(current, "%*[^/]/%n", &new_pos); -+ pos = 0; -+ rc = sscanf(current, "%*[^/]/%n", &pos); - if (rc < 0) { -- efi_error( -- "Cannot parse device link segment \"%s\"", -- current); -+slash_err: -+ efi_error("Cannot parse device link segment \"%s\"", current); - goto err; - } -+ -+ while (current[pos] == '/') -+ pos += 1; -+ -+ if (!current[pos]) -+ goto slash_err; -+ - debug("Cannot parse device link segment \"%s\"", current); - debug("Skipping to \"%s\"", current + pos); - debug("This means we can only create abbreviated paths"); -- if (rc < 0) -- goto err; -- if (new_pos == 0) -- goto err; - dev->flags |= DEV_ABBREV_ONLY; - i = last_successful_probe; -- current += new_pos; -+ current += pos; - } - } - --- -2.17.1 - diff --git a/0021-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch b/0021-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch deleted file mode 100644 index 47e3029..0000000 --- a/0021-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 22b1a7477c5ef72821e6491c67ad85ca52c1ae85 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 13:55:32 -0400 -Subject: [PATCH 21/34] efiboot: don't error on unknown type with - DEV_ABBREV_ONLY - -Signed-off-by: Peter Jones ---- - src/linux.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/src/linux.c b/src/linux.c -index 6d20c2dbe25..7fac339c50e 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -494,10 +494,15 @@ slash_err: - dev->flags |= DEV_ABBREV_ONLY; - i = last_successful_probe; - current += pos; -+ -+ if (!*current || !strncmp(current, "block/", 6)) -+ break; - } - } - -- if (dev->interface_type == unknown) { -+ if (dev->interface_type == unknown && -+ !(dev->flags & DEV_ABBREV_ONLY) && -+ !strcmp(current, "block/")) { - efi_error("unknown storage interface"); - errno = ENOSYS; - goto err; --- -2.17.1 - diff --git a/0022-efiboot-fix-a-bad-error-check.patch b/0022-efiboot-fix-a-bad-error-check.patch deleted file mode 100644 index a6b2170..0000000 --- a/0022-efiboot-fix-a-bad-error-check.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 6d87113fc3d9b2b0f520fc97eab9f5a60fda7d30 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 13:55:45 -0400 -Subject: [PATCH 22/34] efiboot: fix a bad error check - -Signed-off-by: Peter Jones ---- - src/linux-acpi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/linux-acpi.c b/src/linux-acpi.c -index 3eac526525f..88f0084a37e 100644 ---- a/src/linux-acpi.c -+++ b/src/linux-acpi.c -@@ -93,7 +93,7 @@ hid_err: - errno = 0; - fbuf = NULL; - rc = read_sysfs_file(&fbuf, "%s/firmware_node/uid", path); -- if ((rc <= 0 && errno != ENOENT) || fbuf == NULL) { -+ if ((rc < 0 && errno != ENOENT) || (rc > 0 && fbuf == NULL)) { - efi_error("could not read %s/firmware_node/uid", path); - return -1; - } --- -2.17.1 - diff --git a/0023-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch b/0023-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch deleted file mode 100644 index 4c94460..0000000 --- a/0023-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 50e8c66f92b2d93d20c2524936f6858fd2b07afe Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 14:23:40 -0400 -Subject: [PATCH 23/34] efiboot: parse_scsi_link(): fix the offset searching - for the port - -Signed-off-by: Peter Jones ---- - src/linux-scsi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/linux-scsi.c b/src/linux-scsi.c -index 80c2fb7d82e..2e4f710badf 100644 ---- a/src/linux-scsi.c -+++ b/src/linux-scsi.c -@@ -92,7 +92,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host, - pos0 = 0; - - debug("searching for port-4:0 or port-4:0:0"); -- rc = sscanf(current, "port-%d:%d%n:%d%n", &tosser0, -+ rc = sscanf(current+sz, "port-%d:%d%n:%d%n", &tosser0, - &tosser1, &pos0, &tosser2, &pos1); - debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1); - arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2); --- -2.17.1 - diff --git a/0024-Coverity-still-doesn-t-believe-in-error-codes.patch b/0024-Coverity-still-doesn-t-believe-in-error-codes.patch deleted file mode 100644 index 02b4467..0000000 --- a/0024-Coverity-still-doesn-t-believe-in-error-codes.patch +++ /dev/null @@ -1,28 +0,0 @@ -From c2223eb4638c6d8562626917651a11b8aa1e8f9e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 16:18:32 -0400 -Subject: [PATCH 24/34] Coverity still doesn't believe in error codes... - -So also test fbuf here. - -Signed-off-by: Peter Jones ---- - src/linux-acpi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/linux-acpi.c b/src/linux-acpi.c -index 88f0084a37e..346eba09041 100644 ---- a/src/linux-acpi.c -+++ b/src/linux-acpi.c -@@ -49,7 +49,7 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...) - return -1; - - rc = read_sysfs_file(&fbuf, "%s/firmware_node/path", path); -- if (rc > 0) { -+ if (rc > 0 && fbuf) { - size_t l = strlen(fbuf); - if (l > 1) { - fbuf[l-1] = 0; --- -2.17.1 - diff --git a/0025-Don-t-require-NVME-to-have-an-EUI.patch b/0025-Don-t-require-NVME-to-have-an-EUI.patch deleted file mode 100644 index 46b5cbc..0000000 --- a/0025-Don-t-require-NVME-to-have-an-EUI.patch +++ /dev/null @@ -1,28 +0,0 @@ -From d8d7e54fe01a7a255e649a7734820800edf82633 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 16 Jul 2018 15:40:22 -0400 -Subject: [PATCH 25/34] Don't require NVME to have an EUI - -Resolves: rhbz#1593784 - -Signed-off-by: Peter Jones ---- - src/linux-nvme.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/src/linux-nvme.c b/src/linux-nvme.c -index ce931b7e237..d68d11a3409 100644 ---- a/src/linux-nvme.c -+++ b/src/linux-nvme.c -@@ -117,8 +117,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED) - } - dev->nvme_info.has_eui = 1; - memcpy(dev->nvme_info.eui, eui, sizeof(eui)); -- } else { -- return -1; - } - - return pos0; --- -2.17.1 - diff --git a/0026-makeguids-initialize-memory.patch b/0026-makeguids-initialize-memory.patch deleted file mode 100644 index 2418d6a..0000000 --- a/0026-makeguids-initialize-memory.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 50d7b979d1aa1c4afbb60a702bd16f9ff3066c50 Mon Sep 17 00:00:00 2001 -From: "Bernhard M. Wiedemann" -Date: Tue, 24 Jul 2018 09:34:21 +0200 -Subject: [PATCH 26/34] makeguids: initialize memory - -so that we do not write uninitialized memory into guids.bin and names.bin -which made the resulting libefivar.so.1.36 unreproducible. -See https://reproducible-builds.org/ for why this matters. ---- - src/makeguids.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/makeguids.c b/src/makeguids.c -index f84fbb81166..a15356b152e 100644 ---- a/src/makeguids.c -+++ b/src/makeguids.c -@@ -147,6 +147,7 @@ main(int argc, char *argv[]) - outbuf = realloc(outbuf, line * sizeof (struct guidname)); - if (!outbuf) - err(1, "makeguids"); -+ memset(outbuf + line - 1, 0, sizeof(struct guidname)); - - char *symbol = strchr(guidstr, '\t'); - if (symbol == NULL) --- -2.17.1 - diff --git a/0027-emmc_parser-add-emmc_parser.patch b/0027-emmc_parser-add-emmc_parser.patch deleted file mode 100644 index 7807fe0..0000000 --- a/0027-emmc_parser-add-emmc_parser.patch +++ /dev/null @@ -1,255 +0,0 @@ -From d6a526a0c819c439a894af625f45b657576f8744 Mon Sep 17 00:00:00 2001 -From: Alek Du -Date: Fri, 27 Jul 2018 21:31:01 +0800 -Subject: [PATCH 27/34] emmc_parser: add emmc_parser - -Signed-off-by: Alek Du ---- - src/dp-message.c | 18 +++++ - src/linux-emmc.c | 129 +++++++++++++++++++++++++++++++++ - src/linux.c | 1 + - src/include/efivar/efivar-dp.h | 2 + - src/linux.h | 7 ++ - src/libefivar.map.in | 1 + - 6 files changed, 158 insertions(+) - create mode 100644 src/linux-emmc.c - -diff --git a/src/dp-message.c b/src/dp-message.c -index 5af66438bfc..3724e5f57bd 100644 ---- a/src/dp-message.c -+++ b/src/dp-message.c -@@ -826,3 +826,21 @@ efidp_make_nvdimm(uint8_t *buf, ssize_t size, efi_guid_t *uuid) - - return sz; - } -+ -+ssize_t PUBLIC -+efidp_make_emmc(uint8_t *buf, ssize_t size, uint32_t slot_id) -+{ -+ efidp_emmc *emmc = (efidp_emmc *)buf; -+ ssize_t req = sizeof (*emmc); -+ ssize_t sz; -+ -+ sz = efidp_make_generic(buf, size, EFIDP_MESSAGE_TYPE, -+ EFIDP_MSG_NVME, sizeof (*emmc)); -+ if (size && sz == req) -+ emmc->slot = slot_id; -+ -+ if (sz < 0) -+ efi_error("efidp_make_generic failed"); -+ -+ return sz; -+} -diff --git a/src/linux-emmc.c b/src/linux-emmc.c -new file mode 100644 -index 00000000000..f0c9e635cb6 ---- /dev/null -+++ b/src/linux-emmc.c -@@ -0,0 +1,129 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+/* -+ * support for emmc devices -+ * -+ * /sys/dev/block/$major:$minor looks like: -+ * 179:0 -> ../../devices/pci0000:00/0000:00:1c.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0 -+ * 179:1 -> ../../devices/pci0000:00/0000:00:1c.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 -+ * -+ * /sys/dev/block/179:0/device looks like: -+ * device -> ../../../mmc0:0001 -+ * -+ * /sys/dev/block/179:1/partition looks like: -+ * $ cat partition -+ * 1 -+ * -+ */ -+ -+static ssize_t -+parse_emmc(struct device *dev, const char *current, const char *root UNUSED) -+{ -+ int rc; -+ int32_t tosser0, tosser1, tosser2, tosser3, slot_id, partition; -+ int pos0 = 0, pos1 = 0; -+ char *spaces; -+ -+ pos0 = strlen(current); -+ spaces = alloca(pos0+1); -+ memset(spaces, ' ', pos0+1); -+ spaces[pos0] = '\0'; -+ pos0 = 0; -+ -+ debug(DEBUG, "entry"); -+ -+ debug(DEBUG, "searching for mmc_host/mmc0/mmc0:0001/block/mmcblk0 or mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1"); -+ rc = sscanf(current, "mmc_host/mmc%d/mmc%d:%d/block/mmcblk%d%n/mmcblk%dp%d%n", -+ &tosser0, &tosser1, &tosser2, &slot_id, -+ &pos0, &tosser3, &partition, &pos1); -+ debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -+ arrow(DEBUG, spaces, 9, pos0, rc, 4); -+ arrow(DEBUG, spaces, 9, pos1, rc, 6); -+ /* -+ * If it isn't of that form, it's not one of our emmc devices. -+ */ -+ if (rc != 4 && rc != 6) -+ return 0; -+ -+ dev->emmc_info.slot_id = slot_id; -+ dev->interface_type = emmc; -+ -+ if (rc == 6) { -+ if (dev->part == -1) -+ dev->part = partition; -+ -+ pos0 = pos1; -+ } -+ -+ return pos0; -+} -+ -+static ssize_t -+dp_create_emmc(struct device *dev, -+ uint8_t *buf, ssize_t size, ssize_t off) -+{ -+ ssize_t sz; -+ -+ debug(DEBUG, "entry"); -+ -+ sz = efidp_make_emmc(buf + off, size ? size - off : 0, -+ dev->emmc_info.slot_id); -+ return sz; -+} -+ -+static char * -+make_part_name(struct device *dev) -+{ -+ char *ret = NULL; -+ ssize_t rc; -+ -+ if (dev->part < 1) -+ return NULL; -+ -+ rc = asprintf(&ret, "%sp%d", dev->disk_name, dev->part); -+ if (rc < 0) { -+ efi_error("could not allocate memory"); -+ return NULL; -+ } -+ -+ return ret; -+} -+ -+static enum interface_type emmc_iftypes[] = { emmc, unknown }; -+ -+struct dev_probe HIDDEN emmc_parser = { -+ .name = "emmc", -+ .iftypes = emmc_iftypes, -+ .flags = DEV_PROVIDES_HD, -+ .parse = parse_emmc, -+ .create = dp_create_emmc, -+ .make_part_name = make_part_name, -+}; -diff --git a/src/linux.c b/src/linux.c -index 7fac339c50e..ff8db812ad3 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -246,6 +246,7 @@ static struct dev_probe *dev_probes[] = { - &ata_parser, - &scsi_parser, - &i2o_parser, -+ &emmc_parser, - NULL - }; - -diff --git a/src/include/efivar/efivar-dp.h b/src/include/efivar/efivar-dp.h -index 1b05775ae7e..f9ebb059d06 100644 ---- a/src/include/efivar/efivar-dp.h -+++ b/src/include/efivar/efivar-dp.h -@@ -689,6 +689,8 @@ typedef struct { - uint8_t slot; - } EFIVAR_PACKED efidp_emmc; - -+extern ssize_t efidp_make_emmc(uint8_t *buf, ssize_t size, uint32_t slot_id); -+ - #define EFIDP_MSG_BTLE 0x1e - typedef struct { - efidp_header header; -diff --git a/src/linux.h b/src/linux.h -index 99d61013e02..7c7ea91e771 100644 ---- a/src/linux.h -+++ b/src/linux.h -@@ -93,6 +93,10 @@ struct nvdimm_info { - efi_guid_t nvdimm_label; - }; - -+struct emmc_info { -+ int32_t slot_id; -+}; -+ - enum interface_type { - unknown, - isa, acpi_root, pci_root, soc_root, pci, network, -@@ -100,6 +104,7 @@ enum interface_type { - usb, i1394, fibre, i2o, - md, virtblk, - nvme, nd_pmem, -+ emmc, - }; - - struct dev_probe; -@@ -139,6 +144,7 @@ struct device { - struct sata_info sata_info; - struct ata_info ata_info; - struct nvme_info nvme_info; -+ struct emmc_info emmc_info; - struct nvdimm_info nvdimm_info; - }; - }; -@@ -277,5 +283,6 @@ extern struct dev_probe virtblk_parser; - extern struct dev_probe i2o_parser; - extern struct dev_probe scsi_parser; - extern struct dev_probe ata_parser; -+extern struct dev_probe emmc_parser; - - #endif /* _EFIBOOT_LINUX_H */ -diff --git a/src/libefivar.map.in b/src/libefivar.map.in -index 31f696d3cb5..b5ee1ce334a 100644 ---- a/src/libefivar.map.in -+++ b/src/libefivar.map.in -@@ -51,6 +51,7 @@ libefivar.so.0 { - efidp_make_sata; - efidp_make_scsi; - efidp_make_vendor; -+ efidp_make_emmc; - efidp_parse_device_node; - efidp_parse_device_path; - efidp_set_node_data; --- -2.17.1 - diff --git a/0028-abignore-work-around-an-abidw-bug.patch b/0028-abignore-work-around-an-abidw-bug.patch deleted file mode 100644 index 77c1f52..0000000 --- a/0028-abignore-work-around-an-abidw-bug.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 1f385ff1bde1e783eba03df37af9421bac0df82b Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 3 Aug 2018 09:56:01 -0400 -Subject: [PATCH 28/34] abignore: work around an abidw bug - -Some versions of abignore mistakenly treat brackets as section headers, -thus ignoring the rest of the stanza after them. It's fixed upstream, -but I don't have the newer version yet. Moving the braces to be after -the change-kind and other things works around the issue. - -Signed-off-by: Peter Jones ---- - src/abignore | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/abignore b/src/abignore -index a4597b1029c..1badb2dab35 100644 ---- a/src/abignore -+++ b/src/abignore -@@ -14,28 +14,28 @@ - # 'efidp_wifi __anonymous_union__::wifi' at efivar-dp.h:868:1 - # - [suppress_type] -- soname_regexp = libefi(var|boot)\\.so\\..* - name = efidp_data - type_kind = typedef - has_data_member_inserted_at = end -+ soname_regexp = libefi(var|boot)\\.so\\..* - - # 1 Added variable: - # - # 'const __anonymous_struct__ efi_guid_ux_capsule' {efi_guid_ux_capsule@@LIBEFIVAR_1.33} - # - [suppress_variable] -+ change_kind = added-variable - soname_regexp = libefivar\\.so\\..* - symbol_name_regexp = ^efi_guid_[[:alnum:]_]+$ -- change_kind = added-variable - - # allow new functions that are prefixed correctly - [suppress_function] -+ change_kind = added-function - soname_regexp = ^libefi(var|boot)\\.so\\..* - name_regexp = ^(efidp_|efi_)[[:alnum:]_]+ -- change_kind = added-function - - # allow new variables that are prefixed correctly - [suppress_variable] -+ change_kind = added-variable - soname_regexp = libefi(var|boot)\\.so\\..* - symbol_name_regexp = ^(efidp_|efi_)[[:alnum:]_]+ -- change_kind = added-variable --- -2.17.1 - diff --git a/0029-Update-abidw-for-newer-tools.patch b/0029-Update-abidw-for-newer-tools.patch deleted file mode 100644 index 8b2b739..0000000 --- a/0029-Update-abidw-for-newer-tools.patch +++ /dev/null @@ -1,1780 +0,0 @@ -From cdb840bc122ff1527416becdf1922962c0251df9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 8 Jun 2018 15:14:27 -0400 -Subject: [PATCH 29/34] Update abidw for newer tools. - -Signed-off-by: Peter Jones ---- - src/libefiboot.abixml | 34 +- - src/libefivar.abixml | 1026 ++++++++++++++++++++--------------------- - 2 files changed, 530 insertions(+), 530 deletions(-) - -diff --git a/src/libefiboot.abixml b/src/libefiboot.abixml -index 94d96a2f692..97f030865ed 100644 ---- a/src/libefiboot.abixml -+++ b/src/libefiboot.abixml -@@ -21,7 +21,7 @@ - - - -- -+ - - - -@@ -204,12 +204,12 @@ - - - -- -+ - -- -+ - - -- -+ - - - -@@ -416,7 +416,7 @@ - - - -- -+ - - - -@@ -434,30 +434,30 @@ - - - -- -- -- -- -- -- -- -- -- - - - -- -- -- - - - -+ -+ -+ -+ -+ -+ - - - - - - -+ -+ -+ -+ -+ -+ - - - -diff --git a/src/libefivar.abixml b/src/libefivar.abixml -index f0137030eb0..bee8bf60efb 100644 ---- a/src/libefivar.abixml -+++ b/src/libefivar.abixml -@@ -303,115 +303,115 @@ - - - -- -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -+ -+ -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -@@ -810,261 +810,294 @@ - - - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ - - -- -+ - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - -- -+ - - - -@@ -1075,7 +1108,7 @@ - - - -- -+ - - - -@@ -1086,10 +1119,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1098,19 +1131,19 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - -@@ -1122,36 +1155,36 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - - -- -+ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - -@@ -1160,10 +1193,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1172,10 +1205,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1190,24 +1223,24 @@ - - - -- -- -+ -+ - -- -+ - - -- -+ - - - -- -+ - - - -- -- -+ -+ - -- -+ - - - -@@ -1219,10 +1252,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1231,10 +1264,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1246,30 +1279,30 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -+ - - - -- -- -+ -+ - - -- -- -+ -+ - -- -+ - - - -@@ -1278,10 +1311,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1290,10 +1323,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1311,10 +1344,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1326,27 +1359,27 @@ - - - -- -+ - - - -- -+ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - -@@ -1358,42 +1391,42 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - -- -+ - - - - - - -- -- -+ -+ - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -+ - - - -@@ -1405,31 +1438,31 @@ - - - -- -+ - - -- -+ - - -- -+ - - - -- -- -+ -+ - - -- -- -- -+ -+ -+ - -- -+ - - -- -+ - - -- -+ - - - -@@ -1451,32 +1484,32 @@ - - - -- -- -+ -+ - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -+ - - - -@@ -1486,11 +1519,11 @@ - - - -- -- -+ -+ - - -- -+ - - - -@@ -1498,10 +1531,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1519,22 +1552,22 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -- -+ -+ - -- -+ - - - -@@ -1543,10 +1576,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1570,16 +1603,16 @@ - - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -+ - - - -@@ -1591,10 +1624,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1603,40 +1636,40 @@ - - - -- -+ - - - - - -- -+ - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -- -+ -+ - -- -+ - - - -@@ -1645,46 +1678,46 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - -@@ -1693,65 +1726,65 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -+ - -- -+ - - -- -+ - - -- -+ - - - -- -- -+ -+ - - -- -+ - -- -+ - - -- -- -+ -+ - -- -+ - - -- -- -+ -+ - -- -+ - - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - - -@@ -1763,7 +1796,7 @@ - - - -- -+ - - - -@@ -1772,10 +1805,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1787,58 +1820,58 @@ - - - -- -- -+ -+ - -- -+ - - - - - -- -+ - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -- -+ -+ - -- -+ - - - - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -- -+ -+ - -- -+ - - -- -+ - - -- -- -+ -+ - -- -+ - - - -@@ -1850,10 +1883,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1868,10 +1901,10 @@ - - - -- -- -+ -+ - -- -+ - - - -@@ -1880,105 +1913,72 @@ - - - -- -+ - - -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -+ -+ -+ -+ - - -- -- -- -- -+ -+ -+ -+ - - -- -- -- -- -- -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - --- -2.17.1 - diff --git a/0030-linux-emmc-update-for-internal-API-breakage.patch b/0030-linux-emmc-update-for-internal-API-breakage.patch deleted file mode 100644 index e0cf5eb..0000000 --- a/0030-linux-emmc-update-for-internal-API-breakage.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0c44e3d75a9c3a2a1d4cef3c1b836aa0d7fb004f Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 3 Aug 2018 10:02:02 -0400 -Subject: [PATCH 30/34] linux-emmc: update for internal API breakage. - -Alek wrote his code before I made debug() imply LOG_DEBUG, so we need to -change that here as well. - -Signed-off-by: Peter Jones ---- - src/linux-emmc.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/src/linux-emmc.c b/src/linux-emmc.c -index f0c9e635cb6..87e92477554 100644 ---- a/src/linux-emmc.c -+++ b/src/linux-emmc.c -@@ -58,15 +58,15 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED) - spaces[pos0] = '\0'; - pos0 = 0; - -- debug(DEBUG, "entry"); -+ debug("entry"); - -- debug(DEBUG, "searching for mmc_host/mmc0/mmc0:0001/block/mmcblk0 or mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1"); -+ debug("searching for mmc_host/mmc0/mmc0:0001/block/mmcblk0 or mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1"); - rc = sscanf(current, "mmc_host/mmc%d/mmc%d:%d/block/mmcblk%d%n/mmcblk%dp%d%n", - &tosser0, &tosser1, &tosser2, &slot_id, - &pos0, &tosser3, &partition, &pos1); -- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -- arrow(DEBUG, spaces, 9, pos0, rc, 4); -- arrow(DEBUG, spaces, 9, pos1, rc, 6); -+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4); -+ arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6); - /* - * If it isn't of that form, it's not one of our emmc devices. - */ -@@ -92,7 +92,7 @@ dp_create_emmc(struct device *dev, - { - ssize_t sz; - -- debug(DEBUG, "entry"); -+ debug("entry"); - - sz = efidp_make_emmc(buf + off, size ? size - off : 0, - dev->emmc_info.slot_id); --- -2.17.1 - diff --git a/0031-Fix-another-buggy-fake-acpi-pci-root-driver.patch b/0031-Fix-another-buggy-fake-acpi-pci-root-driver.patch deleted file mode 100644 index ba0569d..0000000 --- a/0031-Fix-another-buggy-fake-acpi-pci-root-driver.patch +++ /dev/null @@ -1,64 +0,0 @@ -From da30e9f2eee235ce11d47bb2e32f976b8c187e5d Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 10 Sep 2018 15:00:03 -0400 -Subject: [PATCH 31/34] Fix another buggy fake acpi pci root driver - -In this case, the platform driver that creates the PCI(e) root device -doesn't fill in its driver link, so we can't look up what driver is in -use - but since it's the root, it *really* doesn't matter. And in -general, we only really care if it's the last node in our path, because -that'll be the controller for the boot device anyway. - -Signed-off-by: Peter Jones ---- - src/linux-pci.c | 24 +++++++++++++++++------- - 1 file changed, 17 insertions(+), 7 deletions(-) - -diff --git a/src/linux-pci.c b/src/linux-pci.c -index e7c864b2d33..f63f5914d9f 100644 ---- a/src/linux-pci.c -+++ b/src/linux-pci.c -@@ -67,7 +67,9 @@ parse_pci(struct device *dev, const char *current, const char *root) - uint8_t bus, device, function; - struct pci_dev_info *pci_dev; - unsigned int i = dev->n_pci_devs; -+ struct stat statbuf; - -+ debug("devpart is \"%s\"", devpart); - pos = 0; - debug("searching for 0000:00:00.0/"); - rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n", -@@ -100,15 +102,23 @@ parse_pci(struct device *dev, const char *current, const char *root) - return -1; - } - tmp[devpart - root] = '\0'; -- rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp); -- if (rc < 0 || !linkbuf) { -- efi_error("Could not find driver for pci device %s", tmp); -- free(tmp); -- return -1; -+ rc = sysfs_stat(&statbuf, "class/block/%s/driver", tmp); -+ if (rc < 0 && errno == ENOENT) { -+ debug("No driver link for /sys/class/block/%s", tmp); -+ debug("Assuming this is just a buggy platform core driver"); -+ dev->pci_dev[i].driverlink = NULL; -+ } else { -+ rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp); -+ if (rc < 0 || !linkbuf) { -+ efi_error("Could not find driver for pci device %s", tmp); -+ free(tmp); -+ return -1; -+ } else { -+ dev->pci_dev[i].driverlink = strdup(linkbuf); -+ debug("driver:%s\n", linkbuf); -+ } - } - free(tmp); -- dev->pci_dev[i].driverlink = strdup(linkbuf); -- debug("driver:%s\n", linkbuf); - dev->n_pci_devs += 1; - } - --- -2.17.1 - diff --git a/0032-Fix-dev-probes-intialization-test.patch b/0032-Fix-dev-probes-intialization-test.patch deleted file mode 100644 index 2d5238f..0000000 --- a/0032-Fix-dev-probes-intialization-test.patch +++ /dev/null @@ -1,28 +0,0 @@ -From e56cf8d480c27bf3ea81af63efb4704896282c6a Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 17 Sep 2018 16:12:25 -0400 -Subject: [PATCH 32/34] Fix dev->probes intialization test - -Signed-off-by: Peter Jones ---- - src/linux.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/linux.c b/src/linux.c -index ff8db812ad3..19eb488c992 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -117,7 +117,9 @@ reset_part_name(struct device *dev) - if (dev->part < 1) - return 0; - -- if (dev->probes[dev->n_probes]->make_part_name) { -+ if (dev->n_probes > 0 && -+ dev->probes[dev->n_probes-1] && -+ dev->probes[dev->n_probes-1]->make_part_name) { - part = dev->probes[dev->n_probes]->make_part_name(dev); - dev->part_name = part; - rc = 0; --- -2.17.1 - diff --git a/0033-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch b/0033-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch deleted file mode 100644 index b703262..0000000 --- a/0033-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch +++ /dev/null @@ -1,92 +0,0 @@ -From e83002b08aa6db57b90d89968ab8d34f6c7f73cf Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 17 Sep 2018 16:13:24 -0400 -Subject: [PATCH 33/34] Deal with devices that don't have a ->device link in - sysfs - -Signed-off-by: Peter Jones ---- - src/linux.c | 53 ++++++++++++++++++++++++++++++----------------------- - 1 file changed, 30 insertions(+), 23 deletions(-) - -diff --git a/src/linux.c b/src/linux.c -index 19eb488c992..6d405af8a76 100644 ---- a/src/linux.c -+++ b/src/linux.c -@@ -389,43 +389,50 @@ struct device HIDDEN - - rc = sysfs_readlink(&tmpbuf, "block/%s/device", dev->disk_name); - if (rc < 0 || !tmpbuf) { -- efi_error("readlink of /sys/block/%s/device failed", -+ debug("readlink of /sys/block/%s/device failed", - dev->disk_name); -- goto err; -+ -+ dev->device = strdup(""); -+ } else { -+ dev->device = strdup(tmpbuf); - } - -- dev->device = strdup(tmpbuf); - if (!dev->device) { - efi_error("strdup(\"%s\") failed", tmpbuf); - goto err; - } - -- rc = sysfs_readlink(&tmpbuf, "block/%s/device/driver", dev->disk_name); -- if (rc < 0 || !tmpbuf) { -- if (errno == ENOENT) { -- /* -- * nvme, for example, will have nvme0n1/device point -- * at nvme0, and we need to look for device/driver -- * there. -- */ -- rc = sysfs_readlink(&tmpbuf, -- "block/%s/device/device/driver", -- dev->disk_name); -- } -+ if (dev->device[0] != 0) { -+ rc = sysfs_readlink(&tmpbuf, "block/%s/device/driver", dev->disk_name); - if (rc < 0 || !tmpbuf) { -- efi_error("readlink of /sys/block/%s/device/driver failed", -- dev->disk_name); -+ if (errno == ENOENT) { -+ /* -+ * nvme, for example, will have nvme0n1/device point -+ * at nvme0, and we need to look for device/driver -+ * there. -+ */ -+ rc = sysfs_readlink(&tmpbuf, -+ "block/%s/device/device/driver", -+ dev->disk_name); -+ } -+ if (rc < 0 || !tmpbuf) { -+ efi_error("readlink of /sys/block/%s/device/driver failed", -+ dev->disk_name); -+ goto err; -+ } -+ } -+ -+ linkbuf = pathseg(tmpbuf, -1); -+ if (!linkbuf) { -+ efi_error("could not get segment -1 of \"%s\"", tmpbuf); - goto err; - } -- } - -- linkbuf = pathseg(tmpbuf, -1); -- if (!linkbuf) { -- efi_error("could not get segment -1 of \"%s\"", tmpbuf); -- goto err; -+ dev->driver = strdup(linkbuf); -+ } else { -+ dev->driver = strdup(""); - } - -- dev->driver = strdup(linkbuf); - if (!dev->driver) { - efi_error("strdup(\"%s\") failed", linkbuf); - goto err; --- -2.17.1 - diff --git a/0034-Handle-partition-name-parsing-and-formatting-for-par.patch b/0034-Handle-partition-name-parsing-and-formatting-for-par.patch deleted file mode 100644 index f5f001f..0000000 --- a/0034-Handle-partition-name-parsing-and-formatting-for-par.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 576f55b02d9ec478bd5157352c884e3543bcca58 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 17 Sep 2018 16:52:57 -0400 -Subject: [PATCH 34/34] Handle partition name parsing and formatting for - partitioned md. - -Signed-off-by: Peter Jones ---- - src/linux-md.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 103 insertions(+) - create mode 100644 src/linux-md.c - -diff --git a/src/linux-md.c b/src/linux-md.c -new file mode 100644 -index 00000000000..0a5c1cdb435 ---- /dev/null -+++ b/src/linux-md.c -@@ -0,0 +1,103 @@ -+/* -+ * libefiboot - library for the manipulation of EFI boot variables -+ * Copyright 2012-2018 Red Hat, Inc. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of the -+ * License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, see -+ * . -+ * -+ */ -+ -+#include "fix_coverity.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "efiboot.h" -+ -+/* -+ * "support" for partitioned md devices - basically we just need to format -+ * the partition name. -+ * -+ * /sys/dev/block/$major:$minor looks like: -+ * 259:0 -> ../../devices/virtual/block/md1/md1p1 -+ * 9:1 -> ../../devices/virtual/block/md1 -+ * -+ */ -+ -+static ssize_t -+parse_md(struct device *dev, const char *current, const char *root UNUSED) -+{ -+ int rc; -+ int32_t md, tosser0, part; -+ int pos0 = 0, pos1 = 0; -+ char *spaces; -+ -+ pos0 = strlen(current); -+ spaces = alloca(pos0+1); -+ memset(spaces, ' ', pos0+1); -+ spaces[pos0] = '\0'; -+ pos0 = 0; -+ -+ debug("entry"); -+ -+ debug("searching for mdM/mdMpN"); -+ rc = sscanf(current, "md%d/%nmd%dp%d%n", -+ &md, &pos0, &tosser0, &part, &pos1); -+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1); -+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3); -+ /* -+ * If it isn't of that form, it's not one of our partitioned md devices. -+ */ -+ if (rc != 3) -+ return 0; -+ -+ dev->interface_type = md; -+ -+ if (dev->part == -1) -+ dev->part = part; -+ -+ return pos1; -+} -+ -+ -+static char * -+make_part_name(struct device *dev) -+{ -+ char *ret = NULL; -+ ssize_t rc; -+ -+ if (dev->part < 1) -+ return NULL; -+ -+ rc = asprintf(&ret, "%sp%d", dev->disk_name, dev->part); -+ if (rc < 0) { -+ efi_error("could not allocate memory"); -+ return NULL; -+ } -+ -+ return ret; -+} -+ -+static enum interface_type md_iftypes[] = { md, unknown }; -+ -+struct dev_probe HIDDEN md_parser = { -+ .name = "md", -+ .iftypes = md_iftypes, -+ .flags = DEV_PROVIDES_HD, -+ .parse = parse_md, -+ .make_part_name = make_part_name, -+}; --- -2.17.1 - diff --git a/efivar.spec b/efivar.spec index c9bcfbe..3808478 100644 --- a/efivar.spec +++ b/efivar.spec @@ -1,5 +1,5 @@ Name: efivar -Version: 36 +Version: 37 Release: 1%{?dist} Summary: Tools to manage UEFI variables License: LGPLv2.1 @@ -11,42 +11,7 @@ BuildRequires: gcc BuildRequires: efi-srpm-macros git glibc-static libabigail # please don't fix this to reflect github's incomprehensible url that goes # to a different tarball. -Source0: https://github.com/rhboot/efivar/archive/efivar-%{version}.tar.bz2 - -Patch0001: 0001-Move-the-syntastic-file-I-use-out-of-the-repo.patch -Patch0002: 0002-Move-verbosity-headers-to-be-public.patch -Patch0003: 0003-Pacify-some-coverity-nits.patch -Patch0004: 0004-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch -Patch0005: 0005-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch -Patch0006: 0006-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch -Patch0007: 0007-Make-efidp_make_file-have-even-more-better-input-con.patch -Patch0008: 0008-Make-path-helpers.c-also-import-fix_coverity.h.patch -Patch0009: 0009-Fix-a-makeguids-building-problem-with-generics.h.patch -Patch0010: 0010-Improve-ACPI-device-path-formatting.patch -Patch0011: 0011-Give-linux-s-parse-functions-the-unmodified-device-l.patch -Patch0012: 0012-Move-ACPI-ID-parsing-to-a-shared-location.patch -Patch0013: 0013-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch -Patch0014: 0014-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch -Patch0015: 0015-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch -Patch0016: 0016-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch -Patch0017: 0017-Pacify-clang-analyzer-just-a-little.patch -Patch0018: 0018-Try-even-harder-to-convince-coverity-that-get_file-i.patch -Patch0019: 0019-Make-the-debug-code-less-intrusive.patch -Patch0020: 0020-efiboot-Make-the-device-node-skipping-code-pass-cove.patch -Patch0021: 0021-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch -Patch0022: 0022-efiboot-fix-a-bad-error-check.patch -Patch0023: 0023-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch -Patch0024: 0024-Coverity-still-doesn-t-believe-in-error-codes.patch -Patch0025: 0025-Don-t-require-NVME-to-have-an-EUI.patch -Patch0026: 0026-makeguids-initialize-memory.patch -Patch0027: 0027-emmc_parser-add-emmc_parser.patch -Patch0028: 0028-abignore-work-around-an-abidw-bug.patch -Patch0029: 0029-Update-abidw-for-newer-tools.patch -Patch0030: 0030-linux-emmc-update-for-internal-API-breakage.patch -Patch0031: 0031-Fix-another-buggy-fake-acpi-pci-root-driver.patch -Patch0032: 0032-Fix-dev-probes-intialization-test.patch -Patch0033: 0033-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch -Patch0034: 0034-Handle-partition-name-parsing-and-formatting-for-par.patch +Source0: https://github.com/rhboot/efivar/releases/download/%{version}/efivar-%{version}.tar.bz2 %description efivar provides a simple command line interface to the UEFI variable facility. @@ -76,7 +41,7 @@ git config --unset user.email git config --unset user.name %build -make libdir=%{_libdir} bindir=%{_bindir} CFLAGS="$RPM_OPT_FLAGS -flto" LDFLAGS="$RPM_LD_FLAGS -flto" +make LIBDIR=%{_libdir} BINDIR=%{_bindir} CFLAGS="$RPM_OPT_FLAGS -flto" LDFLAGS="$RPM_LD_FLAGS -flto" %install %makeinstall @@ -108,6 +73,22 @@ make abicheck %{_libdir}/*.so.* %changelog +* Wed Dec 05 2018 Peter Jones - 37-1 +- Update to efivar 37: + - Minor coverity fixes + - Improve ACPI device path formatting + - Add support for SOC devices that use FDT as their PCI root node + - Make devices we can't parse the "device" sysfs link for use DEV_ABBREV_ONLY + - Handle SCSI port numbers better + - Don't require an EUI for NVMe + - Fix the accidental requirement on ACPI UID nodes existing + - Add support for EMMC devices + - Add support for PCI root nodes without a device link in sysfs + - Add support for partitioned MD devices + - Fix partition number detection when the number isn't provided + - Add support for ACPI Generic Container and Embedded Controller root nodes + - Add limited support for SAS/SATA port expanders + * Mon Sep 17 2018 Peter Jones - 36-1 - Update to efivar 36 - Add NVDIMM support diff --git a/sources b/sources index 9935a99..5d6214d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (efivar-36.tar.bz2) = 951feabe2d238826fdd6e74e8f7a24f04d705f9ef925cfcfb852944d2d7a4f04e3a6c23f276c40e5564da42614558941dbe7aaf21efa6a722a616e4d165aba2d +SHA512 (efivar-37.tar.bz2) = 305a82ed103c7e3d8f723934019d552677c73558768dd5341f87d0364f5c60824d24f5a8e1bf90075e825908085083d4ecdccec5ac757fd38ee6ac8fea28c3e4