s3: VFS: ceph: Implement SMB_VFS_FNTIMES()
authorSamuel Cabrero <scabrero@samba.org>
Tue, 13 Apr 2021 14:49:25 +0000 (16:49 +0200)
committerSamuel Cabrero <scabrero@sn-devel-184>
Mon, 19 Apr 2021 12:28:30 +0000 (12:28 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph.c

index d627a2233aee14b9efe56c9381da1404616725e7..92a8bd2e0583eb7f7ab2427032f40a5cc12d438c 100644 (file)
@@ -824,6 +824,57 @@ static int cephwrap_ntimes(struct vfs_handle_struct *handle,
        return result;
 }
 
+static int cephwrap_fntimes(struct vfs_handle_struct *handle,
+                           files_struct *fsp,
+                           struct smb_file_time *ft)
+{
+       struct ceph_statx stx = { 0 };
+       int result;
+       int mask = 0;
+
+       if (!is_omit_timespec(&ft->atime)) {
+               stx.stx_atime = ft->atime;
+               mask |= CEPH_SETATTR_ATIME;
+       }
+       if (!is_omit_timespec(&ft->mtime)) {
+               stx.stx_mtime = ft->mtime;
+               mask |= CEPH_SETATTR_MTIME;
+       }
+       if (!is_omit_timespec(&ft->create_time)) {
+               stx.stx_btime = ft->create_time;
+               mask |= CEPH_SETATTR_BTIME;
+       }
+
+       if (!mask) {
+               return 0;
+       }
+
+       if (!fsp->fsp_flags.is_pathref) {
+               /*
+                * We can use an io_fd to set xattrs.
+                */
+               result = ceph_fsetattrx(handle->data,
+                                       fsp_get_io_fd(fsp),
+                                       &stx,
+                                       mask);
+       } else {
+               /*
+                * This is no longer a handle based call.
+                */
+               result = ceph_setattrx(handle->data,
+                                      fsp->fsp_name->base_name,
+                                      &stx,
+                                      mask,
+                                      0);
+       }
+
+       DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n",
+                 handle, fsp_str_dbg(fsp), ft->mtime.tv_sec, ft->atime.tv_sec,
+                 ft->ctime.tv_sec, ft->create_time.tv_sec, result);
+
+       return result;
+}
+
 static int cephwrap_unlinkat(struct vfs_handle_struct *handle,
                        struct files_struct *dirfsp,
                        const struct smb_filename *smb_fname,
@@ -1582,6 +1633,7 @@ static struct vfs_fn_pointers ceph_fns = {
        .chdir_fn = cephwrap_chdir,
        .getwd_fn = cephwrap_getwd,
        .ntimes_fn = cephwrap_ntimes,
+       .fntimes_fn = cephwrap_fntimes,
        .ftruncate_fn = cephwrap_ftruncate,
        .fallocate_fn = cephwrap_fallocate,
        .lock_fn = cephwrap_lock,