From: Daan De Meyer Date: Thu, 29 Jun 2023 13:38:35 +0000 (+0200) Subject: stat-util: Make sure we trigger automounts when looking for ESP/XBOOTLDR X-Git-Tag: v254-rc1~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=506c1bb594543f6fcb232048e76e60e2caddee86;p=thirdparty%2Fsystemd.git stat-util: Make sure we trigger automounts when looking for ESP/XBOOTLDR Fixes #25417 --- diff --git a/src/shared/find-esp.c b/src/shared/find-esp.c index 6b460a27cb9..a4cadc7cbac 100644 --- a/src/shared/find-esp.c +++ b/src/shared/find-esp.c @@ -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 */ diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 83aa3fa6523..b65416b03bd 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -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; +} diff --git a/src/shared/mount-util.h b/src/shared/mount-util.h index 42a15b58008..ceb3964a748 100644 --- a/src/shared/mount-util.h +++ b/src/shared/mount-util.h @@ -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);