phatina / simple-mtpfs

Simple MTP fuse filesystem driver.
GNU General Public License v2.0
371 stars 45 forks source link

doesnt build on freebsd #6

Closed bugmen0t closed 11 years ago

bugmen0t commented 11 years ago

fdatasync(2) is not available on freebsd and dragonfly

simple-mtpfs-fuse.cpp:586:25: error: no member named 'fdatasync' in the global
      namespace
    return datasync ? ::fdatasync(fi->fh) : ::fsync(fi->fh);
                      ~~^
1 error generated.
diff --git a/configure.ac b/configure.ac
index 7d84090..c09d8b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,7 @@ AC_PROG_INSTALL

 m4_include([m4/cxx11.m4])
 AX_CXX_COMPILE_STDCXX_11([noext])
+AC_CHECK_FUNCS([fdatasync])
 AC_CHECK_LIB([mtp], [LIBMTP_Init], [], [AC_MSG_ERROR([libmtp not found])])
 AC_CHECK_HEADERS([libmtp.h])
 PKG_CHECK_MODULES([FUSE], [fuse >= 2.8])
diff --git a/src/simple-mtpfs-fuse.cpp b/src/simple-mtpfs-fuse.cpp
index 1a20dc3..58acd1c 100644
--- a/src/simple-mtpfs-fuse.cpp
+++ b/src/simple-mtpfs-fuse.cpp
@@ -583,7 +583,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)

stat64 is deprecated on OS X

simple-mtpfs-mtp-device.cpp:448:19: error: variable has incomplete type
      'struct stat64'
    struct stat64 file_stat;
                  ^
simple-mtpfs-mtp-device.cpp:448:12: note: forward declaration of 'stat64'
    struct stat64 file_stat;
           ^
1 error generated.
diff --git a/src/simple-mtpfs-mtp-device.cpp b/src/simple-mtpfs-mtp-device.cpp
index 0280fd7..4e85d77 100644
--- a/src/simple-mtpfs-mtp-device.cpp
+++ b/src/simple-mtpfs-mtp-device.cpp
@@ -24,6 +24,7 @@
 extern "C" {
 #  include <unistd.h>
 #  include <sys/types.h>
+#  define _DARWIN_USE_64_BIT_INODE
 #  include <sys/stat.h>
 }
 #include "simple-mtpfs-fuse.h"
@@ -445,8 +446,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<uint64_t>(file_stat.st_size), 0);
     LIBMTP_file_t *f = file_to_upload.toLIBMTPFile();

malloc/free scope vs. clang33/gcc48

In file included from simple-mtpfs-main.cpp:20:0:
simple-mtpfs-fuse.h: In destructor 'SMTPFileSystem::SMTPFileSystemOptions::~SMTPFileSystemOptions()':
simple-mtpfs-fuse.h:59:70: error: 'free' was not declared in this scope
         ~SMTPFileSystemOptions() { free(static_cast<void*>(m_tmp_dir)); }
                                                                      ^
simple-mtpfs-type-dir.cpp:67:9: error: use of undeclared identifier 'malloc'
        malloc(sizeof(LIBMTP_folder_t)));
        ^
simple-mtpfs-type-file.cpp:54:9: error: use of undeclared identifier 'malloc'
        malloc(sizeof(LIBMTP_file_t)));
        ^
diff --git a/src/simple-mtpfs-fuse.h b/src/simple-mtpfs-fuse.h
index 2f7b1ad..f78cb1e 100644
--- a/src/simple-mtpfs-fuse.h
+++ b/src/simple-mtpfs-fuse.h
@@ -18,6 +18,7 @@
 #ifndef SMTPFS_FUSE_H
 #define SMTPFS_FUSE_H

+#include <cstdlib>
 #include <memory>
 #include <string>
 extern "C" {
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 <config.h>
 #include <algorithm>
+#include <cstdlib>
 #include <cstring>
 extern "C" {
 #  include <libmtp.h>
diff --git a/src/simple-mtpfs-type-file.cpp b/src/simple-mtpfs-type-file.cpp
index 3d03220..5ec2785 100644
--- a/src/simple-mtpfs-type-file.cpp
+++ b/src/simple-mtpfs-type-file.cpp
@@ -16,6 +16,7 @@
 * ***** END LICENSE BLOCK ***** */

 #include <config.h>
+#include <cstdlib>
 #include "simple-mtpfs-type-file.h"

 TypeFile::TypeFile():
phatina commented 11 years ago

Looks good, during a weekend, I will process this. Thank you!

phatina commented 11 years ago

Pushed.

bugmen0t commented 11 years ago

Still doesn't build.

$ gmake
...
simple-mtpfs-type-file.cpp:54:9: error: use of undeclared identifier 'malloc'
        malloc(sizeof(LIBMTP_file_t)));
        ^
1 error generated.
phatina commented 11 years ago

Ah, I forgot to add that file into the commit. It should be there.