]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount: Log when we can't create the mount point
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 1 Oct 2023 18:40:45 +0000 (20:40 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 2 Oct 2023 02:24:03 +0000 (11:24 +0900)
Debugging mount unit failures caused by systemd not being able to
create the mount point is currently rather hard. Let's log about
failures to create mount points to simplify debugging.

src/core/mount.c

index 17925f50d9042a79b095434b1e32cb787eccabbf..55e0c2ec8863ae35fec50e29a4b67da9bffcd867 100644 (file)
@@ -1169,9 +1169,11 @@ static void mount_enter_mounting(Mount *m) {
         }
 
         if (source_is_dir)
-                (void) mkdir_p_label(m->where, m->directory_mode);
+                r = mkdir_p_label(m->where, m->directory_mode);
         else
-                (void) touch_file(m->where, /* parents = */ true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
+                r = touch_file(m->where, /* parents = */ true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
+        if (r < 0 && r != -EEXIST)
+                log_unit_warning_errno(UNIT(m), r, "Failed to create mount point '%s', ignoring: %m", m->where);
 
         if (source_is_dir)
                 unit_warn_if_dir_nonempty(UNIT(m), m->where);