diff --git a/.efivar.metadata b/.efivar.metadata
index 5e01996..0f64cd3 100644
--- a/.efivar.metadata
+++ b/.efivar.metadata
@@ -1 +1 @@
-3f1e11c83b5edaafaa76cc5e2ac72921d2244876 SOURCES/efivar-31.tar.bz2
+3c74c8a0d8bc7a39b74de52cad2a791c00cdfd67 SOURCES/efivar-36.tar.bz2
diff --git a/.gitignore b/.gitignore
index 005c3cf..0da8479 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/efivar-31.tar.bz2
+SOURCES/efivar-36.tar.bz2
diff --git a/SOURCES/0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch b/SOURCES/0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch
index 43ed277..2d272db 100644
--- a/SOURCES/0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch
+++ b/SOURCES/0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch
@@ -1,29 +1,45 @@
-From 78bda9cefdb5e29cedd379c1b9ea9fd8274d7c5d Mon Sep 17 00:00:00 2001
+From 7b0bd868dc58657799bd14eb471efe7f62d875a2 Mon Sep 17 00:00:00 2001
 From: Peter Jones <pjones@redhat.com>
-Date: Mon, 13 Mar 2017 13:05:58 -0400
-Subject: [PATCH 1/3] libabigail isn't in RHEL yet, so nerf the abi check.
+Date: Fri, 8 Jun 2018 15:08:21 -0400
+Subject: [PATCH] libabigail isn't in RHEL yet, so nerf the abi check.
 
 Signed-off-by: Peter Jones <pjones@redhat.com>
 ---
- Make.rules   | 9 ---------
- Makefile     | 6 +++---
- src/Makefile | 5 -----
- 3 files changed, 3 insertions(+), 17 deletions(-)
+ Make.defaults  |  2 --
+ Make.rules     | 11 -----------
+ Makefile       | 12 ++++--------
+ efivar.spec.in |  7 +------
+ 4 files changed, 5 insertions(+), 27 deletions(-)
 
+diff --git a/Make.defaults b/Make.defaults
+index 57cee6e82b5..9ee5c80f910 100644
+--- a/Make.defaults
++++ b/Make.defaults
+@@ -24,8 +24,6 @@ LDFLAGS := $(LDFLAGS)
+ AR	:= $(CROSS_COMPILE)$(COMPILER)-ar
+ NM	:= $(CROSS_COMPILE)$(COMPILER)-nm
+ RANLIB	:= $(CROSS_COMPILE)$(COMPILER)-ranlib
+-ABIDW	:= abidw
+-ABIDIFF := abidiff
+ 
+ PKGS	=
+ 
 diff --git a/Make.rules b/Make.rules
-index 88b9aa7..a7d6a23 100644
+index 042585b533c..585e287f455 100644
 --- a/Make.rules
 +++ b/Make.rules
-@@ -22,15 +22,6 @@ include $(TOPDIR)/Make.version
- 	  -Wl,--version-script=$(MAP) \
+@@ -23,17 +23,6 @@ include $(TOPDIR)/Make.version
  	  -o $@ $^ $(LDLIBS)
+ 	ln -vfs $@ $@.1
  
 -%.abixml : %.so
 -	$(ABIDW) --headers-dir $(TOPDIR)/src/include/efivar/ --out-file $@ $^
+-	@sed -i -s 's,$(TOPDIR)/,,g' $@
 -
 -%.abicheck : %.so
--	$(ABIDIFF) --suppr \
--		$(patsubst %.so,%.abignore,$<) \
+-	$(ABIDIFF) \
+-		--suppr abignore \
+-		--headers-dir2 $(TOPDIR)/src/include/efivar/ \
 -		$(patsubst %.so,%.abixml,$<) \
 -		$<
 -
@@ -31,10 +47,10 @@ index 88b9aa7..a7d6a23 100644
  	$(CC) $(cflags) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
  
 diff --git a/Makefile b/Makefile
-index 4d6d308..504a747 100644
+index 8c67b9d2654..e4f76a3a8d4 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -17,7 +17,7 @@ install :
+@@ -20,13 +20,9 @@ install :
  		$(MAKE) -C $$x $@ ; \
  	done
  
@@ -42,41 +58,65 @@ index 4d6d308..504a747 100644
 +efivar efivar-static static:
  	$(MAKE) -C src $@
  
+-abiupdate :
+-	$(MAKE) clean all
+-	$(MAKE) -C src abiclean abixml
+-
  $(SUBDIRS) :
-@@ -44,7 +44,7 @@ clean :
+ 	$(MAKE) -C $@
+ 
+@@ -39,7 +35,7 @@ a :
+ 		exit 1 ; \
+ 	fi
+ 
+-.PHONY: $(SUBDIRS) a brick abiupdate
++.PHONY: $(SUBDIRS) a brick
+ 
+ GITTAG = $(shell bash -c "echo $$(($(VERSION) + 1))")
  
- GITTAG = $(VERSION)
+@@ -51,7 +47,7 @@ clean :
+ 	done
+ 	@rm -vf efivar.spec
  
 -test-archive: abicheck efivar.spec
 +test-archive: efivar.spec
- 	@rm -rf /tmp/efivar-$(VERSION) /tmp/efivar-$(VERSION)-tmp
- 	@mkdir -p /tmp/efivar-$(VERSION)-tmp
- 	@git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/efivar-$(VERSION)-tmp/ ; tar x )
-@@ -58,7 +58,7 @@ test-archive: abicheck efivar.spec
+ 	@rm -rf /tmp/efivar-$(GITTAG) /tmp/efivar-$(GITTAG)-tmp
+ 	@mkdir -p /tmp/efivar-$(GITTAG)-tmp
+ 	@git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/efivar-$(GITTAG)-tmp/ ; tar x )
+@@ -70,7 +66,7 @@ bumpver :
  tag:
  	git tag -s $(GITTAG) refs/heads/master
  
--archive: abicheck abidw tag efivar.spec
-+archive: tag efivar.spec
- 	@rm -rf /tmp/efivar-$(VERSION) /tmp/efivar-$(VERSION)-tmp
- 	@mkdir -p /tmp/efivar-$(VERSION)-tmp
- 	@git archive --format=tar $(GITTAG) | ( cd /tmp/efivar-$(VERSION)-tmp/ ; tar x )
-diff --git a/src/Makefile b/src/Makefile
-index 0c16597..a5d98ec 100644
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -32,11 +32,6 @@ all : $(TARGETS)
- 
- static : $(STATICTARGETS)
- 
--abidw : $(patsubst %.so,%.abixml,$(LIBTARGETS))
--	git commit -m "Update .abixml files" -s $^
--
--abicheck : $(patsubst %.so,%.abicheck,$(LIBTARGETS))
+-archive: abicheck bumpver abidw tag efivar.spec
++archive: bumpver tag efivar.spec
+ 	@rm -rf /tmp/efivar-$(GITTAG) /tmp/efivar-$(GITTAG)-tmp
+ 	@mkdir -p /tmp/efivar-$(GITTAG)-tmp
+ 	@git archive --format=tar $(GITTAG) | ( cd /tmp/efivar-$(GITTAG)-tmp/ ; tar x )
+diff --git a/efivar.spec.in b/efivar.spec.in
+index 180e5374ae6..b55329b265d 100644
+--- a/efivar.spec.in
++++ b/efivar.spec.in
+@@ -7,7 +7,7 @@ URL:            https://github.com/rhinstaller/efivar
+ Requires:       %{name}-libs = %{version}-%{release}
+ ExclusiveArch:  %{ix86} x86_64 aarch64
+ 
+-BuildRequires:  git glibc-static libabigail
++BuildRequires:  git glibc-static
+ Source0:        https://github.com/rhboot/efivar/archive/%{version}.tar.gz
+ 
+ %description
+@@ -47,11 +47,6 @@ rm -rf $RPM_BUILD_ROOT
+ %clean
+ rm -rf $RPM_BUILD_ROOT
+ 
+-%check
+-%ifarch x86_64
+-make abicheck
+-%endif
 -
- ./guid-symbols.c : include/efivar/efivar-guids.h
- ./guids.bin : include/efivar/efivar-guids.h
- ./names.bin : include/efivar/efivar-guids.h
+ %post libs -p /sbin/ldconfig
+ 
+ %postun libs -p /sbin/ldconfig
 -- 
-2.9.3
+2.17.1
 
diff --git a/SOURCES/0002-Don-t-use-_Generic-because-gcc-4.x-doesn-t-have-it.patch b/SOURCES/0002-Don-t-use-_Generic-because-gcc-4.x-doesn-t-have-it.patch
deleted file mode 100644
index fd34b85..0000000
--- a/SOURCES/0002-Don-t-use-_Generic-because-gcc-4.x-doesn-t-have-it.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 1b74597f9327ae2d763ae8863ac784a5a0d6bb93 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 13 Mar 2017 13:36:55 -0400
-Subject: [PATCH 2/3] Don't use _Generic because gcc 4.x doesn't have it...
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/util.h | 17 ++++++++++++++++-
- 1 file changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/src/util.h b/src/util.h
-index 0af7dbe..7ad6ce4 100644
---- a/src/util.h
-+++ b/src/util.h
-@@ -105,14 +105,29 @@
- 	})
- #endif
- 
-+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-+#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
- #define add(a, b, c) _Generic((c),					\
- 			      int *: int_add(a,b,c),			\
- 			      long *: long_add(a,b,c),			\
- 			      unsigned long *: ulong_add(a,b,c))
--
- #define mult(a, b, c) _Generic((c),					\
- 			      long *: long_mult(a,b,c),			\
- 			      unsigned long *: ulong_mult(a,b,c))
-+#endif
-+#endif
-+
-+#ifndef add
-+#define add(a, b, c) ({						\
-+		(*(c)) = ((a) + (b));				\
-+		})
-+#endif
-+#ifndef mult
-+#define mult(a, b, c) ({					\
-+		(*(c)) = ((a) * (b));				\
-+		})
-+#endif
-+
- 
- static inline int
- __attribute__((unused))
--- 
-2.9.3
-
diff --git a/SOURCES/0002-Move-the-syntastic-file-I-use-out-of-the-repo.patch b/SOURCES/0002-Move-the-syntastic-file-I-use-out-of-the-repo.patch
new file mode 100644
index 0000000..94bb4d3
--- /dev/null
+++ b/SOURCES/0002-Move-the-syntastic-file-I-use-out-of-the-repo.patch
@@ -0,0 +1,56 @@
+From d5f88bb1d594451733261d62eac4b4f97d39e3f4 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Tue, 12 Jun 2018 14:36:20 -0400
+Subject: [PATCH 02/17] Move the syntastic file I use out of the repo
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0003-Move-verbosity-headers-to-be-public.patch b/SOURCES/0003-Move-verbosity-headers-to-be-public.patch
new file mode 100644
index 0000000..d272f5c
--- /dev/null
+++ b/SOURCES/0003-Move-verbosity-headers-to-be-public.patch
@@ -0,0 +1,53 @@
+From daf3b6c6ae8a766f362c87dc80e40005428a1b2a Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Tue, 12 Jun 2018 14:36:20 -0400
+Subject: [PATCH 03/17] Move verbosity headers to be public
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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 <stdarg.h>
+ #include <stdint.h>
+ #include <string.h>
++#include <stdio.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+@@ -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 <efivar/efivar-dp.h>
+ 
+ #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/SOURCES/0003-popt-devel-in-RHEL-7.4-doesn-t-provide-popt.pc-so-in.patch b/SOURCES/0003-popt-devel-in-RHEL-7.4-doesn-t-provide-popt.pc-so-in.patch
deleted file mode 100644
index 663746f..0000000
--- a/SOURCES/0003-popt-devel-in-RHEL-7.4-doesn-t-provide-popt.pc-so-in.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 262e2900dde1e03d499b3e06f389dcdd8f12f2fd Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 13 Mar 2017 14:03:55 -0400
-Subject: [PATCH 3/3] popt-devel in RHEL 7.4 doesn't provide popt.pc, so
- include it the other way.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/Makefile | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
-
-diff --git a/src/Makefile b/src/Makefile
-index a5d98ec..c957d84 100644
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -56,13 +56,11 @@ libefivar.so : LIBS=dl
- libefivar.so : MAP=libefivar.map
- 
- efivar : efivar.c | libefivar.so
--efivar : LIBS=efivar dl
--efivar : PKGS=popt
-+efivar : LIBS=efivar dl popt
- 
- efivar-static : efivar.c $(patsubst %.o,%.static.o,$(LIBEFIVAR_OBJECTS))
- efivar-static : | $(GENERATED_SOURCES)
--efivar-static : LIBS=dl
--efivar-static : PKGS=popt
-+efivar-static : LIBS=dl popt
- 
- libefiboot.a : $(patsubst %.o,%.static.o,$(LIBEFIBOOT_OBJECTS))
- 
--- 
-2.9.3
-
diff --git a/SOURCES/0004-Pacify-some-coverity-nits.patch b/SOURCES/0004-Pacify-some-coverity-nits.patch
new file mode 100644
index 0000000..b7bf3dc
--- /dev/null
+++ b/SOURCES/0004-Pacify-some-coverity-nits.patch
@@ -0,0 +1,45 @@
+From bd609a59369574c95f7f31b15caae8bb86b71f39 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Tue, 12 Jun 2018 14:36:20 -0400
+Subject: [PATCH 04/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0004-efi_loadopt_args_from_file-fix-leaked-file-descripto.patch b/SOURCES/0004-efi_loadopt_args_from_file-fix-leaked-file-descripto.patch
deleted file mode 100644
index af9fbf5..0000000
--- a/SOURCES/0004-efi_loadopt_args_from_file-fix-leaked-file-descripto.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 0967cd89ae6c1e55c1d136669e2f426752f233f4 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:40:26 -0400
-Subject: [PATCH 04/22] efi_loadopt_args_from_file(): fix leaked file
- descriptor.
-
-In the case where we're just trying to figure out the file's size, we're
-failing to close the file.  So close it.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/loadopt.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/loadopt.c b/src/loadopt.c
-index ce88986..a3c1ba9 100644
---- a/src/loadopt.c
-+++ b/src/loadopt.c
-@@ -275,8 +275,10 @@ efi_loadopt_args_from_file(uint8_t *buf, ssize_t size, char *filename)
- 	if (rc < 0)
- 		goto err;
- 
--	if (size == 0)
-+	if (size == 0) {
-+		fclose(f);
- 		return statbuf.st_size;
-+	}
- 
- 	if (size < statbuf.st_size) {
- 		errno = ENOSPC;
--- 
-2.12.2
-
diff --git a/SOURCES/0005-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch b/SOURCES/0005-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch
new file mode 100644
index 0000000..b44e98d
--- /dev/null
+++ b/SOURCES/0005-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch
@@ -0,0 +1,38 @@
+From 4becb1303fee8bd7b377292c74589d6ec69009ae Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Tue, 12 Jun 2018 14:36:20 -0400
+Subject: [PATCH 05/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0005-make_mac_path-fix-leaked-file-descriptor.patch b/SOURCES/0005-make_mac_path-fix-leaked-file-descriptor.patch
deleted file mode 100644
index 85bf612..0000000
--- a/SOURCES/0005-make_mac_path-fix-leaked-file-descriptor.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From f3304710b72de55249ef461c544edffd5705bdc7 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:42:25 -0400
-Subject: [PATCH 05/22] make_mac_path(): fix leaked file descriptor.
-
-When make_mac_path() gets an error from efidp_make_mac_addr(), it fails
-to close the file descriptor to the network device.  So close it.  Also
-ensure that the ifrn_name field is NUL terminated.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/linux.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/linux.c b/src/linux.c
-index 34ed479..3c77a93 100644
---- a/src/linux.c
-+++ b/src/linux.c
-@@ -1035,6 +1035,7 @@ make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
- 
- 	memset(&ifr, 0, sizeof (ifr));
- 	strncpy(ifr.ifr_name, ifname, IF_NAMESIZE);
-+	ifr.ifr_name[IF_NAMESIZE-1] = '\0';
- 	drvinfo.cmd = ETHTOOL_GDRVINFO;
- 	ifr.ifr_data = (caddr_t)&drvinfo;
- 
-@@ -1062,7 +1063,8 @@ make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
- 				 (uint8_t *)ifr.ifr_ifru.ifru_hwaddr.sa_data,
- 				 sizeof(ifr.ifr_ifru.ifru_hwaddr.sa_data));
- 	if (sz < 0)
--		return -1;
-+		goto err;
-+
- 	off += sz;
- 	ret = off;
- err:
--- 
-2.12.2
-
diff --git a/SOURCES/0006-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch b/SOURCES/0006-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch
new file mode 100644
index 0000000..b2e144d
--- /dev/null
+++ b/SOURCES/0006-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch
@@ -0,0 +1,88 @@
+From bd8fc0ebe86da82468b40a4998c3000819e73afe Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Tue, 12 Jun 2018 14:36:20 -0400
+Subject: [PATCH 06/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0006-gpt_disk_get_partition_info-free-our-allocations-on-.patch b/SOURCES/0006-gpt_disk_get_partition_info-free-our-allocations-on-.patch
deleted file mode 100644
index aff5553..0000000
--- a/SOURCES/0006-gpt_disk_get_partition_info-free-our-allocations-on-.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 939e4a8524821ccc30b34fec97416bc1b97b5455 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:44:43 -0400
-Subject: [PATCH 06/22] gpt_disk_get_partition_info(): free our allocations on
- the error path.
-
-When gpt_disk_get_partition_info() discovers that a partition is
-invalid, it returns error, but it forgets to free its allocations.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/gpt.c | 10 ++++------
- 1 file changed, 4 insertions(+), 6 deletions(-)
-
-diff --git a/src/gpt.c b/src/gpt.c
-index 30cbdfd..e9c713b 100644
---- a/src/gpt.c
-+++ b/src/gpt.c
-@@ -640,7 +640,7 @@ gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
- 	gpt_entry *ptes = NULL, *p;
- 	int rc = 0;
- 
--	char *report=getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
-+	char *report = getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
- 	if (report)
- 		report_errors = 1;
- 
-@@ -662,12 +662,10 @@ gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
- 		if (report_errors)
- 			fprintf(stderr, "partition %d is not valid\n", num);
- 		errno = EINVAL;
--		return -1;
-+		rc = -1;
- 	}
--	if (ptes)
--		free(ptes);
--	if (gpt)
--		free(gpt);
-+	free(ptes);
-+	free(gpt);
- 
- 	return rc;
- }
--- 
-2.12.2
-
diff --git a/SOURCES/0007-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch b/SOURCES/0007-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch
new file mode 100644
index 0000000..d61e068
--- /dev/null
+++ b/SOURCES/0007-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch
@@ -0,0 +1,138 @@
+From 5e2174acaf1a51ead0a079776229e0df89c7fd81 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 13 Jun 2018 09:15:17 -0400
+Subject: [PATCH 07/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0007-efi_generate_file_device_path-fix-one-error-case-s-f.patch b/SOURCES/0007-efi_generate_file_device_path-fix-one-error-case-s-f.patch
deleted file mode 100644
index 868ca11..0000000
--- a/SOURCES/0007-efi_generate_file_device_path-fix-one-error-case-s-f.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 1461dc3b17aa54377bbc461bf7d5a809322dae17 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:46:37 -0400
-Subject: [PATCH 07/22] efi_generate_file_device_path(): fix one error case's
- free path.
-
-When efi_generate_file_device_path() gets an error from
-find_parent_devpath(), it currently just returns an error, rather than
-freeing up its intermediate resources.  So free them.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/creator.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/creator.c b/src/creator.c
-index ca01964..6d662b7 100644
---- a/src/creator.c
-+++ b/src/creator.c
-@@ -345,7 +345,7 @@ efi_generate_file_device_path(uint8_t *buf, ssize_t size,
- 	rc = find_parent_devpath(child_devpath, &parent_devpath);
- 	if (rc < 0) {
- 		efi_error("could not find parent device for file");
--		return -1;
-+		goto err;
- 	}
- 
- 	rc = get_partition_number(child_devpath);
-@@ -369,7 +369,7 @@ err:
- 	if (child_devpath)
- 		free(child_devpath);
- 	if (parent_devpath)
--			free(parent_devpath);
-+		free(parent_devpath);
- 	if (relpath)
- 		free(relpath);
- 	errno = saved_errno;
--- 
-2.12.2
-
diff --git a/SOURCES/0008-Make-efidp_make_file-have-even-more-better-input-con.patch b/SOURCES/0008-Make-efidp_make_file-have-even-more-better-input-con.patch
new file mode 100644
index 0000000..4e690b5
--- /dev/null
+++ b/SOURCES/0008-Make-efidp_make_file-have-even-more-better-input-con.patch
@@ -0,0 +1,58 @@
+From 9bc1e24859630c933410bfb77658bd69ee400e16 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 13 Jun 2018 09:25:58 -0400
+Subject: [PATCH 08/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0008-efi_va_generate_file_device_path_from_esp-handle-err.patch b/SOURCES/0008-efi_va_generate_file_device_path_from_esp-handle-err.patch
deleted file mode 100644
index e54dff6..0000000
--- a/SOURCES/0008-efi_va_generate_file_device_path_from_esp-handle-err.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 537d3d37d1091080362e11a6fa99b9f31cb48e53 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:48:49 -0400
-Subject: [PATCH 08/22] efi_va_generate_file_device_path_from_esp(): handle
- errors better.
-
-When efi_va_generate_file_device_path_from_esp() gets an error from
-efidp_make_edd10() or make_blockdev_path(), it fails to close the file
-descriptor it uses to do ioctl() against the disk.  So make it use the
-common error path for those as well.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/creator.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/creator.c b/src/creator.c
-index 6d662b7..ccd0faf 100644
---- a/src/creator.c
-+++ b/src/creator.c
-@@ -180,7 +180,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
- 				       uint32_t options, va_list ap)
- {
- 	int rc;
--	ssize_t ret = -1, off=0, sz;
-+	ssize_t ret = -1, off = 0, sz;
- 	struct disk_info info = { 0, };
- 	int fd = -1;
- 	int saved_errno;
-@@ -215,7 +215,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
- 		sz = efidp_make_edd10(buf, size, info.edd10_devicenum);
- 		if (sz < 0) {
- 			efi_error("could not make EDD 1.0 device path");
--			return -1;
-+			goto err;
- 		}
- 		off = sz;
- 	} else if (!(options & EFIBOOT_ABBREV_FILE)
-@@ -228,7 +228,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
- 		sz = make_blockdev_path(buf, size, &info);
- 		if (sz < 0) {
- 			efi_error("could not create device path");
--			return -1;
-+			goto err;
- 		}
- 		off += sz;
- 	}
--- 
-2.12.2
-
diff --git a/SOURCES/0009-Make-path-helpers.c-also-import-fix_coverity.h.patch b/SOURCES/0009-Make-path-helpers.c-also-import-fix_coverity.h.patch
new file mode 100644
index 0000000..50e4deb
--- /dev/null
+++ b/SOURCES/0009-Make-path-helpers.c-also-import-fix_coverity.h.patch
@@ -0,0 +1,25 @@
+From 025f791b57c988d33249c5c33250229fa0e7e8f1 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 14 Jun 2018 12:15:03 -0400
+Subject: [PATCH 09/17] Make path-helpers.c also import fix_coverity.h
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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
+  * <http://www.gnu.org/licenses/>.
+  */
++#include "fix_coverity.h"
+ 
+ #include "efivar.h"
+ 
+-- 
+2.17.1
+
diff --git a/SOURCES/0009-efi_variable_import-fix-memory-leak-on-failure-path.patch b/SOURCES/0009-efi_variable_import-fix-memory-leak-on-failure-path.patch
deleted file mode 100644
index 5751166..0000000
--- a/SOURCES/0009-efi_variable_import-fix-memory-leak-on-failure-path.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 1ae1196e74d5bac16e63a9c453f88da9c28b5c4a Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:52:48 -0400
-Subject: [PATCH 09/22] efi_variable_import(): fix memory leak on failure path.
-
-When one of our allocations fails, we leak the other one.  Woops.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/export.c | 11 +++++++----
- 1 file changed, 7 insertions(+), 4 deletions(-)
-
-diff --git a/src/export.c b/src/export.c
-index 7f2d4dd..89af720 100644
---- a/src/export.c
-+++ b/src/export.c
-@@ -96,11 +96,14 @@ efi_variable_import(uint8_t *data, size_t size, efi_variable_t **var_out)
- 		ptr += sizeof (uint32_t);
- 
- 		if (name_len < 1 ||
--				name_len != ((data + size) - ptr - data_len))
--			return -1;
--		if (data_len < 1 ||
--				data_len != ((data + size) - ptr - name_len))
-+		    name_len != ((data + size) - ptr - data_len) ||
-+		    data_len < 1 ||
-+		    data_len != ((data + size) - ptr - name_len)) {
-+			int saved_errno = errno;
-+			free(var.guid);
-+			errno = saved_errno;
- 			return -1;
-+		}
- 
- 		var.name = calloc(1, name_len + 1);
- 		if (!var.name) {
--- 
-2.12.2
-
diff --git a/SOURCES/0010-Fix-a-makeguids-building-problem-with-generics.h.patch b/SOURCES/0010-Fix-a-makeguids-building-problem-with-generics.h.patch
new file mode 100644
index 0000000..37ddda9
--- /dev/null
+++ b/SOURCES/0010-Fix-a-makeguids-building-problem-with-generics.h.patch
@@ -0,0 +1,34 @@
+From bf5225b0445cc1b7b69c2a80162d3c1b514a27cf Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 14:12:42 -0400
+Subject: [PATCH 10/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0010-efidp_append_path-error-check-the-right-variable.patch b/SOURCES/0010-efidp_append_path-error-check-the-right-variable.patch
deleted file mode 100644
index 5b8c630..0000000
--- a/SOURCES/0010-efidp_append_path-error-check-the-right-variable.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From 62e8de172dfa707990e3f2721954290499c0e14f Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:54:15 -0400
-Subject: [PATCH 10/22] efidp_append_path(): error check the right variable.
-
-We do lsz=efidp_size(dp); rsz=efidp_size(dn); and then we error check
-lsz twice.  One should be rsz.
-
-We also actually do the whole thing with lsz twice anyway, and fail to
-check that dp isn't NULL first.
-
-We're also not error checking that the buffer from our addition is
-actually large enough to hold something meaningful.  So do that too.
-
-None of that is right, so fix it.
-
-Covscan completely failed to notice this, but complained about something
-irrelevant later on in the code that's a result.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/dp.c | 26 +++++++++++++++++++-------
- 1 file changed, 19 insertions(+), 7 deletions(-)
-
-diff --git a/src/dp.c b/src/dp.c
-index e9a257e..e700af9 100644
---- a/src/dp.c
-+++ b/src/dp.c
-@@ -139,7 +139,7 @@ efidp_append_path(const_efidp dp0, const_efidp dp1, efidp *out)
- 	}
- 
- 	rsz = efidp_size(dp1);
--	if (lsz < 0) {
-+	if (rsz < 0) {
- 		efi_error("efidp_size(dp1) returned error");
- 		return -1;
- 	}
-@@ -166,6 +166,13 @@ efidp_append_path(const_efidp dp0, const_efidp dp1, efidp *out)
- 		efi_error("arithmetic overflow computing allocation size");
- 		return -1;
- 	}
-+
-+	if (newsz < (ssize_t)sizeof(efidp_header)) {
-+		errno = EINVAL;
-+		efi_error("allocation for new device path is smaller than device path header.");
-+		return -1;
-+	}
-+
- 	new = malloc(newsz);
- 	if (!new) {
- 		efi_error("allocation failed");
-@@ -195,10 +202,11 @@ efidp_append_node(const_efidp dp, const_efidp dn, efidp *out)
- 		return rc;
- 	}
- 
--	lsz = efidp_size(dp);
--	if (lsz < 0) {
--		efi_error("efidp_size(dp) returned error");
--		return -1;
-+	if (!dp && dn) {
-+		rc = efidp_duplicate_path(dn, out);
-+		if (rc < 0)
-+			efi_error("efidp_duplicate_path() failed");
-+		return rc;
- 	}
- 
- 	if (dp && !dn) {
-@@ -209,13 +217,17 @@ efidp_append_node(const_efidp dp, const_efidp dn, efidp *out)
- 	}
- 
- 	lsz = efidp_size(dp);
--	if (lsz < 0)
-+	if (lsz < 0) {
-+		efi_error("efidp_size(dp) returned error");
- 		return -1;
-+	}
- 
- 
- 	rsz = efidp_node_size(dn);
--	if (rsz < 0)
-+	if (rsz < 0) {
-+		efi_error("efidp_size(dn) returned error");
- 		return -1;
-+	}
- 
- 	if (!dp && dn) {
- 		if (add(rsz, sizeof(end_entire), &newsz)) {
--- 
-2.12.2
-
diff --git a/SOURCES/0011-Improve-ACPI-device-path-formatting.patch b/SOURCES/0011-Improve-ACPI-device-path-formatting.patch
new file mode 100644
index 0000000..204551b
--- /dev/null
+++ b/SOURCES/0011-Improve-ACPI-device-path-formatting.patch
@@ -0,0 +1,402 @@
+From eb7db33c6cf4172551fe0f9f7cf4aa047dc16d88 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 14:27:11 -0400
+Subject: [PATCH 11/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0011-efi_variable_import-make-sure-var.data_size-is-set.patch b/SOURCES/0011-efi_variable_import-make-sure-var.data_size-is-set.patch
deleted file mode 100644
index c037b05..0000000
--- a/SOURCES/0011-efi_variable_import-make-sure-var.data_size-is-set.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From bc5f74e97ff48b89028a5f3cd0064401b37c0951 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:56:53 -0400
-Subject: [PATCH 11/22] efi_variable_import(): make sure var.data_size is set.
-
-Covscan noticed that var.data_size isn't set when we memcpy the
-structure.  It should be set.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/export.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/export.c b/src/export.c
-index 89af720..27ce501 100644
---- a/src/export.c
-+++ b/src/export.c
-@@ -118,6 +118,7 @@ efi_variable_import(uint8_t *data, size_t size, efi_variable_t **var_out)
- 			var.name[i] = wname[i] & 0xff;
- 		ptr += name_len * 2;
- 
-+		var.data_size = data_len;
- 		var.data = malloc(data_len);
- 		if (!var.data) {
- 			int saved_errno = errno;
--- 
-2.12.2
-
diff --git a/SOURCES/0012-Give-linux-s-parse-functions-the-unmodified-device-l.patch b/SOURCES/0012-Give-linux-s-parse-functions-the-unmodified-device-l.patch
new file mode 100644
index 0000000..0fa7c7b
--- /dev/null
+++ b/SOURCES/0012-Give-linux-s-parse-functions-the-unmodified-device-l.patch
@@ -0,0 +1,177 @@
+From ba0655c62978ba64c227f1f87d9da3e1dea4f821 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 14:37:14 -0400
+Subject: [PATCH 12/17] Give linux-*'s ->parse() functions the unmodified
+ device link as well
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0012-makeguids-free-our-input-buffer.patch b/SOURCES/0012-makeguids-free-our-input-buffer.patch
deleted file mode 100644
index c3a6b24..0000000
--- a/SOURCES/0012-makeguids-free-our-input-buffer.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From a09b1f454d01799f4976cb1396348bd850e7223a Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 14:59:57 -0400
-Subject: [PATCH 12/22] makeguids: free our input buffer.
-
-Covscan noticed this, but didn't notice that this is a short lived
-program that just parses some tables during the build.  It *sooo*
-doesn't matter.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/makeguids.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/makeguids.c b/src/makeguids.c
-index da2f5f7..6a76c46 100644
---- a/src/makeguids.c
-+++ b/src/makeguids.c
-@@ -212,6 +212,7 @@ main(int argc, char *argv[])
- 	close(in);
- 	close(guidout);
- 	close(nameout);
-+	free(inbuf);
- 
- 	return 0;
- }
--- 
-2.12.2
-
diff --git a/SOURCES/0013-Move-ACPI-ID-parsing-to-a-shared-location.patch b/SOURCES/0013-Move-ACPI-ID-parsing-to-a-shared-location.patch
new file mode 100644
index 0000000..1b0033d
--- /dev/null
+++ b/SOURCES/0013-Move-ACPI-ID-parsing-to-a-shared-location.patch
@@ -0,0 +1,391 @@
+From e2f68c8f9f4fab48f1ef3a4585932f757593fa92 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 14:43:32 -0400
+Subject: [PATCH 13/17] 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 <pjones@redhat.com>
+---
+ 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
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#include "fix_coverity.h"
++
++#include <errno.h>
++#include <fcntl.h>
++#include <inttypes.h>
++#include <stdint.h>
++#include <unistd.h>
++
++#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/SOURCES/0013-efi_variable_import-constrain-our-inputs-better.patch b/SOURCES/0013-efi_variable_import-constrain-our-inputs-better.patch
deleted file mode 100644
index d8b1f64..0000000
--- a/SOURCES/0013-efi_variable_import-constrain-our-inputs-better.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From f6dc880cb1684d1836ade34e44c7710029c174e2 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:02:27 -0400
-Subject: [PATCH 13/22] efi_variable_import(): constrain our inputs better.
-
-efi_variable_import() could plausibly pass NULL to memcpy() if buf is 0
-and size is < 0, though that should never be the case.  Make the input
-checking return EINVAL if that's the case.
-
-Found by Covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/loadopt.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/loadopt.c b/src/loadopt.c
-index a3c1ba9..d4c2d46 100644
---- a/src/loadopt.c
-+++ b/src/loadopt.c
-@@ -302,7 +302,7 @@ __attribute__((__visibility__ ("default")))
- efi_loadopt_args_as_utf8(uint8_t *buf, ssize_t size, uint8_t *utf8)
- {
- 	ssize_t req;
--	if (!buf && size > 0) {
-+	if (!buf && size != 0) {
- 		errno = EINVAL;
- 		return -1;
- 	}
--- 
-2.12.2
-
diff --git a/SOURCES/0014-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch b/SOURCES/0014-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch
new file mode 100644
index 0000000..b761a7a
--- /dev/null
+++ b/SOURCES/0014-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch
@@ -0,0 +1,425 @@
+From 6b62aa40cfa1feb924609a065098da98c99e925c Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 14:45:14 -0400
+Subject: [PATCH 14/17] Make a platform ACPI root parser separate from PCI
+ roots.
+
+Because apparently PNP0A03 and PNP0A0C weren't good enough.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#include "fix_coverity.h"
++
++#include <errno.h>
++#include <fcntl.h>
++#include <inttypes.h>
++#include <stdint.h>
++#include <unistd.h>
++
++#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
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#include "fix_coverity.h"
++
++#include <errno.h>
++#include <fcntl.h>
++#include <inttypes.h>
++#include <stdint.h>
++#include <unistd.h>
++
++#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/SOURCES/0014-efi_loadopt_create-check-buf-for-NULLness.patch b/SOURCES/0014-efi_loadopt_create-check-buf-for-NULLness.patch
deleted file mode 100644
index 2a564e6..0000000
--- a/SOURCES/0014-efi_loadopt_create-check-buf-for-NULLness.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 20e9ecb4a4b327a32dc639a7ff826af5089e3fbf Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:04:24 -0400
-Subject: [PATCH 14/22] efi_loadopt_create(): check buf for NULLness.
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/loadopt.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/src/loadopt.c b/src/loadopt.c
-index d4c2d46..8db8074 100644
---- a/src/loadopt.c
-+++ b/src/loadopt.c
-@@ -46,13 +46,20 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
- 	ssize_t sz = sizeof (attributes)
- 		     + sizeof (uint16_t) + desc_len
- 		     + dp_size + optional_data_size;
-+
- 	if (size == 0)
- 		return sz;
-+
- 	if (size < sz) {
- 		errno = ENOSPC;
- 		return -1;
- 	}
- 
-+	if (!buf) {
-+		errno = EINVAL;
-+		return -1;
-+	}
-+
- 	if (!optional_data && optional_data_size != 0) {
- 		errno = EINVAL;
- 		return -1;
--- 
-2.12.2
-
diff --git a/SOURCES/0015-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch b/SOURCES/0015-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch
new file mode 100644
index 0000000..4853ff9
--- /dev/null
+++ b/SOURCES/0015-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch
@@ -0,0 +1,71 @@
+From ca71ba77abee7cea805e71a7faded706d19e4c58 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 16:16:00 -0400
+Subject: [PATCH 15/17] Make a way to say "-e 3" isn't viable for a kind of
+ device.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0015-efidp_duplicate_extra-error-if-our-allocation-is-too.patch b/SOURCES/0015-efidp_duplicate_extra-error-if-our-allocation-is-too.patch
deleted file mode 100644
index c75750d..0000000
--- a/SOURCES/0015-efidp_duplicate_extra-error-if-our-allocation-is-too.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 32f6b0d5974e39dbcce89d9ab8551e35eb8fdaab Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:14:33 -0400
-Subject: [PATCH 15/22] efidp_duplicate_extra(): error if our allocation is too
- small.
-
-Covscan believes we might pass 0 to calloc(), though I suspect this is
-because it doesn't fully grok add().
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/dp.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/src/dp.c b/src/dp.c
-index e700af9..eadb397 100644
---- a/src/dp.c
-+++ b/src/dp.c
-@@ -81,6 +81,12 @@ efidp_duplicate_extra(const_efidp dp, efidp *out, size_t extra)
- 		return -1;
- 	}
- 
-+	if (plus < (ssize_t)sizeof(efidp_header)) {
-+		errno = EINVAL;
-+		efi_error("allocation for new device path is smaller than device path header.");
-+		return -1;
-+	}
-+
- 	new = calloc(1, plus);
- 	if (!new) {
- 		efi_error("allocation failed");
--- 
-2.12.2
-
diff --git a/SOURCES/0016-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch b/SOURCES/0016-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch
new file mode 100644
index 0000000..2b9ca26
--- /dev/null
+++ b/SOURCES/0016-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch
@@ -0,0 +1,131 @@
+From d8637ea2b540fc9d16f1d1c1312e49a24082eefe Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 16:16:35 -0400
+Subject: [PATCH 16/17] 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 <pjones@redhat.com>
+---
+ 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
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#include "fix_coverity.h"
++
++#include <errno.h>
++#include <fcntl.h>
++#include <inttypes.h>
++#include <stdint.h>
++#include <unistd.h>
++
++#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/SOURCES/0016-show_errors-make-the-useful-part-here-not-be-dead-co.patch b/SOURCES/0016-show_errors-make-the-useful-part-here-not-be-dead-co.patch
deleted file mode 100644
index 0b2b17a..0000000
--- a/SOURCES/0016-show_errors-make-the-useful-part-here-not-be-dead-co.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 878c81f02e9cabbc990028b2cf87442813eb39f5 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:18:05 -0400
-Subject: [PATCH 16/22] show_errors(): make the useful part here not be dead
- code.
-
-Woops.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/efivar.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/efivar.c b/src/efivar.c
-index cbefe8b..38d19e1 100644
---- a/src/efivar.c
-+++ b/src/efivar.c
-@@ -61,7 +61,7 @@ static int verbose_errors = 0;
- static void
- show_errors(void)
- {
--	int rc = 0;
-+	int rc = 1;
- 
- 	if (!verbose_errors)
- 		return;
--- 
-2.12.2
-
diff --git a/SOURCES/0017-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch b/SOURCES/0017-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch
new file mode 100644
index 0000000..13443c2
--- /dev/null
+++ b/SOURCES/0017-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch
@@ -0,0 +1,110 @@
+From bc215d06720b346ba0d888a6149cf90f544a90ad Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 20 Jun 2018 17:00:24 -0400
+Subject: [PATCH 17/17] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0017-efi_loadopt_args_from_file-make-sure-buf-is-only-NUL.patch b/SOURCES/0017-efi_loadopt_args_from_file-make-sure-buf-is-only-NUL.patch
deleted file mode 100644
index cfecd77..0000000
--- a/SOURCES/0017-efi_loadopt_args_from_file-make-sure-buf-is-only-NUL.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From d251242a71ef01626444180c630330bcfb0ca69e Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:19:18 -0400
-Subject: [PATCH 17/22] efi_loadopt_args_from_file(): make sure buf is only
- NULL if size is.
-
-This avoids passing NULL to fread().
-
-Found by covscan.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/loadopt.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/loadopt.c b/src/loadopt.c
-index 8db8074..5301f3d 100644
---- a/src/loadopt.c
-+++ b/src/loadopt.c
-@@ -269,7 +269,7 @@ efi_loadopt_args_from_file(uint8_t *buf, ssize_t size, char *filename)
- 	int saved_errno;
- 	FILE *f;
- 
--	if (!buf && size > 0) {
-+	if (!buf && size != 0) {
- 		errno = -EINVAL;
- 		return -1;
- 	}
--- 
-2.12.2
-
diff --git a/SOURCES/0018-Pacify-clang-analyzer-just-a-little.patch b/SOURCES/0018-Pacify-clang-analyzer-just-a-little.patch
new file mode 100644
index 0000000..5c8c58f
--- /dev/null
+++ b/SOURCES/0018-Pacify-clang-analyzer-just-a-little.patch
@@ -0,0 +1,25 @@
+From 8f9c1406a2a50d0c67b1380ad6fddc2c266d39f6 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 11:13:39 -0400
+Subject: [PATCH 18/24] Pacify clang analyzer just a little.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0018-calls-to-sysfs_readlink-check-linkbuf-for-NULLness.patch b/SOURCES/0018-calls-to-sysfs_readlink-check-linkbuf-for-NULLness.patch
deleted file mode 100644
index a53c6b7..0000000
--- a/SOURCES/0018-calls-to-sysfs_readlink-check-linkbuf-for-NULLness.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-From 38039634f722eb6e3ef4221e3f37c19a1bc96ae7 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:21:13 -0400
-Subject: [PATCH 18/22] calls to sysfs_readlink(): check linkbuf for NULLness.
-
-If linkbuf were NULL, sysfs_readlink() would have returned an error, but
-covscan can't figure that out, so it thinks linkbuf might be NULL.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/linux.c | 16 ++++++++--------
- 1 file changed, 8 insertions(+), 8 deletions(-)
-
-diff --git a/src/linux.c b/src/linux.c
-index 3c77a93..85b4ee3 100644
---- a/src/linux.c
-+++ b/src/linux.c
-@@ -53,7 +53,7 @@ set_disk_and_part_name(struct disk_info *info)
- 
- 	rc = sysfs_readlink(&linkbuf, "/sys/dev/block/%"PRIu64":%"PRIu32,
- 		      info->major, info->minor);
--	if (rc < 0)
-+	if (rc < 0 || !linkbuf)
- 		return -1;
- 
- 	char *ultimate;
-@@ -141,7 +141,7 @@ get_partition_number(const char *devpath)
- 	min = minor(statbuf.st_rdev);
- 
- 	rc = sysfs_readlink(&linkbuf, "/sys/dev/block/%u:%u", maj, min);
--	if (rc < 0)
-+	if (rc < 0 || !linkbuf)
- 		return -1;
- 
- 	rc = read_sysfs_file(&partbuf, "/sys/dev/block/%s/partition", linkbuf);
-@@ -170,7 +170,7 @@ find_parent_devpath(const char * const child, char **parent)
- 
- 	/* look up full path symlink */
- 	ret = sysfs_readlink(&linkbuf, "/sys/class/block/%s", node);
--	if (ret < 0)
-+	if (ret < 0 || !linkbuf)
- 		return ret;
- 
- 	/* strip child */
-@@ -747,7 +747,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct disk_info *info)
- 
- 	rc = sysfs_readlink(&linkbuf, "/sys/dev/block/%"PRIu64":%u",
- 			    info->major, info->minor);
--	if (rc < 0)
-+	if (rc < 0 || !linkbuf)
- 		return -1;
- 
- 	/*
-@@ -771,7 +771,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct disk_info *info)
- 		return -1;
- 	tmppath[loff] = '\0';
- 	rc = sysfs_readlink(&driverbuf, "/sys/dev/block/%s/driver", tmppath);
--	if (rc < 0)
-+	if (rc < 0 || !driverbuf)
- 		return -1;
- 
- 	char *driver = strrchr(driverbuf, '/');
-@@ -867,7 +867,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct disk_info *info)
- 
- 		rc = sysfs_readlink(&linkbuf, "/sys/class/block/%s/device",
- 			      info->disk_name);
--		if (rc < 0)
-+		if (rc < 0 || !linkbuf)
- 			return 0;
- 
- 		rc = sscanf(linkbuf, "../../../%d:%d:%d:%"PRIu64,
-@@ -1001,14 +1001,14 @@ make_net_pci_path(uint8_t *buf, ssize_t size, const char * const ifname)
- 	int rc;
- 
- 	rc = sysfs_readlink(&linkbuf, "/sys/class/net/%s", ifname);
--	if (rc < 0)
-+	if (rc < 0 || !linkbuf)
- 		return -1;
- 
- 	/*
- 	 * the sysfs path basically looks like:
- 	 * ../../devices/$PCI_STUFF/net/$IFACE
- 	 */
--	rc = sscanf(linkbuf+loff, "../../devices/%n", &lsz);
-+	rc = sscanf(linkbuf, "../../devices/%n", &lsz);
- 	if (rc != 0)
- 		return -1;
- 	loff += lsz;
--- 
-2.12.2
-
diff --git a/SOURCES/0019-Try-even-harder-to-convince-coverity-that-get_file-i.patch b/SOURCES/0019-Try-even-harder-to-convince-coverity-that-get_file-i.patch
new file mode 100644
index 0000000..e77e42a
--- /dev/null
+++ b/SOURCES/0019-Try-even-harder-to-convince-coverity-that-get_file-i.patch
@@ -0,0 +1,32 @@
+From 576b89de7d1a49d64efab9d494eeea5a296bdccd Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 12:23:20 -0400
+Subject: [PATCH 19/24] Try even harder to convince coverity that get_file
+ isn't leaking memory...
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0019-efivar-main-explain-efi_well_known_guids-to-the-comp.patch b/SOURCES/0019-efivar-main-explain-efi_well_known_guids-to-the-comp.patch
deleted file mode 100644
index 54386b1..0000000
--- a/SOURCES/0019-efivar-main-explain-efi_well_known_guids-to-the-comp.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 089265335dfb746a77ec15a917c12e8c77a41240 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:34:28 -0400
-Subject: [PATCH 19/22] efivar main(): explain efi_well_known_guids to the
- compiler better.
-
-Covscan doesn't quite understand that this _is_ an array, so make it
-look even more like one.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/efivar.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/efivar.c b/src/efivar.c
-index 38d19e1..3ed9a84 100644
---- a/src/efivar.c
-+++ b/src/efivar.c
-@@ -461,13 +461,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_end;
-+			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.12.2
-
diff --git a/SOURCES/0020-Make-the-debug-code-less-intrusive.patch b/SOURCES/0020-Make-the-debug-code-less-intrusive.patch
new file mode 100644
index 0000000..0d32cc4
--- /dev/null
+++ b/SOURCES/0020-Make-the-debug-code-less-intrusive.patch
@@ -0,0 +1,1063 @@
+From 154d0794827ffe9fd6adbbdf1cd3d04dba18e24d Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 13:32:28 -0400
+Subject: [PATCH 20/24] Make the debug() code less intrusive
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0020-dp.h-Try-to-make-covscan-believe-format-is-checking-.patch b/SOURCES/0020-dp.h-Try-to-make-covscan-believe-format-is-checking-.patch
deleted file mode 100644
index 3962f5f..0000000
--- a/SOURCES/0020-dp.h-Try-to-make-covscan-believe-format-is-checking-.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 9d74090cea256021e68b204c4770a5df28398cbd Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Mon, 1 May 2017 15:59:09 -0400
-Subject: [PATCH 20/22] dp.h: Try to make covscan believe format() is checking
- its bounds.
-
-covscan doesn't grok that size and off wind up being proxies for buf's
-NULL check.  Hilarity ensues.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/dp.h | 16 +++++++++++-----
- 1 file changed, 11 insertions(+), 5 deletions(-)
-
-diff --git a/src/dp.h b/src/dp.h
-index d6775a6..c14a9ec 100644
---- a/src/dp.h
-+++ b/src/dp.h
-@@ -28,11 +28,17 @@
- #include "ucs2.h"
- 
- #define format(buf, size, off, dp_type, fmt, args...) ({		\
--		ssize_t _x = 0;						\
--		if ((off) >= 0) {					\
--			_x = snprintf(((buf)+(off)),			\
--			       ((size)?((size)-(off)):0),		\
--			       fmt, ## args);				\
-+		ssize_t _insize = 0;					\
-+		void *_inbuf = NULL;					\
-+		if ((buf) != NULL && (size) > 0) {			\
-+			_inbuf = (buf) + (off);				\
-+			_insize = (size) - (off);			\
-+		}							\
-+		if ((off) >= 0 &&					\
-+		    ((buf == NULL && _insize == 0) ||			\
-+		     (buf != NULL && _insize >= 0))) {			\
-+			ssize_t _x = 0;					\
-+			_x = snprintf(_inbuf, _insize, fmt, ## args);	\
- 			if (_x < 0) {					\
- 				efi_error(				\
- 					"could not build %s DP string",	\
--- 
-2.12.2
-
diff --git a/SOURCES/0021-efiboot-Make-the-device-node-skipping-code-pass-cove.patch b/SOURCES/0021-efiboot-Make-the-device-node-skipping-code-pass-cove.patch
new file mode 100644
index 0000000..4e75326
--- /dev/null
+++ b/SOURCES/0021-efiboot-Make-the-device-node-skipping-code-pass-cove.patch
@@ -0,0 +1,79 @@
+From bc11451222cc77d8c1b4e752167adabd3c7f64c9 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 13:33:26 -0400
+Subject: [PATCH 21/24] efiboot: Make the device node skipping code pass
+ coverity.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0021-gpt-try-to-avoid-trusting-unverified-partition-table.patch b/SOURCES/0021-gpt-try-to-avoid-trusting-unverified-partition-table.patch
deleted file mode 100644
index af9704d..0000000
--- a/SOURCES/0021-gpt-try-to-avoid-trusting-unverified-partition-table.patch
+++ /dev/null
@@ -1,360 +0,0 @@
-From 29a53c93ce063c8272e44f4981201a4752fc6ba1 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Tue, 9 May 2017 14:20:13 -0400
-Subject: [PATCH 21/24] gpt: try to avoid trusting unverified partition table
- data.
-
-Covscan complains thusly:
- 4. efivar-31/src/gpt.c:338: tainted_data_return: Function "alloc_read_gpt_header" returns tainted data.
- 7. efivar-31/src/gpt.c:311:2: tainted_data_argument: Function "read_lba" taints argument "gpt".
-12. efivar-31/src/gpt.c:245:2: tainted_data_argument: Calling function "read" taints parameter "*iobuf". [Note: The source code implementation of the function has been overridden by a builtin model.]
-13. efivar-31/src/gpt.c:246:2: tainted_data_transitive: "memcpy" taints argument "buffer" because argument "iobuf" is tainted. [Note: The source code implementation of the function has been overridden by a builtin model.]
-16. efivar-31/src/gpt.c:316:2: return_tainted_data: Returning tainted variable "gpt".
-17. efivar-31/src/gpt.c:338: var_assign: Assigning: "*gpt" = "alloc_read_gpt_header", which taints "*gpt".
-26. efivar-31/src/gpt.c:382: tainted_data: Passing tainted variable "(*gpt)->num_partition_entries" to a tainted sink.
-27. efivar-31/src/gpt.c:272:15: var_assign_alias: Assigning: "count" = "(__u32)(__le32)gpt->num_partition_entries * (__u32)(__le32)gpt->sizeof_partition_entry". Both are now tainted.
-30. efivar-31/src/gpt.c:278:2: tainted_data_sink_lv_call: Passing tainted variable "count" to tainted data sink "malloc".
-
-Hopefully this patch validates num_partition_entries and
-sizeof_partition_entry well enough...
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/disk.c |   3 +-
- src/gpt.c  | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
- src/gpt.h  |   3 +-
- 3 files changed, 173 insertions(+), 23 deletions(-)
-
-diff --git a/src/disk.c b/src/disk.c
-index 91d636d..0a7a769 100644
---- a/src/disk.c
-+++ b/src/disk.c
-@@ -225,7 +225,8 @@ get_partition_info(int fd, uint32_t options,
- 						  signature,
- 						  mbr_type,
- 						  signature_type,
--			(options & EFIBOOT_OPTIONS_IGNORE_PMBR_ERR)?1:0);
-+			(options & EFIBOOT_OPTIONS_IGNORE_PMBR_ERR)?1:0,
-+			sector_size);
- 	if (gpt_invalid) {
- 		mbr_invalid = msdos_disk_get_partition_info(fd,
- 			(options & EFIBOOT_OPTIONS_WRITE_SIGNATURE)?1:0,
-diff --git a/src/gpt.c b/src/gpt.c
-index e9c713b..7baa992 100644
---- a/src/gpt.c
-+++ b/src/gpt.c
-@@ -29,6 +29,7 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-+#include <sys/param.h>
- #include <sys/stat.h>
- #include <sys/utsname.h>
- #include <unistd.h>
-@@ -266,11 +267,10 @@ read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
-  * Notes: remember to free pte when you're done!
-  */
- static gpt_entry *
--alloc_read_gpt_entries(int fd, gpt_header * gpt)
-+alloc_read_gpt_entries(int fd, uint32_t nptes, uint32_t ptesz, uint64_t ptelba)
- {
- 	gpt_entry *pte;
--	size_t count = __le32_to_cpu(gpt->num_partition_entries) *
--		__le32_to_cpu(gpt->sizeof_partition_entry);
-+	size_t count = nptes * ptesz;
- 
- 	if (!count)
- 		return NULL;
-@@ -280,8 +280,7 @@ alloc_read_gpt_entries(int fd, gpt_header * gpt)
- 		return NULL;
- 
- 	memset(pte, 0, count);
--	if (!read_lba(fd, __le64_to_cpu(gpt->partition_entry_lba), pte,
--		      count)) {
-+	if (!read_lba(fd, ptelba, pte, count)) {
- 		free(pte);
- 		return NULL;
- 	}
-@@ -317,6 +316,65 @@ alloc_read_gpt_header(int fd, uint64_t lba)
- }
- 
- /**
-+ * validate_nptes(): Tries to ensure that nptes is a reasonable value
-+ * @first_block is the beginning LBA to bound the table
-+ * @pte_start is the starting LBA of the partition table
-+ * @last_block is the end LBA of to bound the table
-+ * @ptesz is the size of a partition table entry
-+ * @nptes is the number of entries we have.
-+ * @blksz is the block size of the device.
-+ *
-+ * Description: returns 0 if the partition table doesn't fit, 1 if it does
-+ */
-+static int
-+validate_nptes(uint64_t first_block, uint64_t pte_start, uint64_t last_block,
-+	       uint32_t ptesz, uint32_t nptes, uint32_t blksz)
-+{
-+	uint32_t min_entry_size = sizeof(gpt_entry);
-+	uint32_t min_entry_size_mod = 128 - sizeof(gpt_entry) % 128;
-+	uint64_t max_blocks, max_bytes;
-+
-+	if (min_entry_size_mod == 128)
-+		min_entry_size_mod = 0;
-+	min_entry_size += min_entry_size_mod;
-+
-+	if (ptesz < min_entry_size)
-+		return 0;
-+
-+	if (pte_start < first_block || pte_start > last_block)
-+		return 0;
-+
-+	max_blocks = last_block - pte_start;
-+	if (UINT64_MAX / blksz < max_blocks)
-+		return 0;
-+
-+	max_bytes = max_blocks * blksz;
-+	if (UINT64_MAX / ptesz < max_bytes)
-+		return 0;
-+
-+	if (ptesz > max_bytes / nptes)
-+		return 0;
-+
-+	if (max_bytes / ptesz < nptes)
-+		return 0;
-+
-+	return 1;
-+}
-+
-+static int
-+check_lba(uint64_t lba, uint64_t lastlba, char *name)
-+{
-+	if (lba > lastlba) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"Invalid %s LBA %"PRIx64" max:%"PRIx64"\n",
-+				name, lba, lastlba);
-+		return 0;
-+	}
-+	return 1;
-+}
-+
-+/**
-  * is_gpt_valid() - tests one GPT header and PTEs for validity
-  * @fd  is an open file descriptor to the whole disk
-  * @lba is the logical block address of the GPT header to test
-@@ -328,10 +386,12 @@ alloc_read_gpt_header(int fd, uint64_t lba)
-  */
- static int
- is_gpt_valid(int fd, uint64_t lba,
--	     gpt_header ** gpt, gpt_entry ** ptes)
-+	     gpt_header ** gpt, gpt_entry ** ptes,
-+	     uint32_t logical_block_size)
- {
- 	int rc = 0;		/* default to not valid */
- 	uint32_t crc, origcrc;
-+	uint64_t max_device_lba = last_lba(fd);
- 
- 	if (!gpt || !ptes)
- 		return 0;
-@@ -343,7 +403,7 @@ is_gpt_valid(int fd, uint64_t lba,
- 		if (report_errors)
- 			fprintf(stderr,
- 				"GUID Partition Table Header signature is wrong"
--			       ": %" PRIx64" != %" PRIx64 "\n",
-+			       ": %"PRIx64" != %"PRIx64"\n",
- 			       (uint64_t)__le64_to_cpu((*gpt)->signature),
- 			       GPT_HEADER_SIGNATURE);
- 		free(*gpt);
-@@ -351,6 +411,20 @@ is_gpt_valid(int fd, uint64_t lba,
- 		return rc;
- 	}
- 
-+	uint32_t hdrsz = __le32_to_cpu((*gpt)->header_size);
-+	uint32_t hdrmin = MAX(92,
-+			      sizeof(gpt_header) - sizeof((*gpt)->reserved2));
-+	if (hdrsz < hdrmin || hdrsz > logical_block_size) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"GUID Partition Table Header size is invalid (%d < %d < %d)\n",
-+				hdrmin, hdrsz,
-+				logical_block_size);
-+		free (*gpt);
-+		*gpt = NULL;
-+		return rc;
-+	}
-+
- 	/* Check the GUID Partition Table Header CRC */
- 	origcrc = __le32_to_cpu((*gpt)->header_crc32);
- 	(*gpt)->header_crc32 = 0;
-@@ -369,26 +443,97 @@ is_gpt_valid(int fd, uint64_t lba,
- 
- 	/* Check that the my_lba entry points to the LBA
- 	 * that contains the GPT we read */
--	if (__le64_to_cpu((*gpt)->my_lba) != lba) {
-+	uint64_t mylba = __le64_to_cpu((*gpt)->my_lba);
-+	uint64_t altlba = __le64_to_cpu((*gpt)->alternate_lba);
-+	if (mylba != lba && altlba != lba) {
- 		if (report_errors)
- 			fprintf(stderr,
--				"my_lba %"PRIx64 "x != lba %"PRIx64 "x.\n",
--				(uint64_t)__le64_to_cpu((*gpt)->my_lba), lba);
-+				"lba %"PRIx64" != lba %"PRIx64".\n",
-+				mylba, lba);
-+err:
- 		free(*gpt);
- 		*gpt = NULL;
- 		return 0;
- 	}
- 
--	if (!(*ptes = alloc_read_gpt_entries(fd, *gpt))) {
-+	if (!check_lba(mylba, max_device_lba, "GPT"))
-+		goto err;
-+
-+	if (!check_lba(altlba, max_device_lba, "GPT Alt"))
-+		goto err;
-+
-+	uint64_t ptelba = __le64_to_cpu((*gpt)->partition_entry_lba);
-+	uint64_t fulba = __le64_to_cpu((*gpt)->first_usable_lba);
-+	uint64_t lulba = __le64_to_cpu((*gpt)->last_usable_lba);
-+	uint32_t nptes = __le32_to_cpu((*gpt)->num_partition_entries);
-+	uint32_t ptesz = __le32_to_cpu((*gpt)->sizeof_partition_entry);
-+
-+	if (!check_lba(ptelba, max_device_lba, "PTE"))
-+		goto err;
-+	if (!check_lba(fulba, max_device_lba, "First Usable"))
-+		goto err;
-+	if (!check_lba(lulba, max_device_lba, "Last Usable"))
-+		goto err;
-+
-+	if (ptesz < sizeof(gpt_entry) || ptesz % 128 != 0) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"Invalid GPT entry size is %d.\n",
-+				ptesz);
-+		goto err;
-+	}
-+
-+	/* There's really no good answer to maximum bounds, but this large
-+	 * would be completely absurd, so... */
-+	if (nptes > 1024) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"Not honoring insane number of Partition Table Entries 0x%"PRIx32".\n",
-+				nptes);
-+
-+		goto err;
-+	}
-+
-+	if (ptesz > 4096) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"Not honoring insane Partition Table Entry size 0x%"PRIx32".\n",
-+				ptesz);
-+		goto err;
-+	}
-+
-+	uint64_t pte_blocks;
-+	uint64_t firstlba, lastlba;
-+
-+	if (altlba > mylba) {
-+		firstlba = mylba + 1;
-+		lastlba = fulba;
-+		pte_blocks = fulba - ptelba;
-+		rc = validate_nptes(firstlba, ptelba, fulba,
-+				    ptesz, nptes, logical_block_size);
-+	} else {
-+		firstlba = lulba;
-+		lastlba = mylba;
-+		pte_blocks = mylba - ptelba;
-+		rc = validate_nptes(lulba, ptelba, mylba,
-+				    ptesz, nptes, logical_block_size);
-+	}
-+	if (!rc) {
-+		if (report_errors)
-+			fprintf(stderr,
-+				"%"PRIu32" partition table entries with size 0x%"PRIx32" doesn't fit in 0x%"PRIx64" blocks between 0x%"PRIx64" and 0x%"PRIx64".\n",
-+				nptes, ptesz, pte_blocks, firstlba, lastlba);
-+		goto err;
-+	}
-+
-+	if (!(*ptes = alloc_read_gpt_entries(fd, nptes, ptesz, ptelba))) {
- 		free(*gpt);
- 		*gpt = NULL;
- 		return 0;
- 	}
- 
- 	/* Check the GUID Partition Entry Array CRC */
--	crc = efi_crc32(*ptes,
--			__le32_to_cpu((*gpt)->num_partition_entries) *
--			__le32_to_cpu((*gpt)->sizeof_partition_entry));
-+	crc = efi_crc32(*ptes, nptes * ptesz);
- 	if (crc != __le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
- 		if (report_errors)
- 		     fprintf(stderr,
-@@ -519,7 +664,7 @@ compare_gpts(gpt_header *pgpt, gpt_header *agpt, uint64_t lastlba)
-  */
- static int
- find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes,
--	       int ignore_pmbr_err)
-+	       int ignore_pmbr_err, int logical_block_size)
- {
- 	int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
- 	gpt_header *pgpt = NULL, *agpt = NULL;
-@@ -535,16 +680,18 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes,
- 
- 	lastlba = last_lba(fd);
- 	good_pgpt = is_gpt_valid(fd, GPT_PRIMARY_PARTITION_TABLE_LBA,
--				 &pgpt, &pptes);
-+				 &pgpt, &pptes, logical_block_size);
- 	if (good_pgpt) {
- 		good_agpt = is_gpt_valid(fd,
- 					 __le64_to_cpu(pgpt->alternate_lba),
--					 &agpt, &aptes);
-+					 &agpt, &aptes, logical_block_size);
- 		if (!good_agpt) {
--			good_agpt = is_gpt_valid(fd, lastlba, &agpt, &aptes);
-+			good_agpt = is_gpt_valid(fd, lastlba, &agpt, &aptes,
-+						 logical_block_size);
- 		}
- 	} else {
--		good_agpt = is_gpt_valid(fd, lastlba, &agpt, &aptes);
-+		good_agpt = is_gpt_valid(fd, lastlba, &agpt, &aptes,
-+					 logical_block_size);
- 	}
- 
- 	/* The obviously unsuccessful case */
-@@ -634,7 +781,7 @@ __attribute__((__visibility__ ("hidden")))
- gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
- 			    uint64_t * size, uint8_t *signature,
- 			    uint8_t * mbr_type, uint8_t * signature_type,
--			    int ignore_pmbr_error)
-+			    int ignore_pmbr_error, int logical_block_size)
- {
- 	gpt_header *gpt = NULL;
- 	gpt_entry *ptes = NULL, *p;
-@@ -644,7 +791,8 @@ gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
- 	if (report)
- 		report_errors = 1;
- 
--	rc = find_valid_gpt(fd, &gpt, &ptes, ignore_pmbr_error);
-+	rc = find_valid_gpt(fd, &gpt, &ptes, ignore_pmbr_error,
-+			    logical_block_size);
- 	if (rc < 0)
- 		return rc;
- 
-diff --git a/src/gpt.h b/src/gpt.h
-index 2249b59..678ee37 100644
---- a/src/gpt.h
-+++ b/src/gpt.h
-@@ -147,7 +147,8 @@ extern int gpt_disk_get_partition_info (int fd, uint32_t num, uint64_t *start,
- 					uint64_t *size, uint8_t *signature,
- 					uint8_t *mbr_type,
- 					uint8_t *signature_type,
--					int ignore_pmbr_error)
-+					int ignore_pmbr_error,
-+					int logical_sector_size)
- 	__attribute__((__nonnull__ (3, 4, 5, 6, 7)))
- 	__attribute__((__visibility__ ("hidden")));
- 
--- 
-2.12.2
-
diff --git a/SOURCES/0022-Simplify-efidp_append_node-even-more.patch b/SOURCES/0022-Simplify-efidp_append_node-even-more.patch
deleted file mode 100644
index d9ff9db..0000000
--- a/SOURCES/0022-Simplify-efidp_append_node-even-more.patch
+++ /dev/null
@@ -1,138 +0,0 @@
-From 6e59831ea44426736c2ac615c5145c427418086a Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Tue, 9 May 2017 15:15:55 -0400
-Subject: [PATCH 22/24] Simplify efidp_append_node() even more.
-
-Covscan rightly notices that now we've got enough tests on dp and dn
-that some of them are provably dead code.
-
-So take a bunch out.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/dp.c | 94 +++++++++++++++++++---------------------------------------------
- 1 file changed, 28 insertions(+), 66 deletions(-)
-
-diff --git a/src/dp.c b/src/dp.c
-index eadb397..14f4cfe 100644
---- a/src/dp.c
-+++ b/src/dp.c
-@@ -196,78 +196,38 @@ int
- __attribute__((__visibility__ ("default")))
- efidp_append_node(const_efidp dp, const_efidp dn, efidp *out)
- {
--	ssize_t lsz, rsz, newsz;
-+	ssize_t lsz = 0, rsz = 0, newsz;
- 	int rc;
- 
--	if (!dp && !dn) {
--		rc = efidp_duplicate_path(
--			(const_efidp)(const efidp_header * const)&end_entire,
--			out);
--		if (rc < 0)
--			efi_error("efidp_duplicate_path() failed");
--		return rc;
--	}
--
--	if (!dp && dn) {
--		rc = efidp_duplicate_path(dn, out);
--		if (rc < 0)
--			efi_error("efidp_duplicate_path() failed");
--		return rc;
--	}
--
--	if (dp && !dn) {
--		rc = efidp_duplicate_path(dp, out);
--		if (rc < 0)
--			efi_error("efidp_duplicate_path() failed");
--		return rc;
--	}
--
--	lsz = efidp_size(dp);
--	if (lsz < 0) {
--		efi_error("efidp_size(dp) returned error");
--		return -1;
--	}
--
--
--	rsz = efidp_node_size(dn);
--	if (rsz < 0) {
--		efi_error("efidp_size(dn) returned error");
--		return -1;
--	}
--
--	if (!dp && dn) {
--		if (add(rsz, sizeof(end_entire), &newsz)) {
--			errno = EOVERFLOW;
--			efi_error(
--			  "arithmetic overflow computing allocation size");
--			return -1;
--		}
--		efidp new = malloc(rsz + sizeof (end_entire));
--		if (!new) {
--			efi_error("allocation failed");
-+	if (dp) {
-+		lsz = efidp_size(dp);
-+		if (lsz < 0) {
-+			efi_error("efidp_size(dp) returned error");
- 			return -1;
- 		}
- 
--		memcpy(new, dn, dn->length);
--		memcpy((uint8_t *)new + dn->length, &end_entire,
--		       sizeof (end_entire));
--		*out = new;
--		return 0;
--	}
-+		const_efidp le;
-+		le = dp;
-+		while (1) {
-+			if (efidp_type(le) == EFIDP_END_TYPE &&
-+			    efidp_subtype(le) == EFIDP_END_ENTIRE) {
-+				ssize_t lesz = efidp_size(le);
-+				lsz -= lesz;
-+				break;
-+			}
- 
--	const_efidp le;
--	le = dp;
--	while (1) {
--		if (efidp_type(le) == EFIDP_END_TYPE &&
--				efidp_subtype(le) == EFIDP_END_ENTIRE) {
--			ssize_t lesz = efidp_size(le);
--			lsz -= lesz;
--			break;
-+			rc = efidp_get_next_end(le, &le);
-+			if (rc < 0) {
-+				efi_error("efidp_get_next_end() returned error");
-+				return -1;
-+			}
- 		}
-+	}
- 
--		rc = efidp_get_next_end(le, &le);
--		if (rc < 0) {
--			efi_error("efidp_get_next_end() returned error");
-+	if (dn) {
-+		rsz = efidp_node_size(dn);
-+		if (rsz < 0) {
-+			efi_error("efidp_size(dn) returned error");
- 			return -1;
- 		}
- 	}
-@@ -285,8 +245,10 @@ efidp_append_node(const_efidp dp, const_efidp dn, efidp *out)
- 	}
- 
- 	*out = new;
--	memcpy(new, dp, lsz);
--	memcpy((uint8_t *)new + lsz, dn, rsz);
-+	if (dp)
-+		memcpy(new, dp, lsz);
-+	if (dn)
-+		memcpy((uint8_t *)new + lsz, dn, rsz);
- 	memcpy((uint8_t *)new + lsz + rsz, &end_entire, sizeof (end_entire));
- 
- 	return 0;
--- 
-2.12.2
-
diff --git a/SOURCES/0022-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch b/SOURCES/0022-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch
new file mode 100644
index 0000000..8862538
--- /dev/null
+++ b/SOURCES/0022-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch
@@ -0,0 +1,35 @@
+From 22b1a7477c5ef72821e6491c67ad85ca52c1ae85 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 13:55:32 -0400
+Subject: [PATCH 22/24] efiboot: don't error on unknown type with
+ DEV_ABBREV_ONLY
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0023-efi_loadopt_create-avoid-NULL-dereference.patch b/SOURCES/0023-efi_loadopt_create-avoid-NULL-dereference.patch
deleted file mode 100644
index db94606..0000000
--- a/SOURCES/0023-efi_loadopt_create-avoid-NULL-dereference.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From e9ce922ddf2ec6c1095f42ee9857f369084761c3 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Tue, 9 May 2017 15:34:08 -0400
-Subject: [PATCH 23/24] efi_loadopt_create(): avoid NULL dereference
-
-covscan rightly points out that dp is allowed to be NULL (and so is
-buf), so we can't pass those in to memcpy() in those cases.
-
-So don't.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/loadopt.c | 46 +++++++++++++++++++++++++++-------------------
- 1 file changed, 27 insertions(+), 19 deletions(-)
-
-diff --git a/src/loadopt.c b/src/loadopt.c
-index 5301f3d..cf0886d 100644
---- a/src/loadopt.c
-+++ b/src/loadopt.c
-@@ -56,36 +56,44 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
- 	}
- 
- 	if (!buf) {
-+invalid:
- 		errno = EINVAL;
- 		return -1;
- 	}
- 
--	if (!optional_data && optional_data_size != 0) {
--		errno = EINVAL;
--		return -1;
--	}
-+	if (!optional_data && optional_data_size != 0)
-+		goto invalid;
- 
--	if (!dp && dp_size == 0) {
--		errno = EINVAL;
--		return -1;
--	}
-+	if ((!dp && dp_size == 0) || dp_size < 0)
-+		goto invalid;
-+
-+	if (dp) {
-+		if (!efidp_is_valid(dp, dp_size))
-+			goto invalid;
- 
--	uint8_t *pos = buf;
-+		if (efidp_size(dp) != dp_size)
-+			goto invalid;
-+	}
- 
--	*(uint32_t *)pos = attributes;
--	pos += sizeof (attributes);
-+	if (buf) {
-+		uint8_t *pos = buf;
-+		*(uint32_t *)pos = attributes;
-+		pos += sizeof (attributes);
- 
--	*(uint16_t *)pos = dp_size;
--	pos += sizeof (uint16_t);
-+		*(uint16_t *)pos = dp_size;
-+		pos += sizeof (uint16_t);
- 
--	utf8_to_ucs2((uint16_t *)pos, desc_len, 1, (uint8_t *)description);
--	pos += desc_len;
-+		utf8_to_ucs2((uint16_t *)pos, desc_len, 1,
-+			     (uint8_t *)description);
-+		pos += desc_len;
- 
--	memcpy(pos, dp, dp_size);
--	pos += dp_size;
-+		if (dp)
-+			memcpy(pos, dp, dp_size);
-+		pos += dp_size;
- 
--	if (optional_data && optional_data_size > 0)
--		memcpy(pos, optional_data, optional_data_size);
-+		if (optional_data && optional_data_size > 0)
-+			memcpy(pos, optional_data, optional_data_size);
-+	}
- 
- 	return sz;
- }
--- 
-2.12.2
-
diff --git a/SOURCES/0023-efiboot-fix-a-bad-error-check.patch b/SOURCES/0023-efiboot-fix-a-bad-error-check.patch
new file mode 100644
index 0000000..3dc7c75
--- /dev/null
+++ b/SOURCES/0023-efiboot-fix-a-bad-error-check.patch
@@ -0,0 +1,26 @@
+From 6d87113fc3d9b2b0f520fc97eab9f5a60fda7d30 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 13:55:45 -0400
+Subject: [PATCH 23/24] efiboot: fix a bad error check
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0024-efi_generate_file_device_path-make-all-error-paths-u.patch b/SOURCES/0024-efi_generate_file_device_path-make-all-error-paths-u.patch
deleted file mode 100644
index 7c54866..0000000
--- a/SOURCES/0024-efi_generate_file_device_path-make-all-error-paths-u.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 1995ef6d9459931170f5718221104d7eb8c35eba Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Tue, 9 May 2017 16:32:09 -0400
-Subject: [PATCH 24/26] efi_generate_file_device_path(): make all error paths
- use "goto err;"
-
-Honestly I'm just trying to shut coverity up about checking
-child_devpath for NULL-ness twice on the other two error paths.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/creator.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/creator.c b/src/creator.c
-index ccd0faf..21fc6b0 100644
---- a/src/creator.c
-+++ b/src/creator.c
-@@ -339,7 +339,7 @@ efi_generate_file_device_path(uint8_t *buf, ssize_t size,
- 	rc = find_file(filepath, &child_devpath, &relpath);
- 	if (rc < 0) {
- 		efi_error("could not canonicalize fs path");
--		return -1;
-+		goto err;
- 	}
- 
- 	rc = find_parent_devpath(child_devpath, &parent_devpath);
--- 
-2.12.2
-
diff --git a/SOURCES/0024-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch b/SOURCES/0024-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch
new file mode 100644
index 0000000..cece818
--- /dev/null
+++ b/SOURCES/0024-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch
@@ -0,0 +1,27 @@
+From 50e8c66f92b2d93d20c2524936f6858fd2b07afe Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 14:23:40 -0400
+Subject: [PATCH 24/24] efiboot: parse_scsi_link(): fix the offset searching
+ for the port
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0025-Coverity-still-doesn-t-believe-in-error-codes.patch b/SOURCES/0025-Coverity-still-doesn-t-believe-in-error-codes.patch
new file mode 100644
index 0000000..f00817a
--- /dev/null
+++ b/SOURCES/0025-Coverity-still-doesn-t-believe-in-error-codes.patch
@@ -0,0 +1,28 @@
+From c2223eb4638c6d8562626917651a11b8aa1e8f9e Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Thu, 21 Jun 2018 16:18:32 -0400
+Subject: [PATCH] Coverity still doesn't believe in error codes...
+
+So also test fbuf here.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0025-linux.c-fix-a-pile-of-sscanf-NULL-.-possibilities.patch b/SOURCES/0025-linux.c-fix-a-pile-of-sscanf-NULL-.-possibilities.patch
deleted file mode 100644
index c8779eb..0000000
--- a/SOURCES/0025-linux.c-fix-a-pile-of-sscanf-NULL-.-possibilities.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From d8cef3fe75ef8ca3e2622230c81caba06c3476bd Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones@redhat.com>
-Date: Tue, 9 May 2017 16:33:27 -0400
-Subject: [PATCH 25/26] linux.c: fix a pile of sscanf(NULL, ...) possibilities.
-
-Covscan apparently can't figure out that rc!=error == buf!=NULL.
-
-None of these should ever actually happen, because we're checking for
-the error cases from the functions that should fill them in, but hey,
-belt and suspenders.
-
-Signed-off-by: Peter Jones <pjones@redhat.com>
----
- src/linux.c | 12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/src/linux.c b/src/linux.c
-index 85b4ee3..f419ad4 100644
---- a/src/linux.c
-+++ b/src/linux.c
-@@ -297,7 +297,7 @@ sysfs_sata_get_port_info(uint32_t print_id, struct disk_info *info)
- 
- 	rc = read_sysfs_file(&buf, "/sys/class/ata_port/ata%d/port_no",
- 			     print_id);
--	if (rc <= 0)
-+	if (rc <= 0 || buf == NULL)
- 		return -1;
- 
- 	rc = sscanf((char *)buf, "%d", &info->sata_info.ata_port);
-@@ -361,12 +361,12 @@ sysfs_parse_nvme(uint8_t *buf, ssize_t size, ssize_t *off,
- 	rc = read_sysfs_file(&filebuf,
- 			     "/sys/class/block/nvme%dn%d/eui",
- 			     ctrl_id, ns_id);
--	if (rc < 0 && errno == ENOENT) {
-+	if ((rc < 0 && errno == ENOENT) || filebuf == NULL) {
- 		rc = read_sysfs_file(&filebuf,
- 			     "/sys/class/block/nvme%dn%d/device/eui",
- 			     ctrl_id, ns_id);
- 	}
--	if (rc >= 0) {
-+	if (rc >= 0 && filebuf != NULL) {
- 		uint8_t eui[8];
- 		if (rc < 23) {
- 			errno = EINVAL;
-@@ -606,7 +606,7 @@ sysfs_parse_sas(uint8_t *buf, ssize_t size, ssize_t *off,
- 	rc = read_sysfs_file(&filebuf,
- 			     "/sys/class/block/%s/device/sas_address",
- 			     disk_name);
--	if (rc < 0)
-+	if (rc < 0 || filebuf == NULL)
- 		return -1;
- 
- 	rc = sscanf((char *)filebuf, "%"PRIx64, &sas_address);
-@@ -656,7 +656,7 @@ make_pci_path(uint8_t *buf, ssize_t size, char *pathstr, ssize_t *pathoff)
- 	rc = read_sysfs_file(&fbuf,
- 			     "/sys/devices/pci%04x:%02x/firmware_node/hid",
- 			     root_domain, root_bus);
--	if (rc < 0)
-+	if (rc < 0 || fbuf == NULL)
- 		return -1;
- 
- 	uint16_t tmp16 = 0;
-@@ -679,7 +679,7 @@ make_pci_path(uint8_t *buf, ssize_t size, char *pathstr, ssize_t *pathoff)
- 	rc = read_sysfs_file(&fbuf,
- 			     "/sys/devices/pci%4x:%02x/firmware_node/uid",
- 			     root_domain, root_bus);
--	if (rc <= 0 && errno != ENOENT)
-+	if ((rc <= 0 && errno != ENOENT) || fbuf == NULL)
- 		return -1;
- 	if (rc > 0) {
- 		rc = sscanf((char *)fbuf, "%"PRIu64"\n", &acpi_uid_int);
--- 
-2.12.2
-
diff --git a/SOURCES/0026-Don-t-require-NVME-to-have-an-EUI.patch b/SOURCES/0026-Don-t-require-NVME-to-have-an-EUI.patch
new file mode 100644
index 0000000..692295f
--- /dev/null
+++ b/SOURCES/0026-Don-t-require-NVME-to-have-an-EUI.patch
@@ -0,0 +1,28 @@
+From d8d7e54fe01a7a255e649a7734820800edf82633 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Mon, 16 Jul 2018 15:40:22 -0400
+Subject: [PATCH] Don't require NVME to have an EUI
+
+Resolves: rhbz#1593784
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0027-Fix-another-buggy-fake-acpi-pci-root-driver.patch b/SOURCES/0027-Fix-another-buggy-fake-acpi-pci-root-driver.patch
new file mode 100644
index 0000000..87f7430
--- /dev/null
+++ b/SOURCES/0027-Fix-another-buggy-fake-acpi-pci-root-driver.patch
@@ -0,0 +1,64 @@
+From da30e9f2eee235ce11d47bb2e32f976b8c187e5d Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Mon, 10 Sep 2018 15:00:03 -0400
+Subject: [PATCH] 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 <pjones@redhat.com>
+---
+ 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/SOURCES/0028-Fix-dev-probes-intialization-test.patch b/SOURCES/0028-Fix-dev-probes-intialization-test.patch
new file mode 100644
index 0000000..73a16e9
--- /dev/null
+++ b/SOURCES/0028-Fix-dev-probes-intialization-test.patch
@@ -0,0 +1,28 @@
+From e56cf8d480c27bf3ea81af63efb4704896282c6a Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Mon, 17 Sep 2018 16:12:25 -0400
+Subject: [PATCH 28/30] Fix dev->probes intialization test
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0029-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch b/SOURCES/0029-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch
new file mode 100644
index 0000000..4821dd4
--- /dev/null
+++ b/SOURCES/0029-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch
@@ -0,0 +1,92 @@
+From e83002b08aa6db57b90d89968ab8d34f6c7f73cf Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Mon, 17 Sep 2018 16:13:24 -0400
+Subject: [PATCH 29/30] Deal with devices that don't have a ->device link in
+ sysfs
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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/SOURCES/0030-Handle-partition-name-parsing-and-formatting-for-par.patch b/SOURCES/0030-Handle-partition-name-parsing-and-formatting-for-par.patch
new file mode 100644
index 0000000..7bf2603
--- /dev/null
+++ b/SOURCES/0030-Handle-partition-name-parsing-and-formatting-for-par.patch
@@ -0,0 +1,124 @@
+From 576f55b02d9ec478bd5157352c884e3543bcca58 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Mon, 17 Sep 2018 16:52:57 -0400
+Subject: [PATCH 30/30] Handle partition name parsing and formatting for
+ partitioned md.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ 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
++ * <http://www.gnu.org/licenses/>.
++ *
++ */
++
++#include "fix_coverity.h"
++
++#include <errno.h>
++#include <fcntl.h>
++#include <inttypes.h>
++#include <stdint.h>
++#include <unistd.h>
++
++#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/SPECS/efivar.spec b/SPECS/efivar.spec
index 68243f5..d039fdb 100644
--- a/SPECS/efivar.spec
+++ b/SPECS/efivar.spec
@@ -1,39 +1,44 @@
 Name:           efivar
-Version:        31
-Release:        4%{?dist}
+Version:        36
+Release:        11%{?dist}
 Summary:        Tools to manage UEFI variables
-License:        LGPLv2.1
+License:        LGPLv2+
 URL:            https://github.com/rhinstaller/efivar
 Requires:       %{name}-libs = %{version}-%{release}
-ExclusiveArch:	x86_64 aarch64
+ExclusiveArch:  x86_64 aarch64
 
 BuildRequires:  popt popt-devel popt-static git glibc-static
 Source0:        https://github.com/rhinstaller/efivar/releases/download/efivar-%{version}/efivar-%{version}.tar.bz2
-Patch0001:	0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch
-Patch0002:	0002-Don-t-use-_Generic-because-gcc-4.x-doesn-t-have-it.patch
-Patch0003:	0003-popt-devel-in-RHEL-7.4-doesn-t-provide-popt.pc-so-in.patch
-Patch0004:	0004-efi_loadopt_args_from_file-fix-leaked-file-descripto.patch
-Patch0005:	0005-make_mac_path-fix-leaked-file-descriptor.patch
-Patch0006:	0006-gpt_disk_get_partition_info-free-our-allocations-on-.patch
-Patch0007:	0007-efi_generate_file_device_path-fix-one-error-case-s-f.patch
-Patch0008:	0008-efi_va_generate_file_device_path_from_esp-handle-err.patch
-Patch0009:	0009-efi_variable_import-fix-memory-leak-on-failure-path.patch
-Patch0010:	0010-efidp_append_path-error-check-the-right-variable.patch
-Patch0011:	0011-efi_variable_import-make-sure-var.data_size-is-set.patch
-Patch0012:	0012-makeguids-free-our-input-buffer.patch
-Patch0013:	0013-efi_variable_import-constrain-our-inputs-better.patch
-Patch0014:	0014-efi_loadopt_create-check-buf-for-NULLness.patch
-Patch0015:	0015-efidp_duplicate_extra-error-if-our-allocation-is-too.patch
-Patch0016:	0016-show_errors-make-the-useful-part-here-not-be-dead-co.patch
-Patch0017:	0017-efi_loadopt_args_from_file-make-sure-buf-is-only-NUL.patch
-Patch0018:	0018-calls-to-sysfs_readlink-check-linkbuf-for-NULLness.patch
-Patch0019:	0019-efivar-main-explain-efi_well_known_guids-to-the-comp.patch
-Patch0020:	0020-dp.h-Try-to-make-covscan-believe-format-is-checking-.patch
-Patch0021:	0021-gpt-try-to-avoid-trusting-unverified-partition-table.patch
-Patch0022:	0022-Simplify-efidp_append_node-even-more.patch
-Patch0023:	0023-efi_loadopt_create-avoid-NULL-dereference.patch
-Patch0024:	0024-efi_generate_file_device_path-make-all-error-paths-u.patch
-Patch0025:	0025-linux.c-fix-a-pile-of-sscanf-NULL-.-possibilities.patch
+Patch0001: 0001-libabigail-isn-t-in-RHEL-yet-so-nerf-the-abi-check.patch
+Patch0002: 0002-Move-the-syntastic-file-I-use-out-of-the-repo.patch
+Patch0003: 0003-Move-verbosity-headers-to-be-public.patch
+Patch0004: 0004-Pacify-some-coverity-nits.patch
+Patch0005: 0005-efivar-Fix-some-types-in-L-behavior-to-pacify-coveri.patch
+Patch0006: 0006-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch
+Patch0007: 0007-Try-to-convince-covscan-that-sysfs_read_file-doesn-t.patch
+Patch0008: 0008-Make-efidp_make_file-have-even-more-better-input-con.patch
+Patch0009: 0009-Make-path-helpers.c-also-import-fix_coverity.h.patch
+Patch0010: 0010-Fix-a-makeguids-building-problem-with-generics.h.patch
+Patch0011: 0011-Improve-ACPI-device-path-formatting.patch
+Patch0012: 0012-Give-linux-s-parse-functions-the-unmodified-device-l.patch
+Patch0013: 0013-Move-ACPI-ID-parsing-to-a-shared-location.patch
+Patch0014: 0014-Make-a-platform-ACPI-root-parser-separate-from-PCI-r.patch
+Patch0015: 0015-Make-a-way-to-say-e-3-isn-t-viable-for-a-kind-of-dev.patch
+Patch0016: 0016-Make-a-linux-device-root-for-SOC-devices-that-use-FD.patch
+Patch0017: 0017-If-we-can-t-parse-part-of-the-device-link-skip-it-an.patch
+Patch0018: 0018-Pacify-clang-analyzer-just-a-little.patch
+Patch0019: 0019-Try-even-harder-to-convince-coverity-that-get_file-i.patch
+Patch0020: 0020-Make-the-debug-code-less-intrusive.patch
+Patch0021: 0021-efiboot-Make-the-device-node-skipping-code-pass-cove.patch
+Patch0022: 0022-efiboot-don-t-error-on-unknown-type-with-DEV_ABBREV_.patch
+Patch0023: 0023-efiboot-fix-a-bad-error-check.patch
+Patch0024: 0024-efiboot-parse_scsi_link-fix-the-offset-searching-for.patch
+Patch0025: 0025-Coverity-still-doesn-t-believe-in-error-codes.patch
+Patch0026: 0026-Don-t-require-NVME-to-have-an-EUI.patch
+Patch0027: 0027-Fix-another-buggy-fake-acpi-pci-root-driver.patch
+Patch0028: 0028-Fix-dev-probes-intialization-test.patch
+Patch0029: 0029-Deal-with-devices-that-don-t-have-a-device-link-in-s.patch
+Patch0030: 0030-Handle-partition-name-parsing-and-formatting-for-par.patch
 
 %description
 efivar provides a simple command line interface to the UEFI variable facility.
@@ -94,6 +99,63 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/*.so.*
 
 %changelog
+* Mon Sep 17 2018 Peter Jones <pjones@redhat.com> - 36-11
+- Fix device probing with no matching probes where HD() will work
+  Resolves: rhbz#1613698
+- Detect partitiond md devices correctly
+  Resolves: rhbz#1602414
+  Resolves: rhbz#1613370
+
+* Mon Sep 10 2018 Peter Jones <pjones@redhat.com> - 36-10
+- Work around platform ACPI PCI(e) root drivers that don't fill in the
+  "driver" symlink in sysfs.
+  Resolves: rhbz#1614944
+
+* Mon Jul 16 2018 Peter Jones <pjones@redhat.com> - 36-9
+- Don't require NVME to have an EUI
+  Resolves: rhbz#1593784
+
+* Thu Jun 21 2018 Peter Jones <pjones@redhat.com> - 36-8
+- Fix another minor covscan complaint
+  Related: rhbz#1558937
+  Related: rhbz#1591853
+
+* Thu Jun 21 2018 Peter Jones <pjones@redhat.com> - 36-7
+- Fix a couple more weird Aarch64 machines
+  Related: rhbz#1558937
+  Resolves: rhbz#1591853
+
+* Wed Jun 20 2018 Peter Jones <pjones@redhat.com> - 36-6
+- Fix device path generation for block devices on nonstandard device path
+  roots.
+  Related: rhbz#1558937
+  Resolves: rhbz#1591853
+
+* Thu Jun 14 2018 Peter Jones <pjones@redhat.com> - 36-5
+- Try to fix some minor coverity nits.
+  Related: rhbz#1520533
+  Related: rhbz#1570032
+
+* Wed Jun 13 2018 Peter Jones <pjones@redhat.com> - 36-4
+- Try to fix some minor coverity nits.
+  Related: rhbz#1520533
+  Related: rhbz#1570032
+
+* Tue Jun 12 2018 Peter Jones <pjones@redhat.com> - 36-3
+- Try to fix some minor coverity nits.
+  Related: rhbz#1520533
+  Related: rhbz#1570032
+
+* Sat Jun 09 2018 Peter Jones <pjones@redhat.com> - 36-2
+- Minor specfile cleanup to pacify rpmdiff
+  Related: rhbz#1520533
+  Related: rhbz#1570032
+
+* Fri Jun 08 2018 Peter Jones <pjones@redhat.com> - 36-1
+- Rebase to efivar 36
+  Resolves: rhbz#1520533
+  Related: rhbz#1570032
+
 * Tue May 09 2017 Peter Jones <pjones@redhat.com> - 31-4
 - Fix a bunch of coverity issues.
   Related: rhbz#1380825