X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=a88b255875203caa8b16b83a0704fb57ea33a403;hb=6f5878a286c34739d8d6759de5f5a77e56daeb61;hp=b885baab002bb98b50c8792d86f44454e542fc1d;hpb=d2e54fae5ca7a0f71b5ac8b356a589ff0a09ea0a;p=elogind.git diff --git a/src/core/mount.c b/src/core/mount.c index b885baab0..a88b25587 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -366,7 +366,7 @@ static int mount_add_device_links(Mount *m) { /* Let's add in the fsck service */ /* aka SPECIAL_FSCK_SERVICE */ - name = unit_name_from_path_instance("fsck", p->what, ".service"); + name = unit_name_from_path_instance("systemd-fsck", p->what, ".service"); if (!name) return -ENOMEM; @@ -537,68 +537,104 @@ static int mount_verify(Mount *m) { return 0; } -static int mount_load(Unit *u) { - Mount *m = MOUNT(u); +static int mount_add_extras(Mount *m) { + Unit *u = UNIT(m); int r; - assert(u); - assert(u->load_state == UNIT_STUB); - - if ((r = unit_load_fragment_and_dropin_optional(u)) < 0) + r = unit_add_exec_dependencies(u, &m->exec_context); + if (r < 0) return r; - /* This is a new unit? Then let's add in some extras */ - if (u->load_state == UNIT_LOADED) { - if ((r = unit_add_exec_dependencies(u, &m->exec_context)) < 0) - return r; - - if (UNIT(m)->fragment_path) - m->from_fragment = true; + if (UNIT(m)->fragment_path) + m->from_fragment = true; + if (!m->where) { + m->where = unit_name_to_path(u->id); if (!m->where) - if (!(m->where = unit_name_to_path(u->id))) - return -ENOMEM; - - path_kill_slashes(m->where); + return -ENOMEM; + } - if (!UNIT(m)->description) - if ((r = unit_set_description(u, m->where)) < 0) - return r; + path_kill_slashes(m->where); - if ((r = mount_add_device_links(m)) < 0) + if (!UNIT(m)->description) { + r = unit_set_description(u, m->where); + if (r < 0) return r; + } - if ((r = mount_add_mount_links(m)) < 0) - return r; + r = mount_add_device_links(m); + if (r < 0) + return r; - if ((r = mount_add_socket_links(m)) < 0) - return r; + r = mount_add_mount_links(m); + if (r < 0) + return r; - if ((r = mount_add_swap_links(m)) < 0) - return r; + r = mount_add_socket_links(m); + if (r < 0) + return r; - if ((r = mount_add_path_links(m)) < 0) - return r; + r = mount_add_swap_links(m); + if (r < 0) + return r; - r = mount_add_requires_mounts_links(m); - if (r < 0) - return r; + r = mount_add_path_links(m); + if (r < 0) + return r; - if ((r = mount_add_automount_links(m)) < 0) - return r; + r = mount_add_requires_mounts_links(m); + if (r < 0) + return r; + + r = mount_add_automount_links(m); + if (r < 0) + return r; + + r = mount_add_quota_links(m); + if (r < 0) + return r; - r = mount_add_quota_links(m); + if (UNIT(m)->default_dependencies) { + r = mount_add_default_dependencies(m); if (r < 0) return r; + } - if (UNIT(m)->default_dependencies) - if ((r = mount_add_default_dependencies(m)) < 0) - return r; + r = unit_add_default_cgroups(u); + if (r < 0) + return r; + + r = mount_fix_timeouts(m); + if (r < 0) + return r; + + return 0; +} + +static int mount_load(Unit *u) { + Mount *m = MOUNT(u); + int r; + + assert(u); + assert(u->load_state == UNIT_STUB); + + if (m->from_proc_self_mountinfo) + r = unit_load_fragment_and_dropin_optional(u); + else + r = unit_load_fragment_and_dropin(u); + + if (r < 0) + return r; - if ((r = unit_add_default_cgroups(u)) < 0) + /* This is a new unit? Then let's add in some extras */ + if (u->load_state == UNIT_LOADED) { + r = mount_add_extras(m); + if (r < 0) return r; - mount_fix_timeouts(m); + r = unit_patch_working_directory(UNIT(m), &m->exec_context); + if (r < 0) + return r; } return mount_verify(m); @@ -655,8 +691,10 @@ static void mount_set_state(Mount *m, MountState state) { state == MOUNT_REMOUNTING_SIGKILL || state == MOUNT_UNMOUNTING_SIGTERM || state == MOUNT_UNMOUNTING_SIGKILL || - state == MOUNT_FAILED) - mount_notify_automount(m, -ENODEV); + state == MOUNT_FAILED) { + if (state != old_state) + mount_notify_automount(m, -ENODEV); + } if (state != old_state) log_debug("%s changed %s -> %s", @@ -770,6 +808,7 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) { UNIT(m)->cgroup_bondings, UNIT(m)->cgroup_attributes, NULL, + UNIT(m)->id, NULL, &pid)) < 0) goto fail; @@ -1407,6 +1446,14 @@ static int mount_add_one( } else { delete = false; free(e); + + if (u->load_state == UNIT_ERROR) { + u->load_state = UNIT_LOADED; + u->load_error = 0; + r = mount_add_extras(MOUNT(u)); + if (r < 0) + goto fail; + } } if (!(w = strdup(what)) || @@ -1491,7 +1538,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { goto clean_up; } - o = join(options, ",", options2, NULL); + o = strjoin(options, ",", options2, NULL); if (!o) { r = -ENOMEM; goto finish; @@ -1744,7 +1791,6 @@ static const char* const mount_result_table[_MOUNT_RESULT_MAX] = { DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult); const UnitVTable mount_vtable = { - .suffix = ".mount", .object_size = sizeof(Mount), .sections = "Unit\0"