From ce427d0e73667e1b125c82c5c77f98dd9fbe561d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 1 Oct 2023 20:40:45 +0200 Subject: [PATCH] mount: Log when we can't create the mount point 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index 17925f50d9..55e0c2ec88 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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);