chiark / gitweb /
mount: add automatic start ordering dependencies for mounts
authorLennart Poettering <lennart@poettering.net>
Mon, 12 Jul 2010 20:55:27 +0000 (22:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Jul 2010 20:55:27 +0000 (22:55 +0200)
13 files changed:
src/automount.c
src/mount.c
src/swap.c
units/dev-hugepages.automount
units/dev-hugepages.mount
units/dev-mqueue.automount
units/dev-mqueue.mount
units/proc-sys-fs-binfmt_misc.automount
units/proc-sys-fs-binfmt_misc.mount
units/sys-kernel-debug.automount
units/sys-kernel-debug.mount
units/sys-kernel-security.automount
units/sys-kernel-security.mount

index 934aa5f35d78dc83716a56433d0ff3d4e8e28838..00f3736b2fc148c9eb5bf0bb223eca8073177dd3 100644 (file)
@@ -146,6 +146,23 @@ static int automount_add_mount_links(Automount *a) {
         return 0;
 }
 
         return 0;
 }
 
+static int automount_add_default_dependencies(Automount *a) {
+        int r;
+
+        assert(a);
+
+        if (a->meta.manager->running_as == MANAGER_SYSTEM) {
+
+                if ((r = unit_add_dependency_by_name(UNIT(a), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+                if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
+                        return r;
+        }
+
+        return 0;
+}
+
 static int automount_verify(Automount *a) {
         bool b;
         char *e;
 static int automount_verify(Automount *a) {
         bool b;
         char *e;
@@ -201,9 +218,8 @@ static int automount_load(Unit *u) {
                 if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0)
                         return r;
 
                 if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0)
                         return r;
 
-                if (a->meta.default_dependencies &&
-                    a->meta.manager->running_as == MANAGER_SYSTEM)
-                        if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
+                if (a->meta.default_dependencies)
+                        if ((r = automount_add_default_dependencies(a)) < 0)
                                 return r;
         }
 
                                 return r;
         }
 
index 30390de99d85a978ea6069f93ca72e0d8834cfc8..5b0bc6bdf01e6f22343922d8cd1c034600479956 100644 (file)
@@ -274,6 +274,24 @@ static int mount_add_target_links(Mount *m) {
         }
 }
 
         }
 }
 
+static int mount_add_default_dependencies(Mount *m) {
+        int r;
+
+        assert(m);
+
+        if (m->meta.manager->running_as == MANAGER_SYSTEM) {
+
+                if ((r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+                if (!path_equal(m->where, "/"))
+                        if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
+                                return r;
+        }
+
+        return 0;
+}
+
 static int mount_verify(Mount *m) {
         bool b;
         char *e;
 static int mount_verify(Mount *m) {
         bool b;
         char *e;
@@ -368,10 +386,8 @@ static int mount_load(Unit *u) {
                 if ((r = unit_add_default_cgroup(u)) < 0)
                         return r;
 
                 if ((r = unit_add_default_cgroup(u)) < 0)
                         return r;
 
-                if (m->meta.default_dependencies &&
-                    m->meta.manager->running_as == MANAGER_SYSTEM &&
-                    !path_equal(m->where, "/"))
-                        if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
+                if (m->meta.default_dependencies)
+                        if ((r = mount_add_default_dependencies(m)) < 0)
                                 return r;
         }
 
                                 return r;
         }
 
index 92035144ba8055db464f021a913c0cc330ed8fb5..de468a0434ee0e0e4dfcaace2ff6cfa8111168ee 100644 (file)
@@ -120,6 +120,24 @@ static int swap_add_target_links(Swap *s) {
         return unit_add_dependency(UNIT(s), UNIT_BEFORE, tu, true);
 }
 
         return unit_add_dependency(UNIT(s), UNIT_BEFORE, tu, true);
 }
 
+static int swap_add_default_dependencies(Swap *s) {
+        int r;
+
+        assert(s);
+
+        if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+
+                if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+                /* Note that by default we don't disable swap devices
+                 * on shutdown. i.e. there is no umount.target
+                 * conflicts here. */
+        }
+
+        return 0;
+}
+
 static int swap_verify(Swap *s) {
         bool b;
         char *e;
 static int swap_verify(Swap *s) {
         bool b;
         char *e;
@@ -185,6 +203,10 @@ static int swap_load(Unit *u) {
 
                 if ((r = swap_add_target_links(s)) < 0)
                         return r;
 
                 if ((r = swap_add_target_links(s)) < 0)
                         return r;
+
+                if (s->meta.default_dependencies)
+                        if ((r = swap_add_default_dependencies(s)) < 0)
+                                return r;
         }
 
         return swap_verify(s);
         }
 
         return swap_verify(s);
index 4e7f8ff5a9d3cef212d71438312d8c784890bf32..ab8fa7c750b9d3efaab4fa6f1d4150f488cb0624 100644 (file)
@@ -7,7 +7,7 @@
 
 [Unit]
 Description=Huge Pages File System Automount Point
 
 [Unit]
 Description=Huge Pages File System Automount Point
-Before=sysinit.target
+DefaultDependencies=no
 
 [Automount]
 Where=/dev/hugepages
 
 [Automount]
 Where=/dev/hugepages
index 2aa1c23629978da4e15fd44df00174d22771b0d9..e6014e54a050d838b52d6585a56190c0189d4864 100644 (file)
@@ -7,6 +7,7 @@
 
 [Unit]
 Description=Huge Pages File System
 
 [Unit]
 Description=Huge Pages File System
+DefaultDependencies=no
 
 [Mount]
 What=hugetlbfs
 
 [Mount]
 What=hugetlbfs
index 4df53dcaa47c43b7623bd590c5500487055cc32e..ba45b284471933082e2543105a8127ba78d18353 100644 (file)
@@ -7,7 +7,7 @@
 
 [Unit]
 Description=POSIX Message Queue File System Automount Point
 
 [Unit]
 Description=POSIX Message Queue File System Automount Point
-Before=sysinit.target
+DefaultDependencies=no
 
 [Automount]
 Where=/dev/mqueue
 
 [Automount]
 Where=/dev/mqueue
index 28c757a8a5d5e6479fe8d342755ca5600f42ed07..8519df5acaf0a544b05d7881c4e9663b94eec8d4 100644 (file)
@@ -7,6 +7,7 @@
 
 [Unit]
 Description=POSIX Message Queue File System
 
 [Unit]
 Description=POSIX Message Queue File System
+DefaultDependencies=no
 
 [Mount]
 What=mqueue
 
 [Mount]
 What=mqueue
index 82369c56b357582451779f0d80bf09e68f59e3bf..29ae05b64aa46aefb5f1004d286721405a767df8 100644 (file)
@@ -7,7 +7,7 @@
 
 [Unit]
 Description=Arbitrary Executable File Formats File System Automount Point
 
 [Unit]
 Description=Arbitrary Executable File Formats File System Automount Point
-Before=sysinit.target
+DefaultDependencies=no
 
 [Automount]
 Where=/proc/sys/fs/binfmt_misc
 
 [Automount]
 Where=/proc/sys/fs/binfmt_misc
index 0d6b196a6f97a0eebae45c81e80d2f6468cb73d4..1829c2162ac918f7a3cfc3600d8bd39860156167 100644 (file)
@@ -7,6 +7,7 @@
 
 [Unit]
 Description=Arbitrary Executable File Formats File System
 
 [Unit]
 Description=Arbitrary Executable File Formats File System
+DefaultDependencies=no
 
 [Mount]
 What=binfmt_misc
 
 [Mount]
 What=binfmt_misc
index 4da3f20531d9ec4f01bcfc420cb136ccfb059e52..3a6306f2eb8547d974a0737283b9a78fae940eaa 100644 (file)
@@ -7,7 +7,7 @@
 
 [Unit]
 Description=Debug File System Automount Point
 
 [Unit]
 Description=Debug File System Automount Point
-Before=sysinit.target
+DefaultDependencies=no
 
 [Automount]
 Where=/sys/kernel/debug
 
 [Automount]
 Where=/sys/kernel/debug
index 7bf08158f871ff88cd4a6bd3abe29f822eca4be8..53d107260b2fd027a844ee25ec8b81fd41782e7a 100644 (file)
@@ -7,6 +7,7 @@
 
 [Unit]
 Description=Debug File System
 
 [Unit]
 Description=Debug File System
+DefaultDependencies=no
 
 [Mount]
 What=debugfs
 
 [Mount]
 What=debugfs
index 5d8356e513ee94abf949d2a788d5da664d4acd2a..a428e0b6c14eaabbe9df79af10123c48f503f7fb 100644 (file)
@@ -7,7 +7,7 @@
 
 [Unit]
 Description=Security File System Automount Point
 
 [Unit]
 Description=Security File System Automount Point
-Before=sysinit.target
+DefaultDependencies=no
 
 [Automount]
 Where=/sys/kernel/security
 
 [Automount]
 Where=/sys/kernel/security
index db9d672b607b645f8065f35ed35a877be25a9b1f..770207f004b4c67304a3efc8cb7d88e600a7e629 100644 (file)
@@ -7,6 +7,7 @@
 
 [Unit]
 Description=Security File System
 
 [Unit]
 Description=Security File System
+DefaultDependencies=no
 
 [Mount]
 What=securityfs
 
 [Mount]
 What=securityfs