]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Improve logging when we cannot create destination mountpoint
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 16 Jan 2026 20:21:06 +0000 (21:21 +0100)
committerDaan De Meyer <daan@amutable.com>
Tue, 3 Feb 2026 14:00:32 +0000 (15:00 +0100)
If we fail to create a parent directory, then the error from
make_mount_point_inode_from_path() will always be
"No such file or directory" which doesn't tell us anything. Add logging
for the mkdir_parents() call as well so we get a useful error.

src/core/namespace.c

index 1a969895123331a965c1761ac351204bd07b455b..6e9c6a09f8799280ee08db95cc168ee05f396c71 100644 (file)
@@ -2050,15 +2050,20 @@ static int apply_one_mount(
                         /* Hmm, either the source or the destination are missing. Let's see if we can create
                            the destination, then try again. */
 
-                        (void) mkdir_parents(mount_entry_path(m), 0755);
-
-                        q = make_mount_point_inode_from_path(what, mount_entry_path(m), 0755);
+                        q = mkdir_parents(mount_entry_path(m), 0755);
                         if (q < 0 && q != -EEXIST)
                                 // FIXME: this shouldn't be logged at LOG_WARNING, but be bubbled up, and logged there to avoid duplicate logging
-                                log_warning_errno(q, "Failed to create destination mount point node '%s', ignoring: %m",
+                                log_warning_errno(q, "Failed to create parent directories of destination mount point node '%s', ignoring: %m",
                                                   mount_entry_path(m));
-                        else
-                                try_again = true;
+                        else {
+                                q = make_mount_point_inode_from_path(what, mount_entry_path(m), 0755);
+                                if (q < 0 && q != -EEXIST)
+                                        // FIXME: this shouldn't be logged at LOG_WARNING, but be bubbled up, and logged there to avoid duplicate logging
+                                        log_warning_errno(q, "Failed to create destination mount point node '%s', ignoring: %m",
+                                                          mount_entry_path(m));
+                                else
+                                        try_again = true;
+                        }
                 }
 
                 if (try_again)