]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph: Implement SMB_VFS_FSET_DOS_ATTRIBUTES for precise btime
authorAnoop C S <anoopcs@samba.org>
Fri, 17 May 2024 06:27:26 +0000 (11:57 +0530)
committerAnoop C S <anoopcs@samba.org>
Mon, 3 Jun 2024 11:10:11 +0000 (11:10 +0000)
Previously we added an implementation for SMB_VFS_FGET_DOS_ATTRIBUTES
so that the btime is always preserved unless explicitly changed using
SMB_VFS_FNTIMES. But there are situations with open file handle where
btime stored on dos attributes as create_time has to be precise for
comparison because a one-to-one conversion between timepsec and nttime
is not always guaranteed.

Accordingly preserve btime via SMB_VFS_FSET_DOS_ATTRIBUTES so that we
always compare the exact btime from fsp stat information while the file
handle is still open.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Mon Jun  3 11:10:11 UTC 2024 on atb-devel-224

source3/modules/vfs_ceph.c

index 1fb89e3e81ef599e63c224b98e69266cf6e8bba8..bb1650446c9669879033ab3cba6dd5b2d1ca7e6a 100644 (file)
@@ -1589,6 +1589,26 @@ static NTSTATUS cephwrap_fget_dos_attributes(struct vfs_handle_struct *handle,
        return status;
 }
 
+static NTSTATUS cephwrap_fset_dos_attributes(struct vfs_handle_struct *handle,
+                                            struct files_struct *fsp,
+                                            uint32_t dosmode)
+{
+       struct timespec saved_btime = fsp->fsp_name->st.st_ex_btime;
+       NTSTATUS status;
+
+       status = set_ea_dos_attribute(handle->conn, fsp->fsp_name, dosmode);
+
+       /*
+        * Restore previously stored btime from statx timestamps. This is done
+        * to ensure that we have the exact btime in fsp stat information while
+        * the file handle is still open since the create_time stored as part of
+        * dos attributes can loose its precision when converted back to btime.
+        */
+       fsp->fsp_name->st.st_ex_btime = saved_btime;
+
+       return status;
+}
+
 /****************************************************************
  Extended attribute operations.
 *****************************************************************/
@@ -1954,6 +1974,7 @@ static struct vfs_fn_pointers ceph_fns = {
        .get_real_filename_at_fn = cephwrap_get_real_filename_at,
        .connectpath_fn = cephwrap_connectpath,
        .fget_dos_attributes_fn = cephwrap_fget_dos_attributes,
+       .fset_dos_attributes_fn = cephwrap_fset_dos_attributes,
 
        /* EA operations. */
        .getxattrat_send_fn = vfs_not_implemented_getxattrat_send,