chiark / gitweb /
Configurable Timeouts/Restarts default values
[elogind.git] / src / core / mount.c
index 3d46557fb1d42864fcfac04006fb21f8ba7f1d3e..0c15b99f945e85a83aa42ee86acfb0062d9ed6b3 100644 (file)
@@ -59,13 +59,79 @@ static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
         [MOUNT_FAILED] = UNIT_FAILED
 };
 
+static char* mount_test_option(const char *haystack, const char *needle) {
+        struct mntent me = { .mnt_opts = (char*) haystack };
+
+        assert(needle);
+
+        /* Like glibc's hasmntopt(), but works on a string, not a
+         * struct mntent */
+
+        if (!haystack)
+                return NULL;
+
+        return hasmntopt(&me, needle);
+}
+
+static bool mount_is_network(MountParameters *p) {
+        assert(p);
+
+        if (mount_test_option(p->options, "_netdev"))
+                return true;
+
+        if (p->fstype && fstype_is_network(p->fstype))
+                return true;
+
+        return false;
+}
+
+static bool mount_is_bind(MountParameters *p) {
+        assert(p);
+
+        if (mount_test_option(p->options, "bind"))
+                return true;
+
+        if (p->fstype && streq(p->fstype, "bind"))
+                return true;
+
+        if (mount_test_option(p->options, "rbind"))
+                return true;
+
+        if (p->fstype && streq(p->fstype, "rbind"))
+                return true;
+
+        return false;
+}
+
+static bool mount_is_auto(MountParameters *p) {
+        assert(p);
+
+        return !mount_test_option(p->options, "noauto");
+}
+
+static bool needs_quota(MountParameters *p) {
+        assert(p);
+
+        if (mount_is_network(p))
+                return false;
+
+        if (mount_is_bind(p))
+                return false;
+
+        return mount_test_option(p->options, "usrquota") ||
+                mount_test_option(p->options, "grpquota") ||
+                mount_test_option(p->options, "quota") ||
+                mount_test_option(p->options, "usrjquota") ||
+                mount_test_option(p->options, "grpjquota");
+}
+
 static void mount_init(Unit *u) {
         Mount *m = MOUNT(u);
 
         assert(u);
         assert(u->load_state == UNIT_STUB);
 
-        m->timeout_usec = DEFAULT_TIMEOUT_USEC;
+        m->timeout_usec = u->manager->default_timeout_start_usec;
         m->directory_mode = 0755;
 
         exec_context_init(&m->exec_context);
@@ -182,7 +248,10 @@ static int mount_add_mount_links(Mount *m) {
          * for the source path (if this is a bind mount) to be
          * available. */
         pm = get_mount_parameters_fragment(m);
-        if (pm && path_is_absolute(pm->what)) {
+        if (pm && pm->what &&
+            path_is_absolute(pm->what) &&
+            !mount_is_network(pm)) {
+
                 r = unit_require_mounts_for(UNIT(m), pm->what);
                 if (r < 0)
                         return r;
@@ -214,72 +283,6 @@ static int mount_add_mount_links(Mount *m) {
         return 0;
 }
 
-static char* mount_test_option(const char *haystack, const char *needle) {
-        struct mntent me = { .mnt_opts = (char*) haystack };
-
-        assert(needle);
-
-        /* Like glibc's hasmntopt(), but works on a string, not a
-         * struct mntent */
-
-        if (!haystack)
-                return NULL;
-
-        return hasmntopt(&me, needle);
-}
-
-static bool mount_is_network(MountParameters *p) {
-        assert(p);
-
-        if (mount_test_option(p->options, "_netdev"))
-                return true;
-
-        if (p->fstype && fstype_is_network(p->fstype))
-                return true;
-
-        return false;
-}
-
-static bool mount_is_bind(MountParameters *p) {
-        assert(p);
-
-        if (mount_test_option(p->options, "bind"))
-                return true;
-
-        if (p->fstype && streq(p->fstype, "bind"))
-                return true;
-
-        if (mount_test_option(p->options, "rbind"))
-                return true;
-
-        if (p->fstype && streq(p->fstype, "rbind"))
-                return true;
-
-        return false;
-}
-
-static bool mount_is_auto(MountParameters *p) {
-        assert(p);
-
-        return !mount_test_option(p->options, "noauto");
-}
-
-static bool needs_quota(MountParameters *p) {
-        assert(p);
-
-        if (mount_is_network(p))
-                return false;
-
-        if (mount_is_bind(p))
-                return false;
-
-        return mount_test_option(p->options, "usrquota") ||
-                mount_test_option(p->options, "grpquota") ||
-                mount_test_option(p->options, "quota") ||
-                mount_test_option(p->options, "usrjquota") ||
-                mount_test_option(p->options, "grpjquota");
-}
-
 static int mount_add_device_links(Mount *m) {
         MountParameters *p;
         bool device_wants_mount = false;
@@ -310,33 +313,6 @@ static int mount_add_device_links(Mount *m) {
         if (r < 0)
                 return r;
 
-        if (p->passno > 0 &&
-            UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) {
-                char *name;
-                Unit *fsck;
-                /* Let's add in the fsck service */
-
-                /* aka SPECIAL_FSCK_SERVICE */
-                name = unit_name_from_path_instance("systemd-fsck", p->what, ".service");
-                if (!name)
-                        return -ENOMEM;
-
-                r = manager_load_unit_prepare(UNIT(m)->manager, name, NULL, NULL, &fsck);
-                if (r < 0) {
-                        log_warning_unit(name,
-                                         "Failed to prepare unit %s: %s", name, strerror(-r));
-                        free(name);
-                        return r;
-                }
-                free(name);
-
-                SERVICE(fsck)->fsck_passno = p->passno;
-
-                r = unit_add_two_dependencies(UNIT(m), UNIT_AFTER, UNIT_REQUIRES, fsck, true);
-                if (r < 0)
-                        return r;
-        }
-
         return 0;
 }
 
@@ -1407,7 +1383,6 @@ static int mount_add_one(
                 const char *where,
                 const char *options,
                 const char *fstype,
-                int passno,
                 bool set_flags) {
         int r;
         Unit *u;
@@ -1440,6 +1415,9 @@ static int mount_add_one(
 
         u = manager_get_unit(m, e);
         if (!u) {
+                const char* const target =
+                        fstype_is_network(fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
+
                 delete = true;
 
                 u = unit_new(m, sizeof(Mount));
@@ -1466,7 +1444,7 @@ static int mount_add_one(
                         goto fail;
                 }
 
-                r = unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_LOCAL_FS_TARGET, NULL, true);
+                r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
                 if (r < 0)
                         goto fail;
 
@@ -1524,8 +1502,6 @@ static int mount_add_one(
         free(p->fstype);
         p->fstype = f;
 
-        p->passno = passno;
-
         if (load_extras) {
                 r = mount_add_extras(MOUNT(u));
                 if (r < 0)
@@ -1595,7 +1571,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
                 if (!d || !p)
                         return log_oom();
 
-                k = mount_add_one(m, d, p, o, fstype, 0, set_flags);
+                k = mount_add_one(m, d, p, o, fstype, set_flags);
                 if (k < 0)
                         r = k;
         }