From 5d84ad711a38a90587d033f5bad1943831bdcb82 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Tue, 13 Apr 2021 16:23:41 +0200 Subject: [PATCH] s3: VFS: fruit: Implement SMB_VFS_FNTIMES() Signed-off-by: Samuel Cabrero Reviewed-by: Ralph Boehme --- source3/modules/vfs_fruit.c | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index bba7597d8ad..77f999abba0 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3912,6 +3912,46 @@ exit: return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft); } +static int fruit_fntimes(vfs_handle_struct *handle, + files_struct *fsp, + struct smb_file_time *ft) +{ + int rc = 0; + struct adouble *ad = NULL; + struct fruit_config_data *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, + return -1); + + if ((config->meta != FRUIT_META_NETATALK) || + is_omit_timespec(&ft->create_time)) + { + return SMB_VFS_NEXT_FNTIMES(handle, fsp, ft); + } + + DBG_DEBUG("set btime for %s to %s\n", fsp_str_dbg(fsp), + time_to_asc(convert_timespec_to_time_t(ft->create_time))); + + ad = ad_fget(talloc_tos(), handle, fsp, ADOUBLE_META); + if (ad == NULL) { + goto exit; + } + + ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, + convert_time_t_to_uint32_t(ft->create_time.tv_sec)); + + rc = ad_fset(handle, ad, fsp); + +exit: + + TALLOC_FREE(ad); + if (rc != 0) { + DBG_WARNING("%s\n", fsp_str_dbg(fsp)); + return -1; + } + return SMB_VFS_NEXT_FNTIMES(handle, fsp, ft); +} + static int fruit_fallocate(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32_t mode, @@ -5210,6 +5250,7 @@ static struct vfs_fn_pointers vfs_fruit_fns = { .fstat_fn = fruit_fstat, .streaminfo_fn = fruit_streaminfo, .ntimes_fn = fruit_ntimes, + .fntimes_fn = fruit_fntimes, .ftruncate_fn = fruit_ftruncate, .fallocate_fn = fruit_fallocate, .create_file_fn = fruit_create_file, -- 2.47.3