valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0222-fsck-root-only-run-when-requested-in-fstab.patch

9fc0f6
From 8610788332cb6492d8e5275b32200db4138401bb Mon Sep 17 00:00:00 2001
9fc0f6
From: Tom Gundersen <teg@jklm.no>
9fc0f6
Date: Sat, 19 Oct 2013 11:38:42 +0200
9fc0f6
Subject: [PATCH] fsck-root: only run when requested in fstab
9fc0f6
9fc0f6
fsck-root is redundant in case an initrd is used, or in case the rootfs
9fc0f6
is never remounted 'rw', so the new default is the correct behavior for
9fc0f6
most users. For the rest, they should enable it in fstab.
9fc0f6
---
9fc0f6
 Makefile.am                           |  1 -
9fc0f6
 man/systemd-fsck@.service.xml         |  4 +++-
9fc0f6
 src/fstab-generator/fstab-generator.c | 31 ++++++++++++++++++++++---------
9fc0f6
 3 files changed, 25 insertions(+), 11 deletions(-)
9fc0f6
9fc0f6
diff --git a/Makefile.am b/Makefile.am
9fc0f6
index df63275..fa2fba6 100644
9fc0f6
--- a/Makefile.am
9fc0f6
+++ b/Makefile.am
9fc0f6
@@ -4415,7 +4415,6 @@ SYSINIT_TARGET_WANTS += \
9fc0f6
 	systemd-update-utmp.service
9fc0f6
 LOCAL_FS_TARGET_WANTS += \
9fc0f6
 	systemd-remount-fs.service \
9fc0f6
-	systemd-fsck-root.service \
9fc0f6
 	tmp.mount
9fc0f6
 MULTI_USER_TARGET_WANTS += \
9fc0f6
 	getty.target \
9fc0f6
diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml
9fc0f6
index 17bd1c0..811392b 100644
9fc0f6
--- a/man/systemd-fsck@.service.xml
9fc0f6
+++ b/man/systemd-fsck@.service.xml
9fc0f6
@@ -63,7 +63,9 @@
9fc0f6
                 check. <filename>systemd-fsck-root.service</filename> is
9fc0f6
                 responsible for file system checks on the root
9fc0f6
                 file system. The root file system check is performed
9fc0f6
-                before the other file systems.</para>
9fc0f6
+                before the other file systems. Either service is enabled
9fc0f6
+                at boot if passno in <filename>/etc/fstab</filename> for
9fc0f6
+                the filesystem is set to a value greater than zero.</para>
9fc0f6
 
9fc0f6
                 <para><filename>systemd-fsck</filename> will
9fc0f6
                 forward file system checking progress to the
9fc0f6
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
9fc0f6
index 7874ff1..c0c2992 100644
9fc0f6
--- a/src/fstab-generator/fstab-generator.c
9fc0f6
+++ b/src/fstab-generator/fstab-generator.c
9fc0f6
@@ -210,17 +210,29 @@ static int add_mount(
9fc0f6
                         post);
9fc0f6
 
9fc0f6
         if (passno > 0) {
9fc0f6
-                _cleanup_free_ char *fsck = NULL;
9fc0f6
+                if (streq(where, "/")) {
9fc0f6
+                        lnk = strjoin(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET, ".wants/", "systemd-fsck-root.service", NULL);
9fc0f6
+                        if (!lnk)
9fc0f6
+                                return log_oom();
9fc0f6
 
9fc0f6
-                fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
9fc0f6
-                if (!fsck)
9fc0f6
-                        return log_oom();
9fc0f6
+                        mkdir_parents_label(lnk, 0755);
9fc0f6
+                        if (symlink("systemd-fsck-root.service", lnk) < 0) {
9fc0f6
+                                log_error("Failed to create symlink %s: %m", lnk);
9fc0f6
+                                return -errno;
9fc0f6
+                        }
9fc0f6
+                } else {
9fc0f6
+                        _cleanup_free_ char *fsck = NULL;
9fc0f6
 
9fc0f6
-                fprintf(f,
9fc0f6
-                        "Requires=%s\n"
9fc0f6
-                        "After=%s\n",
9fc0f6
-                        fsck,
9fc0f6
-                        fsck);
9fc0f6
+                        fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
9fc0f6
+                        if (!fsck)
9fc0f6
+                                return log_oom();
9fc0f6
+
9fc0f6
+                        fprintf(f,
9fc0f6
+                                "Requires=%s\n"
9fc0f6
+                                "After=%s\n",
9fc0f6
+                                fsck,
9fc0f6
+                                fsck);
9fc0f6
+                }
9fc0f6
         }
9fc0f6
 
9fc0f6
 
9fc0f6
@@ -248,6 +260,7 @@ static int add_mount(
9fc0f6
 
9fc0f6
         if (!noauto) {
9fc0f6
                 if (post) {
9fc0f6
+                        free(lnk);
9fc0f6
                         lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
9fc0f6
                         if (!lnk)
9fc0f6
                                 return log_oom();