chiark / gitweb /
core: add catalog entry and MESSAGE_ID for overmounting
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Dec 2012 10:59:05 +0000 (11:59 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Dec 2012 11:25:50 +0000 (12:25 +0100)
TODO
catalog/systemd.catalog
src/core/automount.c
src/core/execute.c
src/core/mount.c
src/core/mount.h
src/shared/log.h
src/systemd/sd-messages.h

diff --git a/TODO b/TODO
index c99ab6d1bb933033a3dccf0b6bf32c05c38593b6..9ddfb5c293c5e91e587792182ec451861c626ad8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -43,8 +43,6 @@ Features:
   include _SYSTEMD_UNIT= fields so that "systemctl status" can show
   them along with the unit
 
-* define a message ID for "overmounting non-empty directory" and write message catalog entry for it
-
 * use polkit "imply" for binding hostname actions together
 
 * journal: when waiting for journal additions always sleep at least 1s or so, in order to minimize wakeups
index c2f38a39da2786d471c73da2ff2b11356032f09f..5dcbd4620a3cde684884bb9d602d34682868a04e 100644 (file)
@@ -276,3 +276,16 @@ One or more messages could not be forwarded to the syslog service
 running side-by-side with journald. This usually indicates that the
 syslog implementation has not been able to keep up with the speed of
 messages queued.
+
+-- 1dee0369c7fc4736b7099b38ecb46ee7
+Subject: Mount point is not empty
+Defined-By: systemd
+Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
+Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/@MESSAGE_ID@
+
+The directory @WHERE@ is specified as the mount point (second field in
+/etc/fstab or Where= field in systemd unit file) and is not empty.
+This does not interfere with mounting, but the pre-exisiting files in
+this directory become inaccessible. To see those over-mounted files,
+please manually mount the underlying file system to a secondary
+location.
index 5bf59df8bcc1323bfdac18931e22228f23ab31b0..74776646f632b5b7e1cbd6e9b254e9d2f7729788 100644 (file)
@@ -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;
index e236d38e0fa862ca8b5f758301c8d69736e5425b..76284700d7b3044b425775587b8296d62edd9038 100644 (file)
@@ -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)
 
index 09a5d286d36549870c6f97c243d21a59cdec5677..f263d9b9d15461539b164d892ab7f5b97df16e48 100644 (file)
@@ -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);
index 67d6132a5d90ac1c3d07ceb1c7e0df38ad4aec55..30c6d9b249bdf74c69f98b3502698863a0a6cdce 100644 (file)
@@ -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);
index 1bd9dbf27aedd4773c5eaf628f74afc568d06785..5c946faf514c669906d16b2dc357bb09be67e336 100644 (file)
@@ -27,6 +27,7 @@
 #include <errno.h>
 
 #include "macro.h"
+#include "sd-id128.h"
 
 typedef enum LogTarget{
         LOG_TARGET_CONSOLE,
index b8b78d10edc3f9c2ed344168f9c1e3db45359be9..bc560947d41ced10eda2fee297504630a5ef92b1 100644 (file)
@@ -65,6 +65,8 @@ extern "C" {
 
 #define SD_MESSAGE_FORWARD_SYSLOG_MISSED SD_ID128_MAKE(00,27,22,9c,a0,64,41,81,a7,6c,4e,92,45,8a,fa,2e)
 
+#define SD_MESSAGE_OVERMOUNTING     SD_ID128_MAKE(1d,ee,03,69,c7,fc,47,36,b7,09,9b,38,ec,b4,6e,e7)
+
 #ifdef __cplusplus
 }
 #endif