X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fmount.c;h=f94c0eb278dbe10f12fc83d5c9563761f1d63438;hp=f9cfe910a07c5195985ec8c46706fb6f680c6789;hb=7d17cfbc46306a106dbda0f3e92fbc0792d1e9e9;hpb=1e2579fdeb7608719cb28da0b5061f48ba0efc34 diff --git a/src/mount.c b/src/mount.c index f9cfe910a..f94c0eb27 100644 --- a/src/mount.c +++ b/src/mount.c @@ -68,8 +68,10 @@ static void mount_init(Unit *u) { /* The stdio/kmsg bridge socket is on /, in order to avoid a * dep loop, don't use kmsg logging for -.mount */ - if (!unit_has_name(u, "-.mount")) - m->exec_context.std_output = EXEC_OUTPUT_KMSG; + if (!unit_has_name(u, "-.mount")) { + m->exec_context.std_output = u->meta.manager->default_std_output; + m->exec_context.std_error = u->meta.manager->default_std_error; + } /* We need to make sure that /bin/mount is always called in * the same process group as us, so that the autofs kernel @@ -106,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); @@ -364,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; @@ -468,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; } @@ -595,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))) @@ -645,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) { @@ -1404,13 +1395,16 @@ static int mount_add_one( if (!is_path(where)) return 0; - if (!(e = unit_name_from_path(where, ".mount"))) + e = unit_name_from_path(where, ".mount"); + if (!e) return -ENOMEM; - if (!(u = manager_get_unit(m, e))) { + u = manager_get_unit(m, e); + if (!u) { delete = true; - if (!(u = unit_new(m))) { + u = unit_new(m, sizeof(Mount)); + if (!u) { free(e); return -ENOMEM; } @@ -1421,7 +1415,8 @@ static int mount_add_one( if (r < 0) goto fail; - if (!(MOUNT(u)->where = strdup(where))) { + MOUNT(u)->where = strdup(where); + if (!MOUNT(u)->where) { r = -ENOMEM; goto fail; } @@ -1846,6 +1841,7 @@ DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand); const UnitVTable mount_vtable = { .suffix = ".mount", + .object_size = sizeof(Mount), .sections = "Unit\0" "Mount\0"