]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stat-util: Make sure we trigger automounts when looking for ESP/XBOOTLDR
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 29 Jun 2023 13:38:35 +0000 (15:38 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 30 Jun 2023 11:25:07 +0000 (12:25 +0100)
Fixes #25417

src/shared/find-esp.c
src/shared/mount-util.c
src/shared/mount-util.h

index 6b460a27cb9c0d1c56f43df1953cb92e96caf791..a4cadc7cbacd47ca605590226d39498f9ce92747 100644 (file)
@@ -17,6 +17,7 @@
 #include "fd-util.h"
 #include "find-esp.h"
 #include "gpt.h"
+#include "mount-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "stat-util.h"
@@ -363,6 +364,12 @@ static int verify_esp(
                 if (r < 0 && r != -EADDRNOTAVAIL)
                         return log_error_errno(r, "Failed to extract filename of %s: %m", p);
 
+                /* Trigger any automounts so that xstatfsat() operates on the mount instead of the mountpoint
+                 * directory. */
+                r = trigger_automount_at(pfd, f);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to trigger automount at %s: %m", p);
+
                 r = xstatfsat(pfd, strempty(f), &sfs);
                 if (r < 0)
                         /* If we are searching for the mount point, don't generate a log message if we can't find the path */
index 83aa3fa6523e0efa14c233b4350dd0f81ea1e5aa..b65416b03bdf2eb13e55f6cbcdd3eddd2ffba4f2 100644 (file)
@@ -1455,3 +1455,17 @@ int make_mount_point_inode_from_path(const char *source, const char *dest, mode_
 
         return make_mount_point_inode_from_stat(&st, dest, mode);
 }
+
+int trigger_automount_at(int dir_fd, const char *path) {
+        _cleanup_free_ char *nested = NULL;
+
+        assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
+
+        nested = path_join(path, "a");
+        if (!nested)
+                return -ENOMEM;
+
+        (void) faccessat(dir_fd, nested, F_OK, 0);
+
+        return 0;
+}
index 42a15b58008bbd5c6e9c5d66ee857c8b3b19237c..ceb3964a74883ecb0963916f94e2a33394c0329c 100644 (file)
@@ -139,3 +139,5 @@ int bind_mount_submounts(
 /* Creates a mount point (not parents) based on the source path or stat - ie, a file or a directory */
 int make_mount_point_inode_from_stat(const struct stat *st, const char *dest, mode_t mode);
 int make_mount_point_inode_from_path(const char *source, const char *dest, mode_t mode);
+
+int trigger_automount_at(int dir_fd, const char *path);