mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Uses futimesat in Solaris.
This commit is contained in:
parent
8373233f25
commit
06637e9264
3 changed files with 17 additions and 3 deletions
1
HISTORY
1
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
|
||||
=============
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
16
handle.c
16
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue