anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0200-generators-rename-add_-root-usr-_mount-to-add_-sysro.patch

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