diff --git a/SOURCES/0031-Fix-partition-number-detection-when-it-s-not-provide.patch b/SOURCES/0031-Fix-partition-number-detection-when-it-s-not-provide.patch new file mode 100644 index 0000000..a98d0eb --- /dev/null +++ b/SOURCES/0031-Fix-partition-number-detection-when-it-s-not-provide.patch @@ -0,0 +1,79 @@ +From cff35642eac6699e30549db2db3341e7657bf4a6 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 18 Sep 2018 14:57:13 -0400 +Subject: [PATCH] Fix partition number detection when it's not provided. + +We need to actually get the partition number from the child device when +we're called without it. + +Resolves: rhbz#1616305 + +Signed-off-by: Peter Jones +--- + src/creator.c | 43 +++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + +diff --git a/src/creator.c b/src/creator.c +index ef782e2b6475..987fa033e5b7 100644 +--- a/src/creator.c ++++ b/src/creator.c +@@ -350,6 +350,36 @@ efi_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size, + return ret; + } + ++static int ++get_part(char *devpath) ++{ ++ int fd; ++ int partition = -1; ++ struct device *dev = NULL; ++ ++ fd = open(devpath, O_RDONLY); ++ if (fd < 0) { ++ efi_error("could not open device for ESP"); ++ goto err; ++ } ++ ++ dev = device_get(fd, -1); ++ if (dev == NULL) { ++ efi_error("could not get ESP disk info"); ++ goto err; ++ } ++ ++ partition = dev->part; ++ if (partition < 0) ++ partition = 0; ++err: ++ if (dev) ++ device_free(dev); ++ if (fd >= 0) ++ close(fd); ++ return partition; ++} ++ + ssize_t NONNULL(3) PUBLIC + efi_generate_file_device_path(uint8_t *buf, ssize_t size, + const char * const filepath, +@@ -374,6 +404,19 @@ efi_generate_file_device_path(uint8_t *buf, ssize_t size, + efi_error("could not find parent device for file"); + goto err; + } ++ debug("child_devpath:%s", child_devpath); ++ ++ debug("parent_devpath:%s", parent_devpath); ++ debug("child_devpath:%s", child_devpath); ++ debug("rc:%d", rc); ++ ++ rc = get_part(child_devpath); ++ if (rc < 0) { ++ efi_error("Couldn't get partition number for %s", ++ child_devpath); ++ goto err; ++ } ++ debug("detected partition:%d", rc); + + va_start(ap, options); + +-- +2.19.1 + diff --git a/SPECS/efivar.spec b/SPECS/efivar.spec index d039fdb..28591d3 100644 --- a/SPECS/efivar.spec +++ b/SPECS/efivar.spec @@ -1,6 +1,6 @@ Name: efivar Version: 36 -Release: 11%{?dist} +Release: 11%{?dist}.1 Summary: Tools to manage UEFI variables License: LGPLv2+ URL: https://github.com/rhinstaller/efivar @@ -39,6 +39,7 @@ 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 +Patch0031: 0031-Fix-partition-number-detection-when-it-s-not-provide.patch %description efivar provides a simple command line interface to the UEFI variable facility. @@ -99,6 +100,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/*.so.* %changelog +* Tue Nov 13 2018 Javier Martinez Canillas - 36-11.el7_6.1 +- Fix partition number detection when it's not provided (pjones) + Resolves: rhbz#1649712 + * Mon Sep 17 2018 Peter Jones - 36-11 - Fix device probing with no matching probes where HD() will work Resolves: rhbz#1613698