X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fmount.c;h=12c0710f1fb9d9cfd2de84957dd389946c79358c;hb=e6acda19b26e5a8e490b48b15e2ba33d9103b3bd;hp=47422ccf8bafc4a59e9b2af5f3f6ea4041f11f43;hpb=dc1ecd78e9f046880d10ddb45cf9b06df1084b10;p=elogind.git diff --git a/src/mount.c b/src/mount.c index 47422ccf8..12c0710f1 100644 --- a/src/mount.c +++ b/src/mount.c @@ -108,21 +108,12 @@ static void mount_parameters_done(MountParameters *p) { static void mount_done(Unit *u) { Mount *m = MOUNT(u); - Meta *other; assert(m); free(m->where); m->where = NULL; - /* Try to detach us from the automount unit if there is any */ - LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_AUTOMOUNT]) { - Automount *a = (Automount*) other; - - if (a->mount == m) - a->mount = NULL; - } - mount_parameters_done(&m->parameters_etc_fstab); mount_parameters_done(&m->parameters_proc_self_mountinfo); mount_parameters_done(&m->parameters_fragment); @@ -366,10 +357,6 @@ static int mount_add_fstab_links(Mount *m) { after = SPECIAL_LOCAL_FS_PRE_TARGET; } - 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; - if ((r = manager_load_unit(m->meta.manager, target, NULL, NULL, &tu)) < 0) return r; @@ -470,24 +457,23 @@ static int mount_add_device_links(Mount *m) { static int mount_add_default_dependencies(Mount *m) { int r; + MountParameters *p; assert(m); - if (m->meta.manager->running_as == MANAGER_SYSTEM && - !path_equal(m->where, "/")) { - MountParameters *p; - - p = get_mount_parameters_configured(m); + if (m->meta.manager->running_as != MANAGER_SYSTEM) + return 0; - if (p && needs_quota(p)) { - if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0 || - (r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTAON_SERVICE, NULL, true)) < 0) - return r; - } + p = get_mount_parameters_configured(m); + if (p && needs_quota(p)) { + if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0 || + (r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTAON_SERVICE, 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; } @@ -597,8 +583,6 @@ static int mount_load(Unit *u) { if (m->meta.fragment_path) m->from_fragment = true; - else if (m->from_etc_fstab) - m->meta.default_dependencies = false; if (!m->where) if (!(m->where = unit_name_to_path(u->meta.id))) @@ -647,13 +631,18 @@ static int mount_load(Unit *u) { static int mount_notify_automount(Mount *m, int status) { Unit *p; int r; + Iterator i; assert(m); - if ((r = unit_get_related_unit(UNIT(m), ".automount", &p)) < 0) - return r == -ENOENT ? 0 : r; + SET_FOREACH(p, m->meta.dependencies[UNIT_TRIGGERED_BY], i) + if (p->meta.type == UNIT_AUTOMOUNT) { + r = automount_send_ready(AUTOMOUNT(p), status); + if (r < 0) + return r; + } - return automount_send_ready(AUTOMOUNT(p), status); + return 0; } static void mount_set_state(Mount *m, MountState state) {