]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libfuse: check the libfuse version from the pkconfig/fuse{3}.pc file
authorXiubo Li <xiubli@redhat.com>
Wed, 6 May 2020 00:43:12 +0000 (20:43 -0400)
committerNathan Cutler <ncutler@suse.com>
Sat, 6 Jun 2020 08:58:06 +0000 (10:58 +0200)
Since libfuse 3.2 to 3.8 the minor version for FUSE library has
stopped updating together with the releases. So we cannot check
version by using the FUSE_VERSION macro in the fuse_common.h header
file directly.

This will check the major/minor version from the fuse{3}.pc pkconfig
file.

Fixes: https://tracker.ceph.com/issues/45396
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 7a3cc61de03075ada0527f77b64d3456cb47e3a2)

cmake/modules/FindFUSE.cmake
src/ceph_fuse.cc
src/client/fuse_ll.cc
src/include/ceph_fuse.h
src/include/config-h.in.cmake

index 1d0766f33553442968d12c95724ae98fcc77476e..db489bdc1ad6a6346f83307f6b879a284a7c88fb 100644 (file)
@@ -28,14 +28,25 @@ find_library(FUSE_LIBRARIES
   NAMES ${fuse_names}
   PATHS /usr/local/lib64 /usr/local/lib)
 
-foreach(ver "MAJOR" "MINOR")
-  file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line
-    REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$")
-  string(REGEX REPLACE ".*#define[\t ]+FUSE_${ver}_VERSION[\t ]+([0-9]+)$"
-    "\\1" FUSE_VERSION_${ver} "${fuse_ver_${ver}_line}")
-endforeach()
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+  pkg_search_module(PKG_FUSE QUIET ${fuse_names})
+
+  string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)"
+    "\\1" FUSE_MAJOR_VERSION "${PKG_FUSE_VERSION}")
+  string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)"
+    "\\2" FUSE_MINOR_VERSION "${PKG_FUSE_VERSION}")
+else()
+  foreach(ver "MAJOR" "MINOR")
+    file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line
+      REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$")
+    string(REGEX REPLACE ".*#define[\t ]+FUSE_${ver}_VERSION[\t ]+([0-9]+)$"
+      "\\1" FUSE_${ver}_VERSION "${fuse_ver_${ver}_line}")
+  endforeach()
+endif()
+
 set(FUSE_VERSION
-  "${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}")
+  "${FUSE_MAJOR_VERSION}.${FUSE_MINOR_VERSION}")
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(FUSE
index 9d6141c1eaa4c5434b4d0174bbaffc53c100a6e0..2f8e3e4a41118a7d4477e6100b8b1145f88106f7 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <fuse.h>
 #include <fuse_lowlevel.h>
+#include "include/ceph_fuse.h"
 
 #define dout_context g_ceph_context
 
index 88afd05de51edb91081593025dcb934277a282ba..184950763b393cb8a0c3c01dab3d0e7b1a109c0b 100644 (file)
@@ -34,6 +34,7 @@
 #include "common/config.h"
 #include "include/ceph_assert.h"
 #include "include/cephfs/ceph_ll_client.h"
+#include "include/ceph_fuse.h"
 
 #include "fuse_ll.h"
 #include <fuse.h>
index 45881930b87b4eb15dfc6288df5aa2431401f60e..ae504f6715de476f56b8166f0f243ade7132b3e1 100644 (file)
 #define CEPH_FUSE_H
 
 #define FUSE_USE_VERSION 30
-#include "acconfig.h"
 #include <fuse.h>
+#include "acconfig.h"
+
+/*
+ * Redefine the FUSE_VERSION macro defined in "fuse_common.h"
+ * header file, because the MINOR numner has been forgotten to
+ * update since libfuse 3.2 to 3.8. We need to fetch the MINOR
+ * number from pkgconfig file.
+ */
+#ifdef FUSE_VERSION
+#undef FUSE_VERSION
+#define FUSE_VERSION FUSE_MAKE_VERSION(CEPH_FUSE_MAJOR_VERSION, CEPH_FUSE_MINOR_VERSION)
+#endif
 
 static inline int filler_compat(fuse_fill_dir_t filler,
                                 void *buf, const char *name,
index 1eb7807ed4acd992029261186bb90a3c2345fc32..6778155640f5fca749fc3b8512452f0f22888ef0 100644 (file)
 /* Define if you have fuse */
 #cmakedefine HAVE_LIBFUSE
 
+/* Define version major */
+#define CEPH_FUSE_MAJOR_VERSION @FUSE_MAJOR_VERSION@
+
+/* Define version minor */
+#define CEPH_FUSE_MINOR_VERSION @FUSE_MINOR_VERSION@
+
 /* Define to 1 if you have libxfs */
 #cmakedefine HAVE_LIBXFS 1