From: Lennart Poettering Date: Mon, 9 Dec 2024 12:51:28 +0000 (+0100) Subject: btrfs-util: make sure btrfs_subvol_get_info_fd() works on O_PATH fds X-Git-Tag: v258-rc1~1833^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abeedbde90c9a64de656fa85a60ed8842eaa7dae;p=thirdparty%2Fsystemd.git btrfs-util: make sure btrfs_subvol_get_info_fd() works on O_PATH fds --- diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index e9a96cb3a21..9ae22d8aa56 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -329,6 +329,12 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) { assert(fd >= 0); assert(ret); + /* Make sure this works on O_PATH fds */ + _cleanup_close_ int fd_close = -EBADF; + fd = fd_reopen_condition(fd, O_CLOEXEC|O_RDONLY|O_DIRECTORY, O_PATH, &fd_close); + if (fd < 0) + return fd; + if (subvol_id == 0) { r = btrfs_subvol_get_id_fd(fd, &subvol_id); if (r < 0)