]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto-generator: check fstab for /boot entries 1425/head
authorKay Sievers <kay@vrfy.org>
Wed, 30 Sep 2015 20:24:52 +0000 (22:24 +0200)
committerKay Sievers <kay@vrfy.org>
Wed, 30 Sep 2015 20:24:52 +0000 (22:24 +0200)
We need to prevent the creation of the gpt automount unit, which will not
get overridden by the fstab mount unit.

https://github.com/systemd/systemd/issues/1378

src/gpt-auto-generator/gpt-auto-generator.c
src/shared/fstab-util.c
src/shared/fstab-util.h

index bb821797f1c28aebfe1474927b2cedb058b69ef8..dbb6648daac2e989d0f54e2f370b959890bb110a 100644 (file)
@@ -38,6 +38,7 @@
 #include "gpt.h"
 #include "fileio.h"
 #include "efivars.h"
+#include "fstab-util.h"
 #include "blkid-util.h"
 #include "btrfs-util.h"
 
@@ -465,6 +466,12 @@ static int add_boot(const char *what) {
                 return 0;
         }
 
+        /* We create an .automount which is not overridden by the .mount from the fstab generator. */
+        if (fstab_is_mount_point("/boot")) {
+                log_debug("/boot specified in fstab, ignoring.");
+                return 0;
+        }
+
         if (path_is_busy("/boot")) {
                 log_debug("/boot already populated, ignoring.");
                 return 0;
index e231a0ff80bdb2b6096f34e3711139b76ebe323e..db2146f8c112c52f844ad669e8d8dab05034cfab 100644 (file)
 ***/
 
 #include "fstab-util.h"
+#include "path-util.h"
 #include "strv.h"
 #include "util.h"
 
+bool fstab_is_mount_point(const char *mount) {
+        _cleanup_free_ char *device = NULL;
+        _cleanup_endmntent_ FILE *f = NULL;
+        struct mntent *m;
+
+        f = setmntent("/etc/fstab", "r");
+        if (!f)
+                return false;
+
+        while ((m = getmntent(f)))
+                if (path_equal(m->mnt_dir, mount))
+                        return true;
+
+        return false;
+}
+
 int fstab_filter_options(const char *opts, const char *names,
                          const char **namefound, char **value, char **filtered) {
         const char *name, *n = NULL, *x;
index 387c562a9630b63ad2109b09f6a7026c1fbdc8e0..872b2363cd500ea36812c5ee6d64886b6910aaff 100644 (file)
@@ -25,6 +25,7 @@
 #include <stddef.h>
 #include "macro.h"
 
+bool fstab_is_mount_point(const char *mount);
 int fstab_filter_options(const char *opts, const char *names,
                          const char **namefound, char **value, char **filtered);