chiark / gitweb /
fstab-generator: when running in a container, ignore fstab entries referring to devic...
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Mar 2014 16:57:15 +0000 (17:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Mar 2014 17:02:27 +0000 (18:02 +0100)
Since these device nodes will never appear in the container anyway
there's no point in waiting for them.

This makes it easier to boot images generated with general purpose
installers like Anaconda which unconditionally populate /etc/fstab to
boot in containers.

src/fstab-generator/fstab-generator.c

index 34cd720517d7ea260d1330b0110534dc37fe0aea..a9a5c0203f2cb8276a1486b1d2b809cad0d87efb 100644 (file)
@@ -35,6 +35,7 @@
 #include "fileio.h"
 #include "generator.h"
 #include "strv.h"
+#include "virt.h"
 
 static const char *arg_dest = "/tmp";
 static bool arg_fstab_enabled = true;
@@ -77,6 +78,11 @@ static int add_swap(const char *what, struct mntent *me) {
         assert(what);
         assert(me);
 
+        if (detect_container(NULL) > 0) {
+                log_info("Running in a container, ignoring fstab swap entry for %s.", what);
+                return 0;
+        }
+
         r = mount_find_pri(me, &pri);
         if (r < 0) {
                 log_error("Failed to parse priority");
@@ -341,6 +347,11 @@ static int parse_fstab(bool initrd) {
                 if (!what)
                         return log_oom();
 
+                if (detect_container(NULL) > 0 && is_device_path(what)) {
+                        log_info("Running in a container, ignoring fstab device entry for %s.", what);
+                        continue;
+                }
+
                 where = initrd ? strappend("/sysroot/", me->mnt_dir) : strdup(me->mnt_dir);
                 if (!where)
                         return log_oom();