]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: use low-level APIs for lstat
authorShachar Sharon <ssharon@redhat.com>
Mon, 17 Jun 2024 12:57:42 +0000 (15:57 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:36 +0000 (14:51 +0000)
Use libcephfs' low-level APIs and apply the same logic as stat, but
using AT_SYMLINK_NOFOLLOW flags.

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 1b22a0026c33939041773a98d5021c9f3f0f6fb0..97f4dcfb0792ed8c30ce9a67a59e0af52f6ea7d9 100644 (file)
@@ -493,6 +493,17 @@ static int vfs_ceph_iget_by_fname(const struct vfs_handle_struct *handle,
        return ret;
 }
 
+static int vfs_ceph_igetl(const struct vfs_handle_struct *handle,
+                         const struct smb_filename *smb_fname,
+                         struct vfs_ceph_iref *iref)
+{
+       return vfs_ceph_iget(handle,
+                            0,
+                            smb_fname->base_name,
+                            AT_SYMLINK_NOFOLLOW,
+                            iref);
+}
+
 static void vfs_ceph_iput(const struct vfs_handle_struct *handle,
                          struct vfs_ceph_iref *iref)
 {
@@ -1181,10 +1192,10 @@ static int vfs_ceph_fstatat(struct vfs_handle_struct *handle,
 }
 
 static int vfs_ceph_lstat(struct vfs_handle_struct *handle,
-                        struct smb_filename *smb_fname)
+                         struct smb_filename *smb_fname)
 {
        int result = -1;
-       struct ceph_statx stx = { 0 };
+       struct vfs_ceph_iref iref = {0};
 
        DBG_DEBUG("[CEPH] lstat(%p, %s)\n",
                  handle,
@@ -1195,15 +1206,19 @@ static int vfs_ceph_lstat(struct vfs_handle_struct *handle,
                return result;
        }
 
-       result = ceph_statx(handle->data, smb_fname->base_name, &stx,
-                               SAMBA_STATX_ATTR_MASK, AT_SYMLINK_NOFOLLOW);
-       DBG_DEBUG("[CEPH] lstat(...) = %d\n", result);
-       if (result < 0) {
-               return status_code(result);
+       result = vfs_ceph_igetl(handle, smb_fname, &iref);
+       if (result != 0) {
+               goto out;
        }
 
-       init_stat_ex_from_ceph_statx(&smb_fname->st, &stx);
-       return result;
+       result = vfs_ceph_ll_getattr(handle, &iref, &smb_fname->st);
+       if (result != 0) {
+               goto out;
+       }
+out:
+       vfs_ceph_iput(handle, &iref);
+       DBG_DEBUG("[CEPH] lstat(...) = %d\n", result);
+       return status_code(result);
 }
 
 static int vfs_ceph_fntimes(struct vfs_handle_struct *handle,