From: Anoop C S Date: Tue, 9 Jan 2024 05:41:40 +0000 (+0530) Subject: vfs_ceph: Implement SMB_VFS_FSTATAT X-Git-Tag: talloc-2.4.2~36 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=fe8d866d2c619a16cd114e06802efddea4d08e13;p=metze%2Fsamba-autobuild-v4-20-test%2F.git vfs_ceph: Implement SMB_VFS_FSTATAT Signed-off-by: Anoop C S Reviewed-by: Guenther Deschner Autobuild-User(master): Günther Deschner Autobuild-Date(master): Fri Jan 26 16:56:59 UTC 2024 on atb-devel-224 --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 88712e872a5..4387918198e 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -945,6 +945,51 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, S return result; } +static int cephwrap_fstatat(struct vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + SMB_STRUCT_STAT *sbuf, + int flags) +{ + int result = -1; + struct ceph_statx stx = { 0 }; +#ifdef HAVE_CEPH_STATXAT + int dirfd = fsp_get_pathref_fd(dirfsp); + + DBG_DEBUG("[CEPH] fstatat(%p, %d, %s)\n", + handle, dirfd, smb_fname->base_name); + result = ceph_statxat(handle->data, dirfd, smb_fname->base_name, + &stx, SAMBA_STATX_ATTR_MASK, 0); +#else + struct smb_filename *full_fname = NULL; + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + errno = ENOMEM; + return -1; + } + + DBG_DEBUG("[CEPH] fstatat(%p, %s)\n", + handle, smb_fname_str_dbg(full_fname)); + result = ceph_statx(handle->data, full_fname->base_name, + &stx, SAMBA_STATX_ATTR_MASK, 0); + + TALLOC_FREE(full_fname); +#endif + + DBG_DEBUG("[CEPH] fstatat(...) = %d\n", result); + if (result < 0) { + WRAP_RETURN(result); + } + + init_stat_ex_from_ceph_statx(sbuf, &stx); + DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode); + + return 0; +} + static int cephwrap_lstat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname) { @@ -1859,6 +1904,7 @@ static struct vfs_fn_pointers ceph_fns = { .stat_fn = cephwrap_stat, .fstat_fn = cephwrap_fstat, .lstat_fn = cephwrap_lstat, + .fstatat_fn = cephwrap_fstatat, .unlinkat_fn = cephwrap_unlinkat, .fchmod_fn = cephwrap_fchmod, .fchown_fn = cephwrap_fchown, diff --git a/source3/wscript b/source3/wscript index 060e8d3ffe0..b76ced59aa4 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1681,7 +1681,7 @@ int main(void) { headers='cephfs/libcephfs.h') conf.DEFINE('HAVE_MANDATORY_CEPH_API', '1') for api in ['ceph_mkdirat', 'ceph_openat', 'ceph_unlinkat', - 'ceph_symlinkat', 'ceph_readlinkat']: + 'ceph_symlinkat', 'ceph_readlinkat', 'ceph_statxat']: if not conf.CHECK_FUNCS_IN(api, 'cephfs', headers='cephfs/libcephfs.h'): conf.undefine('HAVE_MANDATORY_CEPH_API')