diff --git a/HISTORY b/HISTORY index b87096cf..5c960d4a 100644 --- a/HISTORY +++ b/HISTORY @@ -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 ============= diff --git a/configure.ac b/configure.ac index 53165d79..6e1531a6 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/handle.c b/handle.c index ed1ee176..731b58b1 100644 --- a/handle.c +++ b/handle.c @@ -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) {