From fc95fd5076fd845e496bfbcec1ad9da16534b1c9 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Sat, 4 Jan 2025 23:18:14 +0100 Subject: Make fuse_main_real() not symboled Addresses https://github.com/libfuse/libfuse/issues/1092 We actually don't need to make fuse_main_real() symboled, as it is not part of the official API. The inlined function now always calls into fuse_main_real_317 and the compat ABI function (which should also be available for dlopen/dlsym) is now always compiled, independent if the compiler/linker support versioned symbols. Additionally, fuse_main_real() is also declared as inlined function and a warning message is created when that function is called. Signed-off-by: Bernd Schubert --- include/fuse.h | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/fuse.h b/include/fuse.h index c3add84..969ed97 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -877,21 +877,32 @@ struct fuse_context { mode_t umask; }; -#if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS)) /** * The real main function * * Do not call this directly, use fuse_main() */ -int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, - size_t op_size, struct libfuse_version *version, - void *user_data); -#else -int fuse_main_real_317(int argc, char *argv[], const struct fuse_operations *op, - size_t op_size, struct libfuse_version *version, void *user_data); -#define fuse_main_real(argc, argv, op, op_size, version, user_data) \ - fuse_main_real_317(argc, argv, op, op_size, version, user_data); -#endif +static inline int fuse_main_real(int argc, char *argv[], + const struct fuse_operations *op, + size_t op_size, void *user_data) +{ + struct libfuse_version version = { .major = FUSE_MAJOR_VERSION, + .minor = FUSE_MINOR_VERSION, + .hotfix = FUSE_HOTFIX_VERSION, + .padding = 0 }; + + fuse_log(FUSE_LOG_ERR, + "%s is a libfuse internal function, please use fuse_main()\n", + __func__); + + /* not declared globally, to restrict usage of this function */ + int fuse_main_real_317(int argc, char *argv[], + const struct fuse_operations *op, size_t op_size, + struct libfuse_version *version, + void *user_data); + + return fuse_main_real_317(argc, argv, op, op_size, &version, user_data); +} /** * Main function of FUSE. @@ -957,8 +968,14 @@ fuse_main(int argc, char *argv[], const struct fuse_operations *op, .hotfix = FUSE_HOTFIX_VERSION, .padding = 0 }; - return fuse_main_real(argc, argv, op, sizeof(*(op)), &version, - user_data); + + /* not declared globally, to restrict usage of this function */ + int fuse_main_real_317(int argc, char *argv[], + const struct fuse_operations *op, size_t op_size, + struct libfuse_version *version, + void *user_data); + return fuse_main_real_317(argc, argv, op, sizeof(*(op)), &version, + user_data); } /* ----------------------------------------------------------- * -- cgit v1.2.3