btrfs-util: convert O_PATH if necessary, in btrfs quota call

Fixes: #25468
This commit is contained in:
Lennart Poettering
2022-11-29 15:35:06 +01:00
parent 698bc1861e
commit e6d1d4c0b3
+6
View File
@@ -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)