From f38d8de95d03073006d5f214b56de4d35af414c3 Mon Sep 17 00:00:00 2001 From: Janek Walkenhorst Date: Fri, 19 Nov 2010 09:21:42 +0100 Subject: [PATCH] try other methods if utimensat is not supported (returns ENOSYS) --- source3/modules/vfs_default.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 6e2a571..11e257f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -135,14 +135,26 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, * See what filetime set primitives we have. */ #if defined(HAVE_UTIMENSAT) + struct timespec ts[2]; + ts[0].tv_sec = 0; + ts[0].tv_nsec = UTIME_OMIT; + ts[1] = ts[0]; + if (!(utimensat(AT_FDCWD, "/", ts, AT_SYMLINK_NOFOLLOW) == -1 && errno == ENOSYS)) { *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER; -#elif defined(HAVE_UTIMES) + } else { + DEBUG(0,("vfswrap_fs_capabilities: utimensat returns ENOSYS. " + "never us a glibc which is much more recent than your kernel.\n")); +#else + { +#endif +#if defined(HAVE_UTIMES) /* utimes allows msec timestamps to be set. */ *p_ts_res = TIMESTAMP_SET_MSEC; #elif defined(HAVE_UTIME) /* utime only allows sec timestamps to be set. */ *p_ts_res = TIMESTAMP_SET_SECONDS; #endif + } DEBUG(10,("vfswrap_fs_capabilities: timestamp " "resolution of %s " @@ -541,14 +553,18 @@ 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) + if (result == -1 && errno == ENOSYS) /* try other methods if utimensat is not supported */ +#endif +#if defined(HAVE_UTIMES) { struct timeval tv[2]; @@ -568,6 +584,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 +916,10 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, } else { result = utimensat(AT_FDCWD, smb_fname->base_name, NULL, 0); } -#elif defined(HAVE_UTIMES) + if (result == -1 && errno == ENOSYS) /* try other methods if utimensat is not supported */ +#endif +{ +#if defined(HAVE_UTIMES) if (ft != NULL) { struct timeval tv[2]; tv[0] = convert_timespec_to_timeval(ft->atime); @@ -920,6 +941,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, errno = ENOSYS; result = -1; #endif +} out: END_PROFILE(syscall_ntimes); -- 1.5.6.5