The branch, master has been updated via dd2289eb3ae vfs_ceph: Implement SMB_VFS_FGET_DOS_ATTRIBUTES to preserve create_time via f3c185a6294 source3/smbd: Update timestamps after a successful SMB_VFS_FNTIMES from a3126ebfe57 lib: Use struct initialization in imessaging_client_init()
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit dd2289eb3ae83b6586493a14098a7e7eddc1ec63 Author: Anoop C S <anoo...@samba.org> Date: Thu Mar 21 16:49:04 2024 +0530 vfs_ceph: Implement SMB_VFS_FGET_DOS_ATTRIBUTES to preserve create_time In order to avoid the dependency on dos attribute for create_time we now preserve the btime before parsing dos attribute which may update btime from its value with an old one unless we explicitly reset dos attribute with new create_time in SMB_VFS_FNTIMES implementation. Therefore have an implementation for SMB_VFS_FGET_DOS_ATTRIBUTES to save and restore updated create_time. Signed-off-by: Anoop C S <anoo...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Anoop C S <anoo...@samba.org> Autobuild-Date(master): Mon Apr 1 15:24:39 UTC 2024 on atb-devel-224 commit f3c185a6294d4d92c43687a0ebe64f9cf59a4a2a Author: Anoop C S <anoo...@samba.org> Date: Fri Mar 22 11:38:08 2024 +0530 source3/smbd: Update timestamps after a successful SMB_VFS_FNTIMES When an open file handle is used to change timestamps we fail to return updated values to clients until next open is issued. Unless we fill in the timestamps subsequent calls like GETINFO cannot see the latest value causing incorrect results. Therefore copy those timestamp values as soon as it is set on the backend. Signed-off-by: Anoop C S <anoo...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/proto.h | 1 + source3/lib/system.c | 19 +++++++++++++++++++ source3/modules/vfs_ceph.c | 24 ++++++++++++++++++++++++ source3/smbd/dosmode.c | 8 +++++++- 4 files changed, 51 insertions(+), 1 deletion(-) Changeset truncated at 500 lines: diff --git a/source3/include/proto.h b/source3/include/proto.h index 389bb2fc935..d98bd3c09cb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -173,6 +173,7 @@ void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts); void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time); void update_stat_ex_from_saved_stat(struct stat_ex *dst, const struct stat_ex *src); +void copy_stat_ex_timestamps(files_struct *fsp, const struct smb_file_time *ft); int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf, bool fake_dir_create_times); int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf, diff --git a/source3/lib/system.c b/source3/lib/system.c index 1ec0ae9b1d5..2006edbed65 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -249,6 +249,25 @@ void update_stat_ex_from_saved_stat(struct stat_ex *dst, } } +void copy_stat_ex_timestamps(files_struct *fsp, const struct smb_file_time *ft) +{ + if (!is_omit_timespec(&ft->atime)) { + fsp->fsp_name->st.st_ex_atime = ft->atime; + } + + if (!is_omit_timespec(&ft->create_time)) { + fsp->fsp_name->st.st_ex_btime = ft->create_time; + } + + if (!is_omit_timespec(&ft->ctime)) { + fsp->fsp_name->st.st_ex_ctime = ft->ctime; + } + + if (!is_omit_timespec(&ft->mtime)) { + fsp->fsp_name->st.st_ex_mtime = ft->mtime; + } +} + void init_stat_ex_from_stat (struct stat_ex *dst, const struct stat *src, bool fake_dir_create_times) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index c9ee5414f03..6dae8a5f9e8 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -1569,6 +1569,29 @@ static const char *cephwrap_connectpath( return handle->conn->connectpath; } +static NTSTATUS cephwrap_fget_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 = fget_ea_dos_attribute(fsp, dosmode); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* + * Restore previously stored btime from statx timestamps as it should be + * the only source of truth. create_time from dos attribute, if any, may + * have older values which isn't trustworthy to be looked at for other + * open file handle operations. + */ + fsp->fsp_name->st.st_ex_btime = saved_btime; + + return NT_STATUS_OK; +} + /**************************************************************** Extended attribute operations. *****************************************************************/ @@ -1933,6 +1956,7 @@ static struct vfs_fn_pointers ceph_fns = { .fchflags_fn = cephwrap_fchflags, .get_real_filename_at_fn = cephwrap_get_real_filename_at, .connectpath_fn = cephwrap_connectpath, + .fget_dos_attributes_fn = cephwrap_fget_dos_attributes, /* EA operations. */ .getxattrat_send_fn = vfs_not_implemented_getxattrat_send, diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 4d897d6d7a1..674a13076e1 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -1189,7 +1189,8 @@ int file_ntimes(connection_struct *conn, } if (SMB_VFS_FNTIMES(fsp, ft) == 0) { - return 0; + ret = 0; + goto done; } if((errno != EPERM) && (errno != EACCES)) { @@ -1214,6 +1215,11 @@ int file_ntimes(connection_struct *conn, unbecome_root(); } +done: + if (ret == 0) { + copy_stat_ex_timestamps(fsp, ft); + } + return ret; } -- Samba Shared Repository