mirror of
https://github.com/vgough/encfs.git
synced 2025-02-08 22:11:19 +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)
|
||||
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
||||
|
||||
# Check if we have lchmod.
|
||||
# Check if we have some standard functions.
|
||||
include (CheckFuncs)
|
||||
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
||||
check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
|
||||
|
||||
set (CMAKE_THREAD_PREFER_PTHREAD)
|
||||
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,
|
||||
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];
|
||||
tv[0].tv_sec = ts[0].tv_sec;
|
||||
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;
|
||||
|
||||
int res = lutimes(cyName.c_str(), tv);
|
||||
#endif
|
||||
return (res == -1) ? -errno : ESUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user