aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac14
-rw-r--r--src/bindfs.c10
2 files changed, 21 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 085eeed..01c8248 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,20 @@ AC_SUBST([my_LDFLAGS])
AC_CHECK_FUNCS([lutimes utimensat])
AC_CHECK_FUNCS([setxattr getxattr listxattr removexattr])
AC_CHECK_FUNCS([lsetxattr lgetxattr llistxattr lremovexattr])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #define BSD_SOURCE_
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ void foo() { struct stat st; st.st_mtim.tv_nsec = 123; }
+ ]])],
+ [AC_DEFINE(
+ [HAVE_STAT_NANOSEC],
+ [1],
+ [Define if struct stat has st_mtim.tv_nsec etc.]
+ )]
+)
# Check for fuse
PKG_CHECK_MODULES([fuse], [fuse >= 2.6.0])
diff --git a/src/bindfs.c b/src/bindfs.c
index 1138592..67722a3 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -34,9 +34,8 @@
/* For >= 500 for pread/pwrite and readdir_r; >= 700 for utimensat */
#define _XOPEN_SOURCE 700
-#if !HAVE_UTIMENSAT && HAVE_LUTIMES
+/* For stat() nanosecond precision and lutimes() */
#define _BSD_SOURCE
-#endif
#include <stdlib.h>
#include <stddef.h>
@@ -253,8 +252,13 @@ static int getattr_common(const char *procpath, struct stat *stbuf)
/* Copy mtime (file content modification time)
to ctime (inode/status change time)
if the user asked for that */
- if (settings.ctime_from_mtime)
+ if (settings.ctime_from_mtime) {
+#ifdef HAVE_STAT_NANOSEC
+ stbuf->st_ctim = stbuf->st_mtim;
+#else
stbuf->st_ctime = stbuf->st_mtime;
+#endif
+ }
/* Possibly map user/group */
stbuf->st_uid = usermap_get_uid_or_default(settings.usermap, stbuf->st_uid, stbuf->st_uid);