From f9c29169bb1a09ee1a7c19ddc0faa56ebf59ac9a Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Sun, 16 Jun 2013 14:32:54 +0200 Subject: [PATCH] fix freebsd build based on bugmen0t input --- configure.ac | 1 + src/simple-mtpfs-fuse.cpp | 7 ++++++- src/simple-mtpfs-fuse.h | 1 + src/simple-mtpfs-mtp-device.cpp | 5 +++-- src/simple-mtpfs-type-dir.cpp | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 7d84090..8505b0f 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ m4_include([m4/cxx11.m4]) AX_CXX_COMPILE_STDCXX_11([noext]) AC_CHECK_LIB([mtp], [LIBMTP_Init], [], [AC_MSG_ERROR([libmtp not found])]) AC_CHECK_HEADERS([libmtp.h]) +AC_CHECK_FUNCS([fdatasync]) PKG_CHECK_MODULES([FUSE], [fuse >= 2.8]) AC_SUBST([FUSE_CFLAGS]) diff --git a/src/simple-mtpfs-fuse.cpp b/src/simple-mtpfs-fuse.cpp index b2706da..1ed3881 100644 --- a/src/simple-mtpfs-fuse.cpp +++ b/src/simple-mtpfs-fuse.cpp @@ -584,7 +584,12 @@ int SMTPFileSystem::flush(const char *path, struct fuse_file_info *file_info) int SMTPFileSystem::fsync(const char *path, int datasync, struct fuse_file_info *fi) { - return datasync ? ::fdatasync(fi->fh) : ::fsync(fi->fh); +#ifdef HAVE_FDATASYNC + if (datasync) + return ::fdatasync(fi->fh); + else +#endif + return ::fsync(fi->fh); } int SMTPFileSystem::opendir(const char *path, struct fuse_file_info *file_info) diff --git a/src/simple-mtpfs-fuse.h b/src/simple-mtpfs-fuse.h index 3ac6302..dc0d51e 100644 --- a/src/simple-mtpfs-fuse.h +++ b/src/simple-mtpfs-fuse.h @@ -20,6 +20,7 @@ #include #include +#include extern "C" { # include } diff --git a/src/simple-mtpfs-mtp-device.cpp b/src/simple-mtpfs-mtp-device.cpp index 763672a..e9a57cd 100644 --- a/src/simple-mtpfs-mtp-device.cpp +++ b/src/simple-mtpfs-mtp-device.cpp @@ -24,6 +24,7 @@ extern "C" { # include # include +# define _DARWIN_USE_64_BIT_INODE # include } #include "simple-mtpfs-fuse.h" @@ -449,8 +450,8 @@ int MTPDevice::filePush(const std::string &src, const std::string &dst) } } - struct stat64 file_stat; - stat64(src.c_str(), &file_stat); + struct stat file_stat; + stat(src.c_str(), &file_stat); TypeFile file_to_upload(0, dir_parent->id(), dir_parent->storageid(), dst_basename, static_cast(file_stat.st_size), 0); LIBMTP_file_t *f = file_to_upload.toLIBMTPFile(); diff --git a/src/simple-mtpfs-type-dir.cpp b/src/simple-mtpfs-type-dir.cpp index 47689a0..df2ab17 100644 --- a/src/simple-mtpfs-type-dir.cpp +++ b/src/simple-mtpfs-type-dir.cpp @@ -17,6 +17,7 @@ #include #include +#include #include extern "C" { # include