X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=f263d9b9d15461539b164d892ab7f5b97df16e48;hb=20ad4cfd8e5592f634f20468798cbc1055ab9faf;hp=e1c240e31b0e1ca43b79f13b31cdc061d79cdde2;hpb=b87705cdd2f791f8520edb78791d3e6f78afd481;p=elogind.git diff --git a/src/core/mount.c b/src/core/mount.c index e1c240e31..f263d9b9d 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -30,6 +30,7 @@ #include "load-fragment.h" #include "load-dropin.h" #include "log.h" +#include "sd-messages.h" #include "strv.h" #include "mkdir.h" #include "path-util.h" @@ -547,10 +548,6 @@ static int mount_add_extras(Mount *m) { Unit *u = UNIT(m); int r; - r = unit_add_exec_dependencies(u, &m->exec_context); - if (r < 0) - return r; - if (UNIT(m)->fragment_path) m->from_fragment = true; @@ -562,6 +559,10 @@ static int mount_add_extras(Mount *m) { path_kill_slashes(m->where); + r = unit_add_exec_dependencies(u, &m->exec_context); + if (r < 0) + return r; + if (!UNIT(m)->description) { r = unit_set_description(u, m->where); if (r < 0) @@ -741,10 +742,12 @@ static int mount_coldplug(Unit *u) { if (m->control_pid <= 0) return -EBADMSG; - if ((r = unit_watch_pid(UNIT(m), m->control_pid)) < 0) + r = unit_watch_pid(UNIT(m), m->control_pid); + if (r < 0) return r; - if ((r = unit_watch_timer(UNIT(m), m->timeout_usec, &m->timer_watch)) < 0) + r = unit_watch_timer(UNIT(m), CLOCK_MONOTONIC, true, m->timeout_usec, &m->timer_watch); + if (r < 0) return r; } @@ -800,7 +803,8 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) { assert(c); assert(_pid); - if ((r = unit_watch_timer(UNIT(m), m->timeout_usec, &m->timer_watch)) < 0) + r = unit_watch_timer(UNIT(m), CLOCK_MONOTONIC, true, m->timeout_usec, &m->timer_watch); + if (r < 0) goto fail; if ((r = exec_spawn(c, @@ -900,7 +904,8 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) { } if (wait_for_exit) { - if ((r = unit_watch_timer(UNIT(m), m->timeout_usec, &m->timer_watch)) < 0) + r = unit_watch_timer(UNIT(m), CLOCK_MONOTONIC, true, m->timeout_usec, &m->timer_watch); + if (r < 0) goto fail; mount_set_state(m, state); @@ -923,6 +928,18 @@ fail: set_free(pid_set); } +void warn_if_dir_nonempty(const char *unit, const char* where) { + if (dir_is_empty(where) > 0) + return; + log_struct(LOG_NOTICE, + "MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.", + unit, where, + "WHERE=%s", where, + "_SYSTEMD_UNIT=%s", unit, + MESSAGE_ID(SD_MESSAGE_OVERMOUNTING), + NULL); +} + static void mount_enter_unmounting(Mount *m) { int r; @@ -963,8 +980,7 @@ static void mount_enter_mounting(Mount *m) { mkdir_p_label(m->where, m->directory_mode); - if (dir_is_empty(m->where) <= 0) - log_notice("%s: Directory %s to mount over is not empty, mounting anyway. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", m->meta.id, m->where); + warn_if_dir_nonempty(m->meta.id, m->where); /* Create the source directory for bind-mounts if needed */ p = get_mount_parameters_fragment(m); @@ -1459,6 +1475,14 @@ static int mount_add_one( delete = false; free(e); + if (!MOUNT(u)->where) { + MOUNT(u)->where = strdup(where); + if (!MOUNT(u)->where) { + r = -ENOMEM; + goto fail; + } + } + if (u->load_state == UNIT_ERROR) { u->load_state = UNIT_LOADED; u->load_error = 0;