]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
btrfs-util: convert O_PATH if necessary, in btrfs quota call 25561/head
authorLennart Poettering <lennart@poettering.net>
Tue, 29 Nov 2022 14:31:50 +0000 (15:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 29 Nov 2022 14:35:06 +0000 (15:35 +0100)
Fixes: #25468
src/shared/btrfs-util.c

index affe06ec8006353e8e962e095d2da97de10276be..ba02de17f8523876c54e790ba59393f4f025e276 100644 (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)