diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-12-05 11:59:05 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-12-05 12:25:50 +0100 |
commit | 20ad4cfd8e5592f634f20468798cbc1055ab9faf (patch) | |
tree | 19d3421163da514fad9c74b034d5014636a1cfe0 /src/core | |
parent | f3ffced5415a385ff08b460fcc95251e773b38a7 (diff) |
core: add catalog entry and MESSAGE_ID for overmounting
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/automount.c | 4 | ||||
-rw-r--r-- | src/core/execute.c | 3 | ||||
-rw-r--r-- | src/core/mount.c | 16 | ||||
-rw-r--r-- | src/core/mount.h | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index 5bf59df8bc..74776646f6 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -31,6 +31,7 @@ #include "unit.h" #include "automount.h" +#include "mount.h" #include "load-fragment.h" #include "load-dropin.h" #include "unit-name.h" @@ -507,8 +508,7 @@ static void automount_enter_waiting(Automount *a) { /* We knowingly ignore the results of this call */ mkdir_p_label(a->where, 0555); - if (dir_is_empty(a->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.)", a->meta.id, a->where); + warn_if_dir_nonempty(a->meta.id, a->where); if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) { r = -errno; diff --git a/src/core/execute.c b/src/core/execute.c index e236d38e0f..76284700d7 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -50,6 +50,7 @@ #include "capability.h" #include "util.h" #include "log.h" +#include "sd-messages.h" #include "ioprio.h" #include "securebits.h" #include "cgroup.h" @@ -62,8 +63,6 @@ #include "loopback-setup.h" #include "path-util.h" #include "syscall-list.h" -#include "sd-id128.h" -#include "sd-messages.h" #define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC) diff --git a/src/core/mount.c b/src/core/mount.c index 09a5d286d3..f263d9b9d1 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" @@ -927,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; @@ -967,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); diff --git a/src/core/mount.h b/src/core/mount.h index 67d6132a5d..30c6d9b249 100644 --- a/src/core/mount.h +++ b/src/core/mount.h @@ -119,3 +119,5 @@ MountExecCommand mount_exec_command_from_string(const char *s); const char* mount_result_to_string(MountResult i); MountResult mount_result_from_string(const char *s); + +void warn_if_dir_nonempty(const char *unit, const char* where); |