From 4f3862db82033c393b9565956b33fa88b9d982ee Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 23 Jul 2019 16:02:14 +0200 Subject: [PATCH] build: fix build with older versions of libfuse Signed-off-by: Giuseppe Scrivano --- configure.ac | 23 +++++++++++++++++++++++ main.c | 2 ++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 5ad5629..8a843e3 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,29 @@ AC_DEFINE([USE_DIFF_HASH], 1, [Use the same hashing function as GNU diff]) PKG_CHECK_MODULES([FUSE], [fuse3 >= 3.2.1], [AC_DEFINE([HAVE_FUSE], 1, [Define if libfuse is available])], [AC_MSG_ERROR([*** libfuse not found])]]) +old_CFLAGS=$CFLAGS +old_LDFLAGS=$LDFLAGS +CFLAGS=$pkg_cv_FUSE_CFLAGS +LDFLAGS=$pkg_cv_FUSE_LDFLAGS +AC_COMPILE_IFELSE( +[ +AC_LANG_SOURCE([ +#define FUSE_USE_VERSION 32 +#include +void foo() +{ + struct fuse_file_info fi; + fi.cache_readdir = 1; +}]) +], +[cache_readdir=1], +[cache_readdir=0]) +CFLAGS=$old_CFLAGS +LDFLAGS=$old_LDFLAGS + +AC_DEFINE_UNQUOTED([HAVE_FUSE_CACHE_READDIR], $cache_readdir, [Define if libfuse is available]) + + AC_FUNC_ERROR_AT_LINE AC_FUNC_MALLOC AC_CHECK_FUNCS([open_by_handle_at error memset strdup copy_file_range]) diff --git a/main.c b/main.c index 4b6b19e..45c3505 100644 --- a/main.c +++ b/main.c @@ -1744,7 +1744,9 @@ ovl_opendir (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) if (get_timeout (lo) > 0) { fi->keep_cache = 1; +#if HAVE_FUSE_CACHE_READDIR fi->cache_readdir = 1; +#endif } fuse_reply_open (req, fi); return;