mirror of
https://github.com/vgough/encfs.git
synced 2025-02-15 09:20:11 +01:00
use utimensat if available
This commit is contained in:
parent
e19f4a8c69
commit
ad43aa10b2
@ -83,9 +83,10 @@ check_cxx_source_compiles ("#include <sys/types.h>
|
|||||||
" XATTR_ADD_OPT)
|
" XATTR_ADD_OPT)
|
||||||
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
||||||
|
|
||||||
# Check if we have lchmod.
|
# Check if we have some standard functions.
|
||||||
include (CheckFuncs)
|
include (CheckFuncs)
|
||||||
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
||||||
|
check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
|
||||||
|
|
||||||
set (CMAKE_THREAD_PREFER_PTHREAD)
|
set (CMAKE_THREAD_PREFER_PTHREAD)
|
||||||
find_package (Threads REQUIRED)
|
find_package (Threads REQUIRED)
|
||||||
|
@ -497,6 +497,9 @@ int encfs_utime(const char *path, struct utimbuf *buf) {
|
|||||||
|
|
||||||
int _do_utimens(EncFS_Context *, const string &cyName,
|
int _do_utimens(EncFS_Context *, const string &cyName,
|
||||||
const struct timespec ts[2]) {
|
const struct timespec ts[2]) {
|
||||||
|
#ifdef HAVE_UTIMENSAT
|
||||||
|
int res = utimensat(AT_FDCWD, cyName.c_str(), ts, AT_SYMLINK_NOFOLLOW);
|
||||||
|
#else
|
||||||
struct timeval tv[2];
|
struct timeval tv[2];
|
||||||
tv[0].tv_sec = ts[0].tv_sec;
|
tv[0].tv_sec = ts[0].tv_sec;
|
||||||
tv[0].tv_usec = ts[0].tv_nsec / 1000;
|
tv[0].tv_usec = ts[0].tv_nsec / 1000;
|
||||||
@ -504,6 +507,7 @@ int _do_utimens(EncFS_Context *, const string &cyName,
|
|||||||
tv[1].tv_usec = ts[1].tv_nsec / 1000;
|
tv[1].tv_usec = ts[1].tv_nsec / 1000;
|
||||||
|
|
||||||
int res = lutimes(cyName.c_str(), tv);
|
int res = lutimes(cyName.c_str(), tv);
|
||||||
|
#endif
|
||||||
return (res == -1) ? -errno : ESUCCESS;
|
return (res == -1) ? -errno : ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user