From: Anoop C S Date: Wed, 24 Aug 2022 09:31:31 +0000 (+0530) Subject: vfs_glusterfs: Implement SMB_VFS_FSTATAT X-Git-Tag: talloc-2.4.0~1280 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7c460b902800c0156385b2edb82efb07f561c51;p=thirdparty%2Fsamba.git vfs_glusterfs: Implement SMB_VFS_FSTATAT BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157 Signed-off-by: Anoop C S Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Aug 26 17:33:15 UTC 2022 on sn-devel-184 --- diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 3c309028c89..e2f9fbd8bd4 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1543,6 +1543,55 @@ static int vfs_gluster_fstat(struct vfs_handle_struct *handle, return ret; } +static int vfs_gluster_fstatat(struct vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + SMB_STRUCT_STAT *sbuf, + int flags) +{ + struct stat st; + int ret; + +#ifdef HAVE_GFAPI_VER_7_11 + glfs_fd_t *pglfd = NULL; + + START_PROFILE(syscall_fstatat); + + pglfd = vfs_gluster_fetch_glfd(handle, dirfsp); + if (pglfd == NULL) { + END_PROFILE(syscall_fstatat); + DBG_ERR("Failed to fetch gluster fd\n"); + return -1; + } + + ret = glfs_fstatat(pglfd, smb_fname->base_name, &st, flags); +#else + struct smb_filename *full_fname = NULL; + + START_PROFILE(syscall_fstatat); + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + END_PROFILE(syscall_fstatat); + return -1; + } + + ret = glfs_stat(handle->data, full_fname->base_name, &st); + + TALLOC_FREE(full_fname->base_name); +#endif + + if (ret == 0) { + smb_stat_ex_from_stat(sbuf, &st); + } + + END_PROFILE(syscall_fstatat); + + return ret; +} + static int vfs_gluster_lstat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname) { @@ -2641,6 +2690,7 @@ static struct vfs_fn_pointers glusterfs_fns = { .stat_fn = vfs_gluster_stat, .fstat_fn = vfs_gluster_fstat, + .fstatat_fn = vfs_gluster_fstatat, .lstat_fn = vfs_gluster_lstat, .get_alloc_size_fn = vfs_gluster_get_alloc_size, .unlinkat_fn = vfs_gluster_unlinkat,