From: Lennart Poettering Date: Tue, 25 Jun 2024 10:44:19 +0000 (+0200) Subject: mountpoint-util: use the FID stuff for detecting the root of mounts X-Git-Tag: v257-rc1~1003^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c39ab9b402bd87ed590c8781e9c30d786178a12;p=thirdparty%2Fsystemd.git mountpoint-util: use the FID stuff for detecting the root of mounts In the unlikely event that sandboxes block statx() but let name_to_handle_at() through it's a good way to determine the root inode of the namespace, since its parent inode will have the same FID and mnt_id. --- diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 71979d29ad5..c9cf1bcdac3 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -276,7 +276,7 @@ int fd_is_mount_point(int fd, const char *filename, int flags) { else if (FLAGS_SET(sx.stx_mask, STATX_TYPE) && S_ISLNK(sx.stx_mode)) return false; /* symlinks are never mount points */ - r = name_to_handle_at_loop(fd, filename, &h, &mount_id, flags); + r = name_to_handle_at_try_fid(fd, filename, &h, &mount_id, flags); if (r < 0) { if (is_name_to_handle_at_fatal_error(r)) return r; @@ -290,9 +290,9 @@ int fd_is_mount_point(int fd, const char *filename, int flags) { } if (isempty(filename)) - r = name_to_handle_at_loop(fd, "..", &h_parent, &mount_id_parent, 0); /* can't work for non-directories 😢 */ + r = name_to_handle_at_try_fid(fd, "..", &h_parent, &mount_id_parent, 0); /* can't work for non-directories 😢 */ else - r = name_to_handle_at_loop(fd, "", &h_parent, &mount_id_parent, AT_EMPTY_PATH); + r = name_to_handle_at_try_fid(fd, "", &h_parent, &mount_id_parent, AT_EMPTY_PATH); if (r < 0) { if (is_name_to_handle_at_fatal_error(r)) return r;