X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=3d513a051e4c88d8899da26b0a3d1eafcb9db5b4;hb=047e111bdddfed52dabc7ff8242c2eec78e126fb;hp=e8f8856414b615571acbd83fa4f5ad9e830181c2;hpb=6b1dc2bd3cdb3bd932b0692be636ddd2879edb92;p=elogind.git diff --git a/src/core/mount.c b/src/core/mount.c index e8f885641..3d513a051 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,100 @@ 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; - if ((r = unit_add_default_cgroups(u)) < 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); - mount_fix_timeouts(m); + if (r < 0) + return r; + + /* 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; } return mount_verify(m); @@ -770,6 +802,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; @@ -915,12 +948,12 @@ static void mount_enter_mounting(Mount *m) { m->control_command_id = MOUNT_EXEC_MOUNT; m->control_command = m->exec_command + MOUNT_EXEC_MOUNT; - mkdir_p(m->where, m->directory_mode); + mkdir_p_label(m->where, m->directory_mode); /* Create the source directory for bind-mounts if needed */ p = get_mount_parameters_fragment(m); if (p && mount_is_bind(p)) - mkdir_p(p->what, m->directory_mode); + mkdir_p_label(p->what, m->directory_mode); if (m->from_fragment) r = exec_command_set( @@ -1407,6 +1440,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)) || @@ -1451,27 +1492,6 @@ fail: return r; } -static int mount_find_pri(char *options) { - char *end, *pri; - unsigned long r; - - if (!(pri = mount_test_option(options, "pri"))) - return 0; - - pri += 4; - - errno = 0; - r = strtoul(pri, &end, 10); - - if (errno != 0) - return -errno; - - if (end == pri || (*end != ',' && *end != 0)) - return -EINVAL; - - return (int) r; -} - static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { int r = 0; unsigned i;