diff --git a/configure.ac b/configure.ac index d271698d..e4342038 100644 --- a/configure.ac +++ b/configure.ac @@ -280,6 +280,7 @@ AC_STRUCT_ST_BLOCKS AC_CHECK_MEMBERS([struct stat.st_rdev]) AC_CHECK_MEMBERS([struct stat.st_atim]) AC_CHECK_MEMBERS([struct stat.st_atimespec]) +AC_CHECK_MEMBERS([struct stat.st_atimensec]) # For the 'nfconv' patch (Mac OS X only): case "${target_os}" in diff --git a/include/ntfs-3g/ntfstime.h b/include/ntfs-3g/ntfstime.h index e20492fb..236c0fb4 100644 --- a/include/ntfs-3g/ntfstime.h +++ b/include/ntfs-3g/ntfstime.h @@ -39,7 +39,7 @@ /* * assume "struct timespec" is not defined if st_mtime is not defined */ -#ifndef st_mtime +#if !defined(st_mtime) & !defined(__timespec_defined) struct timespec { time_t tv_sec; long tv_nsec; diff --git a/libfuse-lite/fuse_misc.h b/libfuse-lite/fuse_misc.h index 99e5117a..86309896 100644 --- a/libfuse-lite/fuse_misc.h +++ b/libfuse-lite/fuse_misc.h @@ -36,6 +36,12 @@ static inline void fuse_mutex_init(pthread_mutex_t *mut) #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec) #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val) #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val) +#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) +#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimensec) +#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimensec) +#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimensec) +#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimensec = (val) +#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimensec = (val) #else #define ST_ATIM_NSEC(stbuf) 0 #define ST_CTIM_NSEC(stbuf) 0 diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index 02d0afd3..e87654f1 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -774,8 +774,32 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx, stbuf->st_atim = ntfs2timespec(ni->last_access_time); stbuf->st_ctim = ntfs2timespec(ni->last_mft_change_time); stbuf->st_mtim = ntfs2timespec(ni->last_data_change_time); +#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) + { + struct timespec ts; + + ts = ntfs2timespec(ni->last_access_time); + stbuf->st_atime = ts.tv_sec; + stbuf->st_atimensec = ts.tv_nsec; + ts = ntfs2timespec(ni->last_mft_change_time); + stbuf->st_ctime = ts.tv_sec; + stbuf->st_ctimensec = ts.tv_nsec; + ts = ntfs2timespec(ni->last_data_change_time); + stbuf->st_mtime = ts.tv_sec; + stbuf->st_mtimensec = ts.tv_nsec; + } #else - #error "No known timespec member in struct stat!" +#warning "No known way to set nanoseconds in struct stat !" + { + struct timespec ts; + + ts = ntfs2timespec(ni->last_access_time); + stbuf->st_atime = ts.tv_sec; + ts = ntfs2timespec(ni->last_mft_change_time); + stbuf->st_ctime = ts.tv_sec; + ts = ntfs2timespec(ni->last_data_change_time); + stbuf->st_mtime = ts.tv_sec; + } #endif exit: return (res); diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 1c7489f4..8ab4ecce 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -870,8 +870,32 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) stbuf->st_atim = ntfs2timespec(ni->last_access_time); stbuf->st_ctim = ntfs2timespec(ni->last_mft_change_time); stbuf->st_mtim = ntfs2timespec(ni->last_data_change_time); +#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) + { + struct timespec ts; + + ts = ntfs2timespec(ni->last_access_time); + stbuf->st_atime = ts.tv_sec; + stbuf->st_atimensec = ts.tv_nsec; + ts = ntfs2timespec(ni->last_mft_change_time); + stbuf->st_ctime = ts.tv_sec; + stbuf->st_ctimensec = ts.tv_nsec; + ts = ntfs2timespec(ni->last_data_change_time); + stbuf->st_mtime = ts.tv_sec; + stbuf->st_mtimensec = ts.tv_nsec; + } #else - #error "No known timespec member in struct stat!" +#warning "No known way to set nanoseconds in struct stat !" + { + struct timespec ts; + + ts = ntfs2timespec(ni->last_access_time); + stbuf->st_atime = ts.tv_sec; + ts = ntfs2timespec(ni->last_mft_change_time); + stbuf->st_ctime = ts.tv_sec; + ts = ntfs2timespec(ni->last_data_change_time); + stbuf->st_mtime = ts.tv_sec; + } #endif exit: if (ntfs_inode_close(ni))