chiark / gitweb /
unit: add simple only-by-dependency flag for units
[elogind.git] / src / mount.c
index ec03a52f6a7c4442d3f29e4893040dd769624797..01fc2dffbbee3bbbe057b27511f5f98b675e9fd8 100644 (file)
@@ -215,7 +215,7 @@ static int mount_add_target_links(Mount *m) {
         MountParameters *p;
         Unit *tu;
         int r;
-        bool noauto, handle, automount;
+        bool noauto, handle, automount, user;
 
         assert(m);
 
@@ -227,6 +227,7 @@ static int mount_add_target_links(Mount *m) {
                 return 0;
 
         noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
+        user = mount_test_option(p->options, "user") || mount_test_option(p->options, "users");
         handle = !!mount_test_option(p->options, "comment=systemd.mount");
         automount = !!mount_test_option(p->options, "comment=systemd.automount");
 
@@ -239,7 +240,7 @@ static int mount_add_target_links(Mount *m) {
         if ((r = manager_load_unit(UNIT(m)->meta.manager, target, NULL, &tu)) < 0)
                 return r;
 
-        if (automount) {
+        if (automount && m->meta.manager->running_as != MANAGER_SESSION) {
                 Unit *am;
 
                 if ((r = unit_load_related_unit(UNIT(m), ".automount", &am)) < 0)
@@ -253,8 +254,9 @@ static int mount_add_target_links(Mount *m) {
         } else {
 
                 if (!noauto && handle)
-                        if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
-                                return r;
+                        if (user || m->meta.manager->running_as != MANAGER_SESSION)
+                                if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
+                                        return r;
 
                 return unit_add_dependency(UNIT(m), UNIT_BEFORE, tu, true);
         }
@@ -265,9 +267,12 @@ static int mount_verify(Mount *m) {
         char *e;
         assert(m);
 
-        if (UNIT(m)->meta.load_state != UNIT_LOADED)
+        if (m->meta.load_state != UNIT_LOADED)
                 return 0;
 
+        if (!m->from_etc_fstab && !m->from_fragment && !m->from_proc_self_mountinfo)
+                return -ENOENT;
+
         if (!(e = unit_name_from_path(m->where, ".mount")))
                 return -ENOMEM;
 
@@ -931,7 +936,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         case MOUNT_REMOUNTING_SIGKILL:
         case MOUNT_REMOUNTING_SIGTERM:
 
-                if (success && m->from_proc_self_mountinfo)
+                if (success)
                         mount_enter_mounted(m, true);
                 else if (m->from_proc_self_mountinfo)
                         mount_enter_mounted(m, false);