From 4bcdce164b4182f3acad9b075c7fd92898731f19 Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Tue, 3 Jun 2014 22:27:35 +0100 Subject: Fix --ctime-from-mtime accuracy. Use struct stat's st_mtim instead of st_mtime when available. Fixes #16 --- src/bindfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') 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 #include @@ -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); -- cgit v1.2.3