dryang / rpms / systemd

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