Merge PR #34719 into master

* refs/pull/34719/head:
	ceph-fuse: compatible with libfuse3.5 or higher
	cmake: to get the header and library from specified path
	libfuse: check the libfuse version from the pkconfig/fuse{3}.pc file

Reviewed-by: Zheng Yan <zyan@redhat.com>
Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Patrick Donnelly 2020-06-02 17:46:26 -07:00
commit 2f82b45c44
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
5 changed files with 64 additions and 16 deletions

View File

@ -19,23 +19,46 @@ if(APPLE)
list(APPEND fuse_suffixes osxfuse)
endif()
find_path(
FUSE_INCLUDE_DIR
NAMES fuse_common.h fuse_lowlevel.h fuse.h
PATH_SUFFIXES ${fuse_suffixes})
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_search_module(PKG_FUSE QUIET ${fuse_names})
find_library(FUSE_LIBRARIES
NAMES ${fuse_names}
PATHS /usr/local/lib64 /usr/local/lib)
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}")
find_path(
FUSE_INCLUDE_DIR
NAMES fuse_common.h fuse_lowlevel.h fuse.h
HINTS ${PKG_FUSE_INCLUDE_DIRS}
PATH_SUFFIXES ${fuse_suffixes}
NO_DEFAULT_PATH)
find_library(FUSE_LIBRARIES
NAMES ${fuse_names}
HINTS ${PKG_FUSE_LIBDIR}
NO_DEFAULT_PATH)
else()
find_path(
FUSE_INCLUDE_DIR
NAMES fuse_common.h fuse_lowlevel.h fuse.h
PATH_SUFFIXES ${fuse_suffixes})
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_${ver}_VERSION "${fuse_ver_${ver}_line}")
endforeach()
endif()
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()
set(FUSE_VERSION
"${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}")
"${FUSE_MAJOR_VERSION}.${FUSE_MINOR_VERSION}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FUSE

View File

@ -44,6 +44,7 @@
#include <fuse.h>
#include <fuse_lowlevel.h>
#include "include/ceph_fuse.h"
#define dout_context g_ceph_context

View 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>
@ -640,7 +641,13 @@ static void fuse_ll_flush(fuse_req_t req, fuse_ino_t ino,
}
#ifdef FUSE_IOCTL_COMPAT
static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi,
static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino,
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 5)
unsigned int cmd,
#else
int cmd,
#endif
void *arg, struct fuse_file_info *fi,
unsigned flags, const void *in_buf, size_t in_bufsz, size_t out_bufsz)
{
CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);

View File

@ -15,8 +15,19 @@
#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,

View File

@ -90,6 +90,12 @@
/* 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