naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
923a60
From 3282d24f8f9f7561312779710f250396f2ecc29b Mon Sep 17 00:00:00 2001
923a60
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
923a60
Date: Sat, 2 May 2015 12:01:29 -0500
923a60
Subject: [PATCH] generators: rename add_{root,usr}_mount to
923a60
 add_{sysroot,sysroot_usr}_mount
923a60
923a60
This makes it obvious that those functions are only usable in the
923a60
initramfs.
923a60
923a60
Also, add a warning when noauto, nofail, or automount is used for the
923a60
root fs, instead of silently ignoring. Using those options would be a
923a60
sign of significant misconfiguration, and if we bother to check for
923a60
them, than let's go all the way and complain.
923a60
923a60
Other various small cleanups and reformattings elsewhere.
923a60
923a60
(cherry picked from commit 2e8522767e27d5686206794c69e0aa95da6e798b)
923a60
923a60
Cherry-picked from: 2e85227
923a60
Resolves: #1222517
923a60
---
923a60
 src/fstab-generator/fstab-generator.c | 20 ++++++++++++--------
923a60
 src/shared/generator.c                | 21 ++++++++++++---------
923a60
 src/shared/generator.h                | 17 +++++++++++++----
923a60
 3 files changed, 37 insertions(+), 21 deletions(-)
923a60
923a60
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
923a60
index 65ed205799..029eb16380 100644
923a60
--- a/src/fstab-generator/fstab-generator.c
923a60
+++ b/src/fstab-generator/fstab-generator.c
923a60
@@ -250,10 +250,14 @@ static int add_mount(
923a60
                 return 0;
923a60
 
923a60
         if (path_equal(where, "/")) {
923a60
-                /* The root disk is not an option */
923a60
-                automount = false;
923a60
-                noauto = false;
923a60
-                nofail = false;
923a60
+                if (noauto)
923a60
+                        log_warning("Ignoring \"noauto\" for root device");
923a60
+                if (nofail)
923a60
+                        log_warning("Ignoring \"nofail\" for root device");
923a60
+                if (automount)
923a60
+                        log_warning("Ignoring automount option for root device");
923a60
+
923a60
+                noauto = nofail = automount = false;
923a60
         }
923a60
 
923a60
         name = unit_name_from_path(where, ".mount");
923a60
@@ -470,7 +474,7 @@ static int parse_fstab(bool initrd) {
923a60
         return r;
923a60
 }
923a60
 
923a60
-static int add_root_mount(void) {
923a60
+static int add_sysroot_mount(void) {
923a60
         _cleanup_free_ char *what = NULL;
923a60
         const char *opts;
923a60
 
923a60
@@ -506,7 +510,7 @@ static int add_root_mount(void) {
923a60
                          "/proc/cmdline");
923a60
 }
923a60
 
923a60
-static int add_usr_mount(void) {
923a60
+static int add_sysroot_usr_mount(void) {
923a60
         _cleanup_free_ char *what = NULL;
923a60
         const char *opts;
923a60
 
923a60
@@ -653,9 +657,9 @@ int main(int argc, char *argv[]) {
923a60
 
923a60
         /* Always honour root= and usr= in the kernel command line if we are in an initrd */
923a60
         if (in_initrd()) {
923a60
-                r = add_root_mount();
923a60
+                r = add_sysroot_mount();
923a60
                 if (r == 0)
923a60
-                        r = add_usr_mount();
923a60
+                        r = add_sysroot_usr_mount();
923a60
         }
923a60
 
923a60
         /* Honour /etc/fstab only when that's enabled */
923a60
diff --git a/src/shared/generator.c b/src/shared/generator.c
923a60
index 7f16d5cbef..cd37812f86 100644
923a60
--- a/src/shared/generator.c
923a60
+++ b/src/shared/generator.c
923a60
@@ -33,13 +33,13 @@
923a60
 
923a60
 int generator_write_fsck_deps(
923a60
                 FILE *f,
923a60
-                const char *dest,
923a60
+                const char *dir,
923a60
                 const char *what,
923a60
                 const char *where,
923a60
                 const char *fstype) {
923a60
 
923a60
         assert(f);
923a60
-        assert(dest);
923a60
+        assert(dir);
923a60
         assert(what);
923a60
         assert(where);
923a60
 
923a60
@@ -59,10 +59,10 @@ int generator_write_fsck_deps(
923a60
                         return log_warning_errno(r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype);
923a60
         }
923a60
 
923a60
-        if (streq(where, "/")) {
923a60
+        if (path_equal(where, "/")) {
923a60
                 char *lnk;
923a60
 
923a60
-                lnk = strjoina(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
923a60
+                lnk = strjoina(dir, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
923a60
 
923a60
                 mkdir_parents(lnk, 0755);
923a60
                 if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0)
923a60
@@ -76,17 +76,20 @@ int generator_write_fsck_deps(
923a60
                         return log_oom();
923a60
 
923a60
                 fprintf(f,
923a60
-                        "RequiresOverridable=%s\n"
923a60
-                        "After=%s\n",
923a60
-                        fsck,
923a60
+                        "RequiresOverridable=%1$s\n"
923a60
+                        "After=%1$s\n",
923a60
                         fsck);
923a60
         }
923a60
 
923a60
         return 0;
923a60
 }
923a60
 
923a60
-int generator_write_timeouts(const char *dir, const char *what, const char *where,
923a60
-                             const char *opts, char **filtered) {
923a60
+int generator_write_timeouts(
923a60
+                const char *dir,
923a60
+                const char *what,
923a60
+                const char *where,
923a60
+                const char *opts,
923a60
+                char **filtered) {
923a60
 
923a60
         /* Allow configuration how long we wait for a device that
923a60
          * backs a mount point to show up. This is useful to support
923a60
diff --git a/src/shared/generator.h b/src/shared/generator.h
923a60
index 64bd28f596..6c3f38abba 100644
923a60
--- a/src/shared/generator.h
923a60
+++ b/src/shared/generator.h
923a60
@@ -23,7 +23,16 @@
923a60
 
923a60
 #include <stdio.h>
923a60
 
923a60
-int generator_write_fsck_deps(FILE *f, const char *dest, const char *what, const char *where, const char *type);
923a60
-
923a60
-int generator_write_timeouts(const char *dir, const char *what, const char *where,
923a60
-                             const char *opts, char **filtered);
923a60
+int generator_write_fsck_deps(
923a60
+        FILE *f,
923a60
+        const char *dir,
923a60
+        const char *what,
923a60
+        const char *where,
923a60
+        const char *type);
923a60
+
923a60
+int generator_write_timeouts(
923a60
+        const char *dir,
923a60
+        const char *what,
923a60
+        const char *where,
923a60
+        const char *opts,
923a60
+        char **filtered);