diff options
author | Lee Hanxue <hanxue.developer@gmail.com> | 2014-05-09 11:25:43 +0800 |
---|---|---|
committer | Lee Hanxue <hanxue.developer@gmail.com> | 2014-05-09 11:35:38 +0800 |
commit | e130b9acd6d2a7d2aa389cc982717edfe9fb56aa (patch) | |
tree | 99c7888ec946b1c1c811f12ce96c2ea1bada7dda | |
parent | 799cef8d964f60470cdfd6c9f816d2383a1817fd (diff) | |
download | bindfs-e130b9acd6d2a7d2aa389cc982717edfe9fb56aa.tar.gz |
Remove fuse utimens dependency for OSX
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/bindfs.c | 18 | ||||
-rw-r--r-- | src/misc.h | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 12 |
4 files changed, 30 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 0997c61..878b9ff 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,8 @@ if test x"$with_core_foundation" == "xyes" ; then LDFLAGS="${LDFLAGS} -framework CoreFoundation" fi +AM_CONDITIONAL(BUILD_OS_IS_DARWIN, [test x"$build_os" = darwin]) + my_CPPFLAGS="-D_REENTRANT -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" my_CFLAGS="$my_CFLAGS -Wall" my_LDFLAGS="-pthread" diff --git a/src/bindfs.c b/src/bindfs.c index 9348b2c..5f4b3c8 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -177,7 +177,11 @@ static int bindfs_chown(const char *path, uid_t uid, gid_t gid); static int bindfs_truncate(const char *path, off_t size); static int bindfs_ftruncate(const char *path, off_t size, struct fuse_file_info *fi); +#ifdef __APPLE__ +static int bindfs_utime(const char *path, struct utimbuf *buf); +#else static int bindfs_utimens(const char *path, const struct timespec tv[2]); +#endif static int bindfs_create(const char *path, mode_t mode, struct fuse_file_info *fi); static int bindfs_open(const char *path, struct fuse_file_info *fi); static int bindfs_read(const char *path, char *buf, size_t size, off_t offset, @@ -690,13 +694,21 @@ static int bindfs_ftruncate(const char *path, off_t size, return 0; } +#ifdef __APPLE__ +static int bindfs_utime(const char *path, struct utimbuf *buf) +#else static int bindfs_utimens(const char *path, const struct timespec tv[2]) +#endif { int res; path = process_path(path); + #ifdef __APPLE__ + res = utime(path, buf); + #else res = utimensat(settings.mntsrc_fd, path, tv, AT_SYMLINK_NOFOLLOW); + #endif if (res == -1) return -errno; @@ -906,7 +918,11 @@ static struct fuse_operations bindfs_oper = { .chown = bindfs_chown, .truncate = bindfs_truncate, .ftruncate = bindfs_ftruncate, + #ifdef __APPLE__ + .utime = bindfs_utime, + #else .utimens = bindfs_utimens, + #endif .create = bindfs_create, .open = bindfs_open, .read = bindfs_read, @@ -1599,6 +1615,8 @@ int main(int argc, char *argv[]) fuse_main_return = fuse_main(args.argc, args.argv, &bindfs_oper, NULL); + + fuse_opt_free_args(&args); close(settings.mntsrc_fd); @@ -17,6 +17,7 @@ along with bindfs. If not, see <http://www.gnu.org/licenses/>. */ + #ifndef INC_BINDFS_MISC_H #define INC_BINDFS_MISC_H diff --git a/tests/Makefile.am b/tests/Makefile.am index 8fc80ea..53a9081 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,13 @@ -noinst_PROGRAMS = readdir_inode utimens_nofollow -readdir_inode_SOURCES = readdir_inode.c -utimens_nofollow_SOURCES = utimens_nofollow.c +UNAME_S := $(shell uname -s) +if BUILD_OS_IS_DARWIN + noinst_PROGRAMS = readdir_inode + readdir_inode_SOURCES = readdir_inode.c +else + noinst_PROGRAMS = readdir_inode utimens_nofollow + readdir_inode_SOURCES = readdir_inode.c + utimens_nofollow_SOURCES = utimens_nofollow.c +endif TESTS = test_bindfs.rb SUBDIRS = internals |