X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=0c15b99f945e85a83aa42ee86acfb0062d9ed6b3;hp=93bfa99f3fe123525b6c290fb9985a1100ef3681;hb=1f19a534ea84458670ec011f6d1ba96f76e3f783;hpb=77009452cfd25208509b14ea985e81fdf9f7d40e diff --git a/src/core/mount.c b/src/core/mount.c index 93bfa99f3..0c15b99f9 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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; @@ -1527,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) @@ -1598,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; }