[systemd-devel] [PATCH] fstab-generator: Do less sanity checking

Tobias Hunger tobias.hunger at gmail.com
Tue Mar 24 16:05:38 PDT 2015


Mount whatever the user asked to be mounted on / and /usr on the
kernel command line. Do less sanity check and do *not* bail out
when the mount device looks strange or does not exist.

This basically makes the changes for deviceless filesystems
from yesterday unnecessary and is in line with what we do for
filesystems set up in fstab.

Remove some code that is now dead.
---
 src/fstab-generator/fstab-generator.c | 34 +++++++++++++++-------------------
 src/shared/generator.c                |  5 -----
 src/shared/util.c                     | 29 -----------------------------
 src/shared/util.h                     |  1 -
 4 files changed, 15 insertions(+), 54 deletions(-)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 77c97fd..5bd800e 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -397,20 +397,18 @@ static int add_root_mount(void) {
         _cleanup_free_ char *what = NULL;
         const char *opts;
 
-        if (fstype_is_deviceless(arg_root_fstype)) {
-                if (free_and_strdup(&what, arg_root_what) < 0)
-                        return log_oom();
-        } else {
-                if (isempty(arg_root_what)) {
-                        log_debug("Could not find a root= entry on the kernel command line.");
-                        return 0;
-                }
+        if (isempty(arg_root_what)) {
+                log_debug("Could not find a root= entry on the kernel command line.");
+                return 0;
+        }
 
-                what = fstab_node_to_udev_node(arg_root_what);
-                if (!path_is_absolute(what)) {
-                        log_debug("Skipping entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
-                        return 0;
-                }
+        what = fstab_node_to_udev_node(arg_root_what);
+        if (!what)
+                log_oom();
+
+        if (is_device_path(what) && path_is_read_only_fs("sys") > 0) {
+                log_info("Running in a container, ignoring kernel command line configuration for %s.", what);
+                return 0;
         }
 
         if (!arg_root_options)
@@ -426,7 +424,7 @@ static int add_root_mount(void) {
                          "/sysroot",
                          arg_root_fstype,
                          opts,
-                         1,
+                         is_device_path(what) ? 1 : 0,
                          false,
                          false,
                          false,
@@ -466,10 +464,8 @@ static int add_usr_mount(void) {
                 return 0;
 
         what = fstab_node_to_udev_node(arg_usr_what);
-        if (!path_is_absolute(what)) {
-                log_debug("Skipping entry what=%s where=/sysroot/usr type=%s", what, strna(arg_usr_fstype));
-                return -1;
-        }
+        if (!what)
+                log_oom();
 
         if (!arg_usr_options)
                 opts = arg_root_rw > 0 ? "rw" : "ro";
@@ -483,7 +479,7 @@ static int add_usr_mount(void) {
                          "/sysroot/usr",
                          arg_usr_fstype,
                          opts,
-                         1,
+                         is_device_path(what) ? 1 : 0,
                          false,
                          false,
                          false,
diff --git a/src/shared/generator.c b/src/shared/generator.c
index c348ca2..569b25b 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -42,11 +42,6 @@ int generator_write_fsck_deps(
         assert(what);
         assert(where);
 
-        if (fstype_is_deviceless(fstype)) {
-                log_debug("Not checking deviceless filesystem \"%s\".", fstype);
-                return 0;
-        }
-
         if (!is_device_path(what)) {
                 log_warning("Checking was requested for \"%s\", but it is not a device.", what);
                 return 0;
diff --git a/src/shared/util.c b/src/shared/util.c
index 2d50f73..ad548da 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1713,35 +1713,6 @@ bool fstype_is_network(const char *fstype) {
         return nulstr_contains(table, fstype);
 }
 
-bool fstype_is_deviceless(const char *fstype) {
-        static const char table[] =
-                "autofs\0"
-                "bdev\0"
-                "cgroup\0"
-                "configfs\0"
-                "cpuset\0"
-                "debugfs\0"
-                "devpts\0"
-                "devtmpfs\0"
-                "efivarfs\0"
-                "hugetlbfs\0"
-                "mqueue\0"
-                "overlayfs\0"
-                "pipefs\0"
-                "proc\0"
-                "pstore\0"
-                "ramfs\0"
-                "rootfs\0"
-                "rpc_pipefs\0"
-                "securityfs\0"
-                "sockfs\0"
-                "sysfs\0"
-                "tmpfs\0";
-
-        return !isempty(fstype) && (
-                nulstr_contains(table, fstype) || fstype_is_network(fstype));
-}
-
 int chvt(int vt) {
         _cleanup_close_ int fd;
 
diff --git a/src/shared/util.h b/src/shared/util.h
index b5f44b8..29e85bb 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -409,7 +409,6 @@ int fd_cloexec(int fd, bool cloexec);
 int close_all_fds(const int except[], unsigned n_except);
 
 bool fstype_is_network(const char *fstype);
-bool fstype_is_deviceless(const char *fstype);
 
 int chvt(int vt);
 
-- 
2.3.3



More information about the systemd-devel mailing list