Skip to content

Instantly share code, notes, and snippets.

@kivikakk
Created February 12, 2019 02:25
Show Gist options
  • Save kivikakk/fabd775ceecbf4380757833080a6b278 to your computer and use it in GitHub Desktop.
Save kivikakk/fabd775ceecbf4380757833080a6b278 to your computer and use it in GitHub Desktop.
FUSE 2 -- applies to github/libprojfs@35a3da8
diff --git a/configure.ac b/configure.ac
index 3eb59ee..05e5d82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,15 +153,33 @@ AC_SEARCH_LIBS([fsetxattr], [attr], [],
[AC_MSG_ERROR([Extended attributes library not found])]dnl
)dnl
+AC_DEFINE(_FILE_OFFSET_BITS, 64)
+
# TODO: remove when FUSE no longer used (also Libs.private in projfs.pc)
-AC_CHECK_HEADER([fuse3/fuse.h], [],
- [AC_MSG_ERROR([FUSE version 3.2+ header file not found])],
- [@%:@define FUSE_USE_VERSION 32]dnl
+AC_CHECK_HEADERS([fuse.h], [], [], [@%:@define _FILE_OFFSET_BITS 64])
+AC_CHECK_HEADERS([fuse3/fuse.h], [], [], [@%:@define FUSE_USE_VERSION 32])
+
+AS_IF([test ":$ac_cv_header_fuse_h" = ":no" &&
+ test ":$ac_cv_header_fuse3_fuse_h" = ":no"],
+ [AC_MSG_ERROR([neither FUSE 2 nor FUSE 3 header found])])
+
+AS_IF(
+ [test ":$ac_cv_header_fuse_h" = ":yes"],
+ [
+ AC_SEARCH_LIBS([fuse_loop_mt], [fuse], [],
+ [AC_MSG_ERROR([FUSE 2 not linkable])]dnl
)dnl
+ ])
+
+AS_IF(
+ [test ":$ac_cv_header_fuse3_fuse_h" = ":yes"],
+ [
# NOTE: checking for fuse_loop_mt_31() ensures libfuse version 3.2 or higher
+ # TODO: loosen this
AC_SEARCH_LIBS([fuse_loop_mt_31], [fuse3], [],
[AC_MSG_ERROR([FUSE version 3.2+ library not found])]dnl
)dnl
+ ])
AC_CONFIG_FILES([Makefile include/Makefile lib/Makefile t/Makefile
config.sh projfs.pc])
diff --git a/include/projfs.h b/include/projfs.h
index 5abdf37..cb94ba1 100644
--- a/include/projfs.h
+++ b/include/projfs.h
@@ -32,8 +32,15 @@
#include "projfs_notify.h"
// TODO: remove when not needed
+#ifdef HAVE_FUSE3_FUSE_H
#define FUSE_USE_VERSION 32
#include <fuse3/fuse_lowlevel.h>
+#endif
+
+#ifdef HAVE_FUSE_h
+#define FUSE_USE_VERSION 26
+#include <fuse/fuse_lowlevel.h>
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/lib/projfs.c b/lib/projfs.c
index 4e9864c..46e9810 100644
--- a/lib/projfs.c
+++ b/lib/projfs.c
@@ -39,7 +39,15 @@
#include "projfs.h"
#include "projfs_i.h"
+#ifdef HAVE_FUSE3_FUSE_H
+#define FUSE_USE_VERSION 32
#include <fuse3/fuse.h>
+#endif
+
+#ifdef HAVE_FUSE_H
+#define FUSE_USE_VERSION 26
+#include <fuse/fuse.h>
+#endif
#ifdef PROJFS_VFSAPI
#include "projfs_vfsapi.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment