From f52f71df3373185c4d18414aad57c4e8995a4393 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Sat, 22 Mar 2025 23:57:55 +0100 Subject: fuse: Fix want flag conversion 32-bit conn->want flags been left to be ABI compatible to 3.10, even though the so version was changed. The more recent way is to use fuse_set_feature_flag(), which will use conn->want_ext. Given that we now have two flags (want and want_ext), we need to convert and that brought several issues - If the application sets conn->want, that needs to be set into the lower 32 bit of conn->want_ext. As the application might actually unset values, it really has to be a copy and not just 'or' - fixed now. - convert_to_conn_want_ext() actually needs to check for _modified_ conn->want and conn->want_ext - convert_to_conn_want_ext() must consider being called from high and lowlevel interfact, with different want_ext_default and want_default values. It is only a failure, if the application changed both, conn->want and conn->want_ext. This function was failing in issue #1171, because high level fuse_fs_init() was changing values and then lowlevel do_init() was incorrectly failing on that. This also adds a new test (test_want_conversion) and sets values into example/{hello.c,hello_ll.c} Also some more internal users of conn->want are converted to fuse_{set,unset}_feature_flag(). Closes: https://github.com/libfuse/libfuse/issues/1171 Signed-off-by: Bernd Schubert (cherry picked from commit f68970cd235a7e14026ca0f6240428bbebe8223b) --- lib/util.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/util.h') diff --git a/lib/util.h b/lib/util.h index 74ce748..0c4c258 100644 --- a/lib/util.h +++ b/lib/util.h @@ -1,3 +1,30 @@ +#ifndef FUSE_UTIL_H_ +#define FUSE_UTIL_H_ + +#include + #define ROUND_UP(val, round_to) (((val) + (round_to - 1)) & ~(round_to - 1)) int libfuse_strtol(const char *str, long *res); + +/** + * Return the low bits of a number + */ +static inline uint32_t fuse_lower_32_bits(uint64_t nr) +{ + return (uint32_t)(nr & 0xffffffff); +} + +/** + * Return the high bits of a number + */ +static inline uint64_t fuse_higher_32_bits(uint64_t nr) +{ + return nr & ~0xffffffffULL; +} + +#ifndef FUSE_VAR_UNUSED +#define FUSE_VAR_UNUSED(var) (__attribute__((unused)) var) +#endif + +#endif -- cgit v1.2.3