Uses futimesat in Solaris.

This commit is contained in:
Andrea Mazzoleni 2012-10-07 21:12:03 +02:00
parent 8373233f25
commit 06637e9264
3 changed files with 17 additions and 3 deletions

View file

@ -17,6 +17,7 @@ SnapRAID HISTORY
This a safe measure to be 100% sure to always detect file changes.
* Always fill the memory after allocating it to avoid the OOM (Out Of Memory)
killer in Linux.
* Fixed compilation in Solaris for lacking both futimes() and futimens().
1.12 2012/9
=============

View file

@ -48,7 +48,8 @@ dnl Checks for library functions.
AC_SYS_LARGEFILE
AC_CHECK_FUNCS([memset strchr strerror strrchr mkdir gettimeofday strtoul])
AC_CHECK_FUNCS([getopt getopt_long snprintf vsnprintf])
AC_CHECK_FUNCS([ftruncate fallocate fsync access posix_fallocate posix_fadvise pread pwrite getc_unlocked ferror_unlocked fnmatch futimes futimens])
AC_CHECK_FUNCS([ftruncate fallocate fsync access posix_fallocate posix_fadvise pread pwrite getc_unlocked ferror_unlocked fnmatch])
AC_CHECK_FUNCS([futimes futimens futimesat])
dnl Checks for architecture
AC_C_BIGENDIAN

View file

@ -338,7 +338,7 @@ int handle_utime(struct snapraid_handle* handle)
if (handle->f == -1)
return 0;
#if HAVE_FUTIMENS /* futimens is preferred because it gives nanosecond precision */
#if HAVE_FUTIMENS /* futimens() is preferred because it gives nanosecond precision */
tv[0].tv_sec = handle->file->mtime_sec;
if (handle->file->mtime_nsec != FILE_MTIME_NSEC_INVALID)
tv[0].tv_nsec = handle->file->mtime_nsec;
@ -348,7 +348,7 @@ int handle_utime(struct snapraid_handle* handle)
tv[1].tv_nsec = tv[0].tv_nsec;
ret = futimens(handle->f, tv);
#else
#elif HAVE_FUTIMES /* fallback to futimes() if nanosecond precision is not available */
tv[0].tv_sec = handle->file->mtime_sec;
if (handle->file->mtime_nsec != FILE_MTIME_NSEC_INVALID)
tv[0].tv_usec = handle->file->mtime_nsec / 1000;
@ -358,6 +358,18 @@ int handle_utime(struct snapraid_handle* handle)
tv[1].tv_usec = tv[0].tv_usec;
ret = futimes(handle->f, tv);
#elif HAVE_FUTIMESAT /* fallback to futimesat() for Solaris, it only has futimesat() */
tv[0].tv_sec = handle->file->mtime_sec;
if (handle->file->mtime_nsec != FILE_MTIME_NSEC_INVALID)
tv[0].tv_usec = handle->file->mtime_nsec / 1000;
else
tv[0].tv_usec = 0;
tv[1].tv_sec = tv[0].tv_sec;
tv[1].tv_usec = tv[0].tv_usec;
ret = futimesat(handle->f, 0, tv);
#else
#error No function available to set file timestamps
#endif
if (ret != 0) {