From: Shachar Sharon Date: Mon, 17 Jun 2024 12:57:42 +0000 (+0300) Subject: vfs_ceph_new: use low-level APIs for lstat X-Git-Tag: tdb-1.4.12~79 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93d786b14358db5664e13b1aa43f3f03e7cf0be3;p=thirdparty%2Fsamba.git vfs_ceph_new: use low-level APIs for lstat 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 Reviewed-by: Guenther Deschner Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 1b22a0026c3..97f4dcfb079 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -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,