daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
9fc0f6
From 8a9eab141ab379c658fc198fb0b0ee4ca3bdd1d2 Mon Sep 17 00:00:00 2001
9fc0f6
From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
9fc0f6
Date: Mon, 30 Sep 2013 01:34:44 +0200
9fc0f6
Subject: [PATCH] fstab-generator: Generate explicit dependencies on
9fc0f6
 systemd-fsck@.service instead of using FsckPassNo
9fc0f6
9fc0f6
[tomegun:
9fc0f6
  * order all fsck instances after fsck-root
9fc0f6
  * check for OOM
9fc0f6
  * added notes in the manpages]
9fc0f6
9fc0f6
Conflicts:
9fc0f6
	man/systemd-fsck@.service.xml
9fc0f6
	man/systemd-fstab-generator.xml
9fc0f6
---
9fc0f6
 man/systemd-fsck@.service.xml         |  4 +---
9fc0f6
 man/systemd-fstab-generator.xml       |  9 ++++-----
9fc0f6
 src/fstab-generator/fstab-generator.c | 21 +++++++++++++++++----
9fc0f6
 units/systemd-fsck@.service.in        |  2 +-
9fc0f6
 4 files changed, 23 insertions(+), 13 deletions(-)
9fc0f6
9fc0f6
diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml
9fc0f6
index c653dc5..17bd1c0 100644
9fc0f6
--- a/man/systemd-fsck@.service.xml
9fc0f6
+++ b/man/systemd-fsck@.service.xml
9fc0f6
@@ -63,9 +63,7 @@
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. Either service is enabled
9fc0f6
-                at boot if passno in <filename>/etc/fstab</filename> for
9fc0f6
-                the file system is set to a value greater than zero.</para>
9fc0f6
+                before the other file systems.</para>
9fc0f6
 
9fc0f6
                 <para><filename>systemd-fsck</filename> will
9fc0f6
                 forward file system checking progress to the
9fc0f6
diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml
9fc0f6
index e3cf5d2..740db8f 100644
9fc0f6
--- a/man/systemd-fstab-generator.xml
9fc0f6
+++ b/man/systemd-fstab-generator.xml
9fc0f6
@@ -61,11 +61,10 @@
9fc0f6
                 reloaded. This will instantiate mount and swap units
9fc0f6
                 as necessary.</para>
9fc0f6
 
9fc0f6
-                <para>The <varname>passno</varname> field is treated
9fc0f6
-                like a simple boolean, and the ordering information is
9fc0f6
-                discarded. However, if the root file system is
9fc0f6
-                checked, it is checked before all the other
9fc0f6
-                file systems.</para>
9fc0f6
+                <para>The <term><varname>passno</varname></term> field
9fc0f6
+                is treated like a simlpe boolean, and the ordering information
9fc0f6
+                is discarded. However, the root filesystem is checked
9fc0f6
+                before all the other filesystems.</para>
9fc0f6
 
9fc0f6
                 <para>See
9fc0f6
                 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
9fc0f6
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
9fc0f6
index 6cecb4e..7874ff1 100644
9fc0f6
--- a/src/fstab-generator/fstab-generator.c
9fc0f6
+++ b/src/fstab-generator/fstab-generator.c
9fc0f6
@@ -209,17 +209,30 @@ static int add_mount(
9fc0f6
                         "Before=%s\n",
9fc0f6
                         post);
9fc0f6
 
9fc0f6
+        if (passno > 0) {
9fc0f6
+                _cleanup_free_ char *fsck = NULL;
9fc0f6
+
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
         fprintf(f,
9fc0f6
                 "\n"
9fc0f6
                 "[Mount]\n"
9fc0f6
                 "What=%s\n"
9fc0f6
                 "Where=%s\n"
9fc0f6
-                "Type=%s\n"
9fc0f6
-                "FsckPassNo=%i\n",
9fc0f6
+                "Type=%s\n",
9fc0f6
                 what,
9fc0f6
                 where,
9fc0f6
-                type,
9fc0f6
-                passno);
9fc0f6
+                type);
9fc0f6
 
9fc0f6
         if (!isempty(opts) &&
9fc0f6
             !streq(opts, "defaults"))
9fc0f6
diff --git a/units/systemd-fsck@.service.in b/units/systemd-fsck@.service.in
9fc0f6
index e229cdc..c12efa8 100644
9fc0f6
--- a/units/systemd-fsck@.service.in
9fc0f6
+++ b/units/systemd-fsck@.service.in
9fc0f6
@@ -10,7 +10,7 @@ Description=File System Check on %f
9fc0f6
 Documentation=man:systemd-fsck@.service(8)
9fc0f6
 DefaultDependencies=no
9fc0f6
 BindsTo=%i.device
9fc0f6
-After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device
9fc0f6
+After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device systemd-fsck-root.service
9fc0f6
 Before=shutdown.target
9fc0f6
 
9fc0f6
 [Service]