stat-util: Make sure we trigger automounts when looking for ESP/XBOOTLDR

Fixes #25417
This commit is contained in:
Daan De Meyer
2023-06-29 15:38:35 +02:00
committed by Luca Boccassi
parent 06afda6b38
commit 506c1bb594
3 changed files with 23 additions and 0 deletions

View 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 */

View 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;
}

View 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);