+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
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=
#include <stdint.h>
#include <fcntl.h>
+#include <sys/types.h>
/**
* Perform POSIX locking operation
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
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);
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);
}
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
}
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
}
}
#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
#include <pthread.h>
#include <errno.h>
#include <assert.h>
+#include <signal.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/wait.h>