vfs_glusterfs: allow path based ops without glfd in vfs_gluster_fchown()
authorRalph Boehme <slow@samba.org>
Fri, 8 Dec 2023 18:58:08 +0000 (19:58 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 8 Dec 2023 18:58:08 +0000 (19:58 +0100)
source3/modules/vfs_glusterfs.c

index 47bdba39f30440c7289fc8a43daad859143e84fc..8259d9ce632517fc36cdb41d8acd34089643624e 100644 (file)
@@ -1721,18 +1721,28 @@ static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
                              files_struct *fsp, uid_t uid, gid_t gid)
 {
        int ret;
-       glfs_fd_t *glfd = NULL;
 
        START_PROFILE(syscall_fchown);
 
-       glfd = vfs_gluster_fetch_glfd(handle, fsp);
-       if (glfd == NULL) {
-               END_PROFILE(syscall_fchown);
-               DBG_ERR("Failed to fetch gluster fd\n");
-               return -1;
+       if (!fsp->fsp_flags.is_pathref) {
+               glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+               if (glfd == NULL) {
+                       END_PROFILE(syscall_fchown);
+                       DBG_ERR("Failed to fetch gluster fd\n");
+                       return -1;
+               }
+
+               ret = glfs_fchown(glfd, uid, gid);
+       } else {
+               /*
+                * This is no longer a handle based call.
+                */
+               ret = glfs_chown(handle->data,
+                                fsp->fsp_name->base_name,
+                                uid,
+                                gid);
        }
 
-       ret = glfs_fchown(glfd, uid, gid);
        END_PROFILE(syscall_fchown);
 
        return ret;