diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-04-14 12:47:47 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-04-14 13:15:35 +0200 |
commit | 92851defbd9ec1b4216b01d55e36fccc4b1b5dc6 (patch) | |
tree | 0ba7bd48f8b95ad12e8c68194f85024b386e589e | |
parent | 13524b29a2833675518b5d5701344196429cb924 (diff) | |
download | systemd-92851defbd9ec1b4216b01d55e36fccc4b1b5dc6.tar.gz |
mountpoint-util: pass AT_STATX_DONT_SYNC to statx() when looking for mnt_id/mountpoints
The concept of a "mount" is a local one, hence there's no point in going
to the network to retrieve mnt_id or STATX_ATTR_MOUNT_ROOT. Hence set
AT_STATX_DONT_SYNC so that the call will not go to the network ever, and
risk deadlocking on that.
Just some extra safety.
-rw-r--r-- | src/basic/mountpoint-util.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 751d5a35ce..b00108783b 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -213,9 +213,14 @@ int fd_is_mount_point(int fd, const char *filename, int flags) { * reported. Also, btrfs subvolumes have different st_dev, even though they aren't real mounts of * their own. */ - if (statx(fd, filename, (FLAGS_SET(flags, AT_SYMLINK_FOLLOW) ? 0 : AT_SYMLINK_NOFOLLOW) | - (flags & AT_EMPTY_PATH) | - AT_NO_AUTOMOUNT, STATX_TYPE, &sx) < 0) { + if (statx(fd, + filename, + (FLAGS_SET(flags, AT_SYMLINK_FOLLOW) ? 0 : AT_SYMLINK_NOFOLLOW) | + (flags & AT_EMPTY_PATH) | + AT_NO_AUTOMOUNT | /* don't trigger automounts – mounts are a local concept, hence no need to trigger automounts to determine STATX_ATTR_MOUNT_ROOT */ + AT_STATX_DONT_SYNC, /* don't go to the network for this – for similar reasons */ + STATX_TYPE, + &sx) < 0) { if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) return -errno; @@ -360,7 +365,9 @@ int path_get_mnt_id_at(int dir_fd, const char *path, int *ret) { if (statx(dir_fd, path, - AT_NO_AUTOMOUNT|(isempty(path) ? AT_EMPTY_PATH : AT_SYMLINK_NOFOLLOW), + (isempty(path) ? AT_EMPTY_PATH : AT_SYMLINK_NOFOLLOW) | + AT_NO_AUTOMOUNT | /* don't trigger automounts, mnt_id is a local concept */ + AT_STATX_DONT_SYNC, /* don't go to the network, mnt_id is a local concept */ STATX_MNT_ID, &buf.sx) < 0) { if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) |