[systemd-devel] [PATCH] efi-boot-generator: Continue if /boot does not exist

Tobias Hunger tobias.hunger at gmail.com
Wed Apr 1 13:53:50 PDT 2015


/boot does not exist on a stateless system, so do not get
confused by that.
---
 src/efi-boot-generator/efi-boot-generator.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/efi-boot-generator/efi-boot-generator.c b/src/efi-boot-generator/efi-boot-generator.c
index 58c4cc2..938bbe2 100644
--- a/src/efi-boot-generator/efi-boot-generator.c
+++ b/src/efi-boot-generator/efi-boot-generator.c
@@ -35,6 +35,7 @@ static const char *arg_dest = "/tmp";
 int main(int argc, char *argv[]) {
         _cleanup_free_ char *what = NULL;
         _cleanup_fclose_ FILE *f = NULL;
+        struct stat boot_stat;
         int r = EXIT_SUCCESS;
         sd_id128_t id;
         char *name;
@@ -68,10 +69,24 @@ int main(int argc, char *argv[]) {
                 return EXIT_SUCCESS;
         }
 
-        if (path_is_mount_point("/boot", true) <= 0 &&
-            dir_is_empty("/boot") <= 0) {
-                log_debug("/boot already populated, exiting.");
-                return EXIT_SUCCESS;
+        r = stat("/boot", &boot_stat);
+        if (r < 0) {
+                if (errno == ENOENT)
+                        log_debug("/boot does not exist, continuing.");
+                else {
+                        log_debug("Failed to stat /boot, exiting.");
+                        return EXIT_FAILURE;
+                }
+        } else {
+                if (!S_ISDIR(boot_stat.st_mode) && !S_ISLNK(boot_stat.st_mode)) {
+                        log_debug("/boot is not a directory or link, exiting.");
+                        return EXIT_FAILURE;
+                }
+                if (path_is_mount_point("/boot", true) <= 0 &&
+                    dir_is_empty("/boot") <= 0) {
+                        log_debug("/boot already populated, exiting.");
+                        return EXIT_SUCCESS;
+                }
         }
 
         r = efi_loader_get_device_part_uuid(&id);
-- 
2.3.3



More information about the systemd-devel mailing list