conn->want conversion: Fix fuse_apply_conn_info_opts()

fuse_apply_conn_info_opts() was applying to 'want_ext',
which would cause conflicts with 'want' if the application
applied its own flags to 'conn->want'.

Solution is:
    - to move fuse_{set,unset,get}_feature_flag and
      convert_to_conn_want_ext() to fuse_lowlevel.c and
      to define them as part of the public API, although
      convert_to_conn_want_ext() should not be used - it is
      currently needed to be a public function due as it needs
      to be defined for the tests.

Related to https://github.com/libfuse/libfuse/issues/1171 and
https://github.com/libfuse/libfuse/pull/1172.

Closes: https://github.com/libfuse/libfuse/issues/1171
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
This commit is contained in:
Bernd Schubert
2025-05-18 00:24:07 +02:00
committed by Bernd Schubert
parent eadd6a5454
commit baadab0492
9 changed files with 187 additions and 106 deletions
+31 -19
View File
@@ -1107,28 +1107,40 @@ void fuse_loop_cfg_convert(struct fuse_loop_config *config,
struct fuse_loop_config_v1 *v1_conf);
#endif
/**
* Set a feature flag in the want_ext field of fuse_conn_info.
*
* @param conn connection information
* @param flag feature flag to be set
* @return true if the flag was set, false if the flag is not supported
*/
bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
static inline bool fuse_set_feature_flag(struct fuse_conn_info *conn,
uint64_t flag)
{
if (conn->capable_ext & flag) {
conn->want_ext |= flag;
return true;
}
return false;
}
/**
* Unset a feature flag in the want_ext field of fuse_conn_info.
*
* @param conn connection information
* @param flag feature flag to be unset
*/
void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
/**
* Get the value of a feature flag in the want_ext field of fuse_conn_info.
*
* @param conn connection information
* @param flag feature flag to be checked
* @return true if the flag is set, false otherwise
*/
bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
/*
* DO NOT USE: Not part of public API, for internal test use only.
* The function signature or any use of it is not guaranteeed to
* remain stable. And neither are results of what this function does.
*/
int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn);
static inline void fuse_unset_feature_flag(struct fuse_conn_info *conn,
uint64_t flag)
{
conn->want_ext &= ~flag;
}
static inline bool fuse_get_feature_flag(struct fuse_conn_info *conn,
uint64_t flag)
{
return conn->capable_ext & flag ? true : false;
}
/* ----------------------------------------------------------- *
* Compatibility stuff *