diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index affe06ec80..ba02de17f8 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)