[systemd-devel] [PATCH] Rename root-fs.target to initrd-root-fs.target, add x-initrd-rootfs.mount

harald at redhat.com harald at redhat.com
Thu Mar 14 05:55:13 PDT 2013


From: Harald Hoyer <harald at redhat.com>

First, rename root-fs.target to initrd-root-fs.target to clarify its usage.

Mount units with "x-initrd-rootfs.mount" are now ordered before
initrd-root-fs.target. As we sometimes construct /sysroot mounts in
/etc/fstab in the initrd, we want these to be mounted before the
initrd-root-fs.target is active.
---
 Makefile.am                                     |  2 +-
 man/systemd.special.xml                         |  4 ++--
 src/core/special.h                              |  2 +-
 src/fstab-generator/fstab-generator.c           | 11 ++++++++++-
 units/initrd-cleanup.service.in                 |  4 ++--
 units/initrd-parse-etc.service.in               |  4 ++--
 units/{root-fs.target => initrd-root-fs.target} |  0
 units/initrd-switch-root.target                 |  4 ++--
 8 files changed, 20 insertions(+), 11 deletions(-)
 rename units/{root-fs.target => initrd-root-fs.target} (100%)

diff --git a/Makefile.am b/Makefile.am
index 175d14b..d92b24a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -348,7 +348,7 @@ dist_systemunit_DATA = \
 	units/local-fs.target \
 	units/local-fs-pre.target \
 	units/initrd-fs.target \
-	units/root-fs.target \
+	units/initrd-root-fs.target \
 	units/remote-fs.target \
 	units/remote-fs-pre.target \
 	units/network.target \
diff --git a/man/systemd.special.xml b/man/systemd.special.xml
index 7b78099..67a81b6 100644
--- a/man/systemd.special.xml
+++ b/man/systemd.special.xml
@@ -79,7 +79,7 @@
                 <filename>remote-fs.target</filename>,
                 <filename>remote-fs-pre.target</filename>,
                 <filename>rescue.target</filename>,
-                <filename>root-fs.target</filename>,
+                <filename>initrd-root-fs.target</filename>,
                 <filename>rpcbind.target</filename>,
                 <filename>runlevel2.target</filename>,
                 <filename>runlevel3.target</filename>,
@@ -523,7 +523,7 @@
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
-                                <term><filename>root-fs.target</filename></term>
+                                <term><filename>initrd-root-fs.target</filename></term>
                                 <listitem>
                                         <para>systemd automatically
                                         adds dependencies of type
diff --git a/src/core/special.h b/src/core/special.h
index 52e593b..c7b856e 100644
--- a/src/core/special.h
+++ b/src/core/special.h
@@ -49,7 +49,7 @@
 #define SPECIAL_LOCAL_FS_TARGET "local-fs.target"
 #define SPECIAL_LOCAL_FS_PRE_TARGET "local-fs-pre.target"
 #define SPECIAL_INITRD_FS_TARGET "initrd-fs.target"
-#define SPECIAL_ROOT_FS_TARGET "root-fs.target"
+#define SPECIAL_INITRD_ROOT_FS_TARGET "initrd-root-fs.target"
 #define SPECIAL_REMOTE_FS_TARGET "remote-fs.target"       /* LSB's $remote_fs */
 #define SPECIAL_REMOTE_FS_PRE_TARGET "remote-fs-pre.target"
 #define SPECIAL_SWAP_TARGET "swap.target"
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index b4fb134..cf85d31 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -199,6 +199,12 @@ static bool mount_in_initrd(struct mntent *me) {
                 streq(me->mnt_dir, "/usr");
 }
 
+static bool mount_is_rootfs(struct mntent *me) {
+        assert(me);
+
+        return hasmntopt(me, "x-initrd-rootfs.mount");
+}
+
 static int add_mount(const char *what, const char *where, const char *type, const char *opts,
                      int passno, bool noauto, bool nofail, bool automount, bool isbind,
                      const char *pre, const char *post, const char *source) {
@@ -434,6 +440,9 @@ static int parse_fstab(const char *prefix, bool initrd) {
                         if (initrd) {
                                 post = SPECIAL_INITRD_FS_TARGET;
                                 pre = NULL;
+                        } else if (mount_is_rootfs(me)) {
+                                post = SPECIAL_INITRD_ROOT_FS_TARGET;
+                                pre = NULL;
                         } else if (mount_is_network(me)) {
                                 post = SPECIAL_REMOTE_FS_TARGET;
                                 pre = SPECIAL_REMOTE_FS_PRE_TARGET;
@@ -525,7 +534,7 @@ static int parse_new_root_from_proc_cmdline(void) {
 
         log_debug("Found entry what=%s where=/sysroot type=%s", what, type);
         r = add_mount(what, "/sysroot", type, opts, 0, false, false, false,
-                      false, NULL, SPECIAL_ROOT_FS_TARGET, "/proc/cmdline");
+                      false, NULL, SPECIAL_INITRD_ROOT_FS_TARGET, "/proc/cmdline");
 
         return (r < 0) ? r : 0;
 }
diff --git a/units/initrd-cleanup.service.in b/units/initrd-cleanup.service.in
index 5bef090..1de6b48 100644
--- a/units/initrd-cleanup.service.in
+++ b/units/initrd-cleanup.service.in
@@ -10,8 +10,8 @@ Description=Cleaning Up and Shutting Down Daemons
 DefaultDependencies=no
 ConditionPathExists=/etc/initrd-release
 OnFailure=emergency.target
-Wants=root-fs.target initrd-fs.target
-After=root-fs.target initrd-fs.target
+Wants=initrd-root-fs.target initrd-fs.target
+After=initrd-root-fs.target initrd-fs.target
 
 [Service]
 Type=oneshot
diff --git a/units/initrd-parse-etc.service.in b/units/initrd-parse-etc.service.in
index 44fee7b..14cbf01 100644
--- a/units/initrd-parse-etc.service.in
+++ b/units/initrd-parse-etc.service.in
@@ -8,8 +8,8 @@
 [Unit]
 Description=Reload Configuration from the Real Root
 DefaultDependencies=no
-Requires=root-fs.target
-After=root-fs.target
+Requires=initrd-root-fs.target
+After=initrd-root-fs.target
 OnFailure=emergency.target
 ConditionPathExists=/etc/initrd-release
 
diff --git a/units/root-fs.target b/units/initrd-root-fs.target
similarity index 100%
rename from units/root-fs.target
rename to units/initrd-root-fs.target
diff --git a/units/initrd-switch-root.target b/units/initrd-switch-root.target
index cf646c4..f347687 100644
--- a/units/initrd-switch-root.target
+++ b/units/initrd-switch-root.target
@@ -12,5 +12,5 @@ DefaultDependencies=no
 Requires=initrd-switch-root.service
 Before=initrd-switch-root.service
 AllowIsolate=yes
-Wants=initrd-udevadm-cleanup-db.service root-fs.target initrd-fs.target systemd-journald.service
-After=initrd-udevadm-cleanup-db.service root-fs.target initrd-fs.target emergency.service emergency.target
+Wants=initrd-udevadm-cleanup-db.service initrd-root-fs.target initrd-fs.target systemd-journald.service
+After=initrd-udevadm-cleanup-db.service initrd-root-fs.target initrd-fs.target emergency.service emergency.target
-- 
1.8.1



More information about the systemd-devel mailing list