Support for nanosec times on FBSD and other FBSD fixes
authorCsaba Henk <csaba.henk@creo.hu>
Sun, 24 Sep 2006 14:53:29 +0000 (14:53 +0000)
committerCsaba Henk <csaba.henk@creo.hu>
Sun, 24 Sep 2006 14:53:29 +0000 (14:53 +0000)
ChangeLog
configure.in
include/ulockmgr.h
lib/fuse.c
lib/fuse_lowlevel.c
lib/fuse_misc.h
lib/ulockmgr.c

index 7cd502365332023d88c367d5d616fef6ede415b7..7a53ceae1dee9c5c3d54c04239333f35e7320092 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-24  Csaba Henk <csaba.henk@creo.hu>
+
+       * Add support for nanosec times on FreeBSD
+
+       * Fix FreeBSD compatibility issues
+
 2006-09-22  Miklos Szeredi <miklos@szeredi.hu>
 
        * Fix compatibility bugs in low level interface.  Reported by
index f21326ef0c530e279f180b70bd5a91f81b3cdf1c..a20f2b7ddee01ae356cbcaa4dfbe114fa07f91d7 100644 (file)
@@ -60,6 +60,7 @@ if test "$enable_mtab" = "no"; then
 fi
 AC_CHECK_FUNCS([fork setxattr fdatasync])
 AC_CHECK_MEMBERS([struct stat.st_atim])
+AC_CHECK_MEMBERS([struct stat.st_atimespec])
 
 libfuse_libs=-pthread
 LIBS=
index 4cd7b1c08cd15d712fb68b8d5be98577633e2cde..dfdde0112f118775320740b5c76d7491f56661e6 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <stdint.h>
 #include <fcntl.h>
+#include <sys/types.h>
 
 /**
  * Perform POSIX locking operation
index 16eb7ada39c85671716f1e5407d2027c14c48a6d..14789b7589f51fa55f7e48c317b99ea8fca68e05 100644 (file)
@@ -702,16 +702,16 @@ static int hide_node(struct fuse *f, fuse_req_t req, const char *oldpath,
 static int mtime_eq(const struct stat *stbuf, const struct timespec *ts)
 {
     return stbuf->st_mtime == ts->tv_sec
-#ifdef HAVE_STRUCT_STAT_ST_ATIM
-        && stbuf->st_mtim.tv_nsec == ts->tv_nsec
+#ifdef FUSE_STAT_HAS_NANOSEC
+        && ST_MTIM(stbuf).tv_nsec == ts->tv_nsec
 #endif
         ;
 }
 
 static void mtime_set(const struct stat *stbuf, struct timespec *ts)
 {
-#ifdef HAVE_STRUCT_STAT_ST_ATIM
-    *ts = stbuf->st_mtim;
+#ifdef FUSE_STAT_HAS_NANOSEC
+    *ts = ST_MTIM(stbuf);
 #else
     ts->tv_sec = stbuf->st_mtime;
 #endif
@@ -1027,8 +1027,15 @@ static int do_utimens(struct fuse *f, fuse_req_t req, const char *path,
     err = -ENOSYS;
     if (f->op.utimens) {
         struct timespec tv[2];
-        tv[0] = attr->st_atim;
-        tv[1] = attr->st_mtim;
+#ifdef FUSE_STAT_HAS_NANOSEC
+        tv[0] = ST_ATIM(attr);
+        tv[1] = ST_MTIM(attr);
+#else
+        tv[0].tv_sec = attr->st_atime;
+        tv[0].tv_nsec = 0;
+        tv[1].tv_sec = attr->st_mtime;
+        tv[1].tv_nsec = 0;
+#endif
         fuse_prepare_interrupt(f, req, &d);
         err = f->op.utimens(path, tv);
         fuse_finish_interrupt(f, req, &d);
@@ -2973,7 +2980,7 @@ static int fuse_compat_opendir(struct fuse *f, fuse_req_t req, char *path,
     return fuse_do_opendir(f, req, path, fi);
 }
 
-static int fuse_do_statfs(struct fuse *f, fuse_req_t req, struct statvfs *buf)
+static int fuse_compat_statfs(struct fuse *f, fuse_req_t req, struct statvfs *buf)
 {
     return fuse_do_statfs(f, req, "/", buf);
 }
index 27a3d204546e99eb68ff4a48f7ba0cc20f506e03..f014e6e4dd2c85f4b512dadd6a0fba651c1a3277 100644 (file)
@@ -72,10 +72,10 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr)
     attr->atime     = stbuf->st_atime;
     attr->mtime     = stbuf->st_mtime;
     attr->ctime     = stbuf->st_ctime;
-#ifdef HAVE_STRUCT_STAT_ST_ATIM
-    attr->atimensec = stbuf->st_atim.tv_nsec;
-    attr->mtimensec = stbuf->st_mtim.tv_nsec;
-    attr->ctimensec = stbuf->st_ctim.tv_nsec;
+#ifdef FUSE_STAT_HAS_NANOSEC
+    attr->atimensec = ST_ATIM(stbuf).tv_nsec;
+    attr->mtimensec = ST_MTIM(stbuf).tv_nsec;
+    attr->ctimensec = ST_CTIM(stbuf).tv_nsec;
 #endif
 }
 
@@ -87,9 +87,9 @@ static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
     stbuf->st_size         = attr->size;
     stbuf->st_atime        = attr->atime;
     stbuf->st_mtime        = attr->mtime;
-#ifdef HAVE_STRUCT_STAT_ST_ATIM
-    stbuf->st_atim.tv_nsec = attr->atimensec;
-    stbuf->st_mtim.tv_nsec = attr->mtimensec;
+#ifdef FUSE_STAT_HAS_NANOSEC
+    ST_ATIM(stbuf).tv_nsec = attr->atimensec;
+    ST_MTIM(stbuf).tv_nsec = attr->mtimensec;
 #endif
 }
 
index 3a026558fa65d3422f1864dd0dbec4aeb91a7913..57a1e37045a25a91e17dc0d2ce61eb335f1d0d79 100644 (file)
@@ -22,6 +22,16 @@ static inline void fuse_mutex_init(pthread_mutex_t *mut)
 }
 #endif
 
-
-
-
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
+/* Linux */
+#define ST_ATIM(stbuf) (stbuf)->st_atim
+#define ST_CTIM(stbuf) (stbuf)->st_ctim
+#define ST_MTIM(stbuf) (stbuf)->st_mtim
+#define FUSE_STAT_HAS_NANOSEC 1 
+#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
+/* FreeBSD */
+#define ST_ATIM(stbuf) (stbuf)->st_atimespec
+#define ST_CTIM(stbuf) (stbuf)->st_ctimespec
+#define ST_MTIM(stbuf) (stbuf)->st_mtimespec
+#define FUSE_STAT_HAS_NANOSEC 1
+#endif
index 795fc41974495b4391b058e300d3409818bcdae3..012a45073d49eceac77ec3a3cbb7099797a996db 100644 (file)
@@ -16,6 +16,7 @@
 #include <pthread.h>
 #include <errno.h>
 #include <assert.h>
+#include <signal.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/wait.h>