]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph: call 'ceph_fgetxattr' only if valid fd
authorShachar Sharon <ssharon@redhat.com>
Thu, 16 Nov 2023 09:57:02 +0000 (11:57 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 30 Nov 2023 12:32:29 +0000 (12:32 +0000)
Align getxattr logic with the rest of xattr hooks: call ceph_fgetxattr
with appropriate io-fd when 'is_pathref' is false; otherwise, call
ceph_getxattr.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15440

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Thu Nov 30 12:32:29 UTC 2023 on atb-devel-224

source3/modules/vfs_ceph.c

index 6d252d204253838c9af9db152f12cf67d2c04cde..b1039ee36ef3a5005a7724da37baf3a8074fc2dc 100644 (file)
@@ -1431,11 +1431,32 @@ static const char *cephwrap_connectpath(
  Extended attribute operations.
 *****************************************************************/
 
-static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
+static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle,
+                                 struct files_struct *fsp,
+                                 const char *name,
+                                 void *value,
+                                 size_t size)
 {
        int ret;
-       DBG_DEBUG("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size));
-       ret = ceph_fgetxattr(handle->data, fsp_get_io_fd(fsp), name, value, size);
+       DBG_DEBUG("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n",
+                 handle,
+                 fsp,
+                 name,
+                 value,
+                 llu(size));
+       if (!fsp->fsp_flags.is_pathref) {
+               ret = ceph_fgetxattr(handle->data,
+                                    fsp_get_io_fd(fsp),
+                                    name,
+                                    value,
+                                    size);
+       } else {
+               ret = ceph_getxattr(handle->data,
+                                   fsp->fsp_name->base_name,
+                                   name,
+                                   value,
+                                   size);
+       }
        DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);