valeriyvdovin / rpms / systemd

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