diff options
author | Bernd Schubert <bschubert@ddn.com> | 2024-09-19 15:03:55 +0200 |
---|---|---|
committer | Bernd Schubert <bernd.schubert@fastmail.fm> | 2024-11-13 16:43:59 +0100 |
commit | 15f5c811239abca80eda2d988be7a9a9848f7c10 (patch) | |
tree | efc000f312d984f5cd4282fef5353e2c66aa60a7 /lib/fuse_lowlevel.c | |
parent | 82cca94678e6b914e76bfb3fdb5ac176568fe0e1 (diff) | |
download | libfuse-15f5c811239abca80eda2d988be7a9a9848f7c10.tar.gz |
Add fuse_set_feature_flag() / fuse_unset_feature_flag
Simplify setting feature flags a bit by adding a helper
function.
Also move the check for valid flags into a funtion we can re-use
in a later patch.
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r-- | lib/fuse_lowlevel.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index ef1cda5..220a263 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -9,6 +9,7 @@ See the file COPYING.LIB */ +#include <stdbool.h> #define _GNU_SOURCE #include "fuse_config.h" @@ -1965,6 +1966,18 @@ static void do_lseek(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) fuse_reply_err(req, ENOSYS); } +static bool want_flags_valid(uint64_t capable, uint64_t want) +{ + uint64_t unknown_flags = want & (~capable); + if (unknown_flags != 0) { + fuse_log(FUSE_LOG_ERR, + "fuse: unknown connection 'want' flags: 0x%08lx\n", + unknown_flags); + return false; + } + return true; +} + /* Prevent bogus data races (bogus since "init" is called before * multi-threading becomes relevant */ static __attribute__((no_sanitize("thread"))) @@ -2121,10 +2134,7 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) if (se->op.init) se->op.init(se->userdata, &se->conn); - if (se->conn.want & (~se->conn.capable)) { - fuse_log(FUSE_LOG_ERR, "fuse: error: filesystem requested capabilities " - "0x%x that are not supported by kernel, aborting.\n", - se->conn.want & (~se->conn.capable)); + if (!want_flags_valid(se->conn.capable, se->conn.want)) { fuse_reply_err(req, EPROTO); se->error = -EPROTO; fuse_session_exit(se); |