chiark / gitweb /
mount: notify the user if we over-mount a non-empty directory
[elogind.git] / src / core / mount.c
index 5709db2266196c1a9e82ce25f35ae18bdb9a1598..78740a8b2d6ab170008d72e9c5ac9049bdd9d342 100644 (file)
@@ -634,7 +634,7 @@ static int mount_load(Unit *u) {
                 if (r < 0)
                         return r;
 
-                r = unit_patch_working_directory(UNIT(m), &m->exec_context);
+                r = unit_exec_context_defaults(u, &m->exec_context);
                 if (r < 0)
                         return r;
         }
@@ -959,6 +959,9 @@ 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, ignoring. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", m->meta.id, m->where);
+
         /* Create the source directory for bind-mounts if needed */
         p = get_mount_parameters_fragment(m);
         if (p && mount_is_bind(p))
@@ -981,7 +984,8 @@ static void mount_enter_mounting(Mount *m) {
 
         mount_unwatch_control_pid(m);
 
-        if ((r = mount_spawn(m, m->control_command, &m->control_pid)) < 0)
+        r = mount_spawn(m, m->control_command, &m->control_pid);
+        if (r < 0)
                 goto fail;
 
         mount_set_state(m, MOUNT_MOUNTING);
@@ -1225,7 +1229,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
 
         m->control_pid = 0;
 
-        if (is_clean_exit(code, status))
+        if (is_clean_exit(code, status, NULL))
                 f = MOUNT_SUCCESS;
         else if (code == CLD_EXITED)
                 f = MOUNT_FAILURE_EXIT_CODE;
@@ -1797,6 +1801,8 @@ DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
 
 const UnitVTable mount_vtable = {
         .object_size = sizeof(Mount),
+        .exec_context_offset = offsetof(Mount, exec_context),
+
         .sections =
                 "Unit\0"
                 "Mount\0"