|
|
821f82 |
From cff35642eac6699e30549db2db3341e7657bf4a6 Mon Sep 17 00:00:00 2001
|
|
|
821f82 |
From: Peter Jones <pjones@redhat.com>
|
|
|
821f82 |
Date: Tue, 18 Sep 2018 14:57:13 -0400
|
|
|
821f82 |
Subject: [PATCH] Fix partition number detection when it's not provided.
|
|
|
821f82 |
|
|
|
821f82 |
We need to actually get the partition number from the child device when
|
|
|
821f82 |
we're called without it.
|
|
|
821f82 |
|
|
|
821f82 |
Resolves: rhbz#1616305
|
|
|
821f82 |
|
|
|
821f82 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
821f82 |
---
|
|
|
821f82 |
src/creator.c | 43 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
821f82 |
1 file changed, 43 insertions(+)
|
|
|
821f82 |
|
|
|
821f82 |
diff --git a/src/creator.c b/src/creator.c
|
|
|
821f82 |
index ef782e2b6475..987fa033e5b7 100644
|
|
|
821f82 |
--- a/src/creator.c
|
|
|
821f82 |
+++ b/src/creator.c
|
|
|
821f82 |
@@ -350,6 +350,36 @@ efi_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
|
|
|
821f82 |
return ret;
|
|
|
821f82 |
}
|
|
|
821f82 |
|
|
|
821f82 |
+static int
|
|
|
821f82 |
+get_part(char *devpath)
|
|
|
821f82 |
+{
|
|
|
821f82 |
+ int fd;
|
|
|
821f82 |
+ int partition = -1;
|
|
|
821f82 |
+ struct device *dev = NULL;
|
|
|
821f82 |
+
|
|
|
821f82 |
+ fd = open(devpath, O_RDONLY);
|
|
|
821f82 |
+ if (fd < 0) {
|
|
|
821f82 |
+ efi_error("could not open device for ESP");
|
|
|
821f82 |
+ goto err;
|
|
|
821f82 |
+ }
|
|
|
821f82 |
+
|
|
|
821f82 |
+ dev = device_get(fd, -1);
|
|
|
821f82 |
+ if (dev == NULL) {
|
|
|
821f82 |
+ efi_error("could not get ESP disk info");
|
|
|
821f82 |
+ goto err;
|
|
|
821f82 |
+ }
|
|
|
821f82 |
+
|
|
|
821f82 |
+ partition = dev->part;
|
|
|
821f82 |
+ if (partition < 0)
|
|
|
821f82 |
+ partition = 0;
|
|
|
821f82 |
+err:
|
|
|
821f82 |
+ if (dev)
|
|
|
821f82 |
+ device_free(dev);
|
|
|
821f82 |
+ if (fd >= 0)
|
|
|
821f82 |
+ close(fd);
|
|
|
821f82 |
+ return partition;
|
|
|
821f82 |
+}
|
|
|
821f82 |
+
|
|
|
821f82 |
ssize_t NONNULL(3) PUBLIC
|
|
|
821f82 |
efi_generate_file_device_path(uint8_t *buf, ssize_t size,
|
|
|
821f82 |
const char * const filepath,
|
|
|
821f82 |
@@ -374,6 +404,19 @@ efi_generate_file_device_path(uint8_t *buf, ssize_t size,
|
|
|
821f82 |
efi_error("could not find parent device for file");
|
|
|
821f82 |
goto err;
|
|
|
821f82 |
}
|
|
|
821f82 |
+ debug("child_devpath:%s", child_devpath);
|
|
|
821f82 |
+
|
|
|
821f82 |
+ debug("parent_devpath:%s", parent_devpath);
|
|
|
821f82 |
+ debug("child_devpath:%s", child_devpath);
|
|
|
821f82 |
+ debug("rc:%d", rc);
|
|
|
821f82 |
+
|
|
|
821f82 |
+ rc = get_part(child_devpath);
|
|
|
821f82 |
+ if (rc < 0) {
|
|
|
821f82 |
+ efi_error("Couldn't get partition number for %s",
|
|
|
821f82 |
+ child_devpath);
|
|
|
821f82 |
+ goto err;
|
|
|
821f82 |
+ }
|
|
|
821f82 |
+ debug("detected partition:%d", rc);
|
|
|
821f82 |
|
|
|
821f82 |
va_start(ap, options);
|
|
|
821f82 |
|
|
|
821f82 |
--
|
|
|
821f82 |
2.19.1
|
|
|
821f82 |
|