aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2014-06-03 22:27:35 +0100
committerMartin Pärtel <martin.partel@gmail.com>2014-06-03 22:27:35 +0100
commit4bcdce164b4182f3acad9b075c7fd92898731f19 (patch)
treeed29132cd9fc6c4d76519f08f29aa07e430d9f41 /src
parenta93dd798d88277489374c45439384781a936cf78 (diff)
downloadbindfs-4bcdce164b4182f3acad9b075c7fd92898731f19.tar.gz
Fix --ctime-from-mtime accuracy.
Use struct stat's st_mtim instead of st_mtime when available. Fixes #16
Diffstat (limited to 'src')
-rw-r--r--src/bindfs.c10
1 files changed, 7 insertions, 3 deletions
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);