]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: use low-level APIs for readdir ops
authorShachar Sharon <ssharon@redhat.com>
Mon, 24 Jun 2024 10:33:05 +0000 (13:33 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:37 +0000 (14:51 +0000)
Implement readdir and rewinddir operations using libcephfs' low-level
APIs. Casts the opaque DIR pointer into struct vfs_ceph_dirp (the first
member of struct vfs_ceph_fh) to resolve the ceph_dir_result pointer
which libcephfs expects for readdir operations.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_ceph_new.c

index 6ca80893afbe34f27c8f85985ecf24fd097f0557..9259d597ffba7b4d84ef5adb603723921361f32a 100644 (file)
@@ -720,6 +720,18 @@ static int vfs_ceph_ll_opendir(const struct vfs_handle_struct *handle,
                               cfh->uperm);
 }
 
+static struct dirent *vfs_ceph_ll_readdir(const struct vfs_handle_struct *hndl,
+                                         const struct vfs_ceph_fh *dircfh)
+{
+       return ceph_readdir(cmount_of(hndl), dircfh->dirp.cdr);
+}
+
+static void vfs_ceph_ll_rewinddir(const struct vfs_handle_struct *handle,
+                                 const struct vfs_ceph_fh *dircfh)
+{
+       ceph_rewinddir(cmount_of(handle), dircfh->dirp.cdr);
+}
+
 static int vfs_ceph_ll_mkdirat(const struct vfs_handle_struct *handle,
                               const struct vfs_ceph_fh *dircfh,
                               const char *name,
@@ -971,11 +983,11 @@ static struct dirent *vfs_ceph_readdir(struct vfs_handle_struct *handle,
                                       struct files_struct *dirfsp,
                                       DIR *dirp)
 {
+       const struct vfs_ceph_fh *dircfh = (const struct vfs_ceph_fh *)dirp;
        struct dirent *result = NULL;
 
        DBG_DEBUG("[CEPH] readdir(%p, %p)\n", handle, dirp);
-       result = ceph_readdir(cmount_of(handle),
-                             (struct ceph_dir_result *)dirp);
+       result = vfs_ceph_ll_readdir(handle, dircfh);
        DBG_DEBUG("[CEPH] readdir(...) = %p\n", result);
 
        return result;
@@ -983,8 +995,10 @@ static struct dirent *vfs_ceph_readdir(struct vfs_handle_struct *handle,
 
 static void vfs_ceph_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
 {
+       const struct vfs_ceph_fh *dircfh = (const struct vfs_ceph_fh *)dirp;
+
        DBG_DEBUG("[CEPH] rewinddir(%p, %p)\n", handle, dirp);
-       ceph_rewinddir(cmount_of(handle), (struct ceph_dir_result *)dirp);
+       vfs_ceph_ll_rewinddir(handle, dircfh);
 }
 
 static int vfs_ceph_mkdirat(struct vfs_handle_struct *handle,