]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_glusterfs: Implement SMB_VFS_FSTATAT
authorAnoop C S <anoopcs@samba.org>
Wed, 24 Aug 2022 09:31:31 +0000 (15:01 +0530)
committerJeremy Allison <jra@samba.org>
Fri, 26 Aug 2022 17:33:15 +0000 (17:33 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Aug 26 17:33:15 UTC 2022 on sn-devel-184

source3/modules/vfs_glusterfs.c

index 3c309028c893773e545a1ca672bf42a75c4df9a7..e2f9fbd8bd4933b0e6ace30cd99773a2f7b7162d 100644 (file)
@@ -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,