]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mountpoint-util: use the FID stuff for detecting the root of mounts
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Jun 2024 10:44:19 +0000 (12:44 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2024 13:45:15 +0000 (15:45 +0200)
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.

src/basic/mountpoint-util.c

index 71979d29ad5ea2436f27b38df6448134d4a4b37f..c9cf1bcdac3e7739363dffa0e1e808ca714b5f31 100644 (file)
@@ -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;