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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user