From c7c2a8fc3853cf5205e952ca94635a7f054efcce Mon Sep 17 00:00:00 2001 From: Janek Walkenhorst Date: Wed, 17 Nov 2010 16:23:39 +0100 Subject: [PATCH] try other methods if utimensat is not supported (returns ENOSYS) --- source3/modules/vfs_default.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 6e2a571..12b7907 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -541,14 +541,19 @@ static int copy_reg(const char *source, const char *dest) /* Try to copy the old file's modtime and access time. */ #if defined(HAVE_UTIMENSAT) + int result; { struct timespec ts[2]; ts[0] = source_stats.st_ex_atime; ts[1] = source_stats.st_ex_mtime; + result = utimensat(AT_FDCWD, dest, ts, AT_SYMLINK_NOFOLLOW); } -#elif defined(HAVE_UTIMES) + /* try other methods if utimensat is not supported */ + if (result == -1 && errno == ENOSYS) +#endif +#if defined(HAVE_UTIMES) { struct timeval tv[2]; @@ -568,6 +573,8 @@ static int copy_reg(const char *source, const char *dest) tv.modtime = convert_timespec_to_time_t(source_stats.st_ex_mtime); utime(dest, &tv); } +#else + {} #endif if (unlink (source) == -1) @@ -898,7 +905,11 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, } else { result = utimensat(AT_FDCWD, smb_fname->base_name, NULL, 0); } -#elif defined(HAVE_UTIMES) + /* try other methods if utimensat is not supported */ + if (result == -1 && errno == ENOSYS) +#endif +{ +#if defined(HAVE_UTIMES) if (ft != NULL) { struct timeval tv[2]; tv[0] = convert_timespec_to_timeval(ft->atime); @@ -920,6 +931,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, errno = ENOSYS; result = -1; #endif +} out: END_PROFILE(syscall_ntimes); -- 1.5.6.5