From e6d1d4c0b31275c4394676bce4f9bc28e3fad5a5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 29 Nov 2022 15:31:50 +0100 Subject: [PATCH] btrfs-util: convert O_PATH if necessary, in btrfs quota call Fixes: #25468 --- src/shared/btrfs-util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index affe06ec800..ba02de17f85 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -1765,6 +1765,7 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) { int btrfs_subvol_auto_qgroup_fd(int fd, uint64_t subvol_id, bool insert_intermediary_qgroup) { _cleanup_free_ uint64_t *qgroups = NULL; + _cleanup_close_ int real_fd = -1; uint64_t parent_subvol; bool changed = false; int n = 0, r; @@ -1808,6 +1809,11 @@ int btrfs_subvol_auto_qgroup_fd(int fd, uint64_t subvol_id, bool insert_intermed * qgroup that then includes all its own child subvolumes. */ + /* Turn this into a proper fd, if it is currently O_PATH */ + fd = fd_reopen_condition(fd, O_RDONLY|O_CLOEXEC, O_PATH, &real_fd); + if (fd < 0) + return fd; + if (subvol_id == 0) { r = btrfs_is_subvol_fd(fd); if (r < 0) -- 2.47.3