summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Schubert <bschubert@ddn.com>2022-04-11 12:02:54 +0200
committerNikolaus Rath <Nikolaus@rath.org>2022-09-04 13:07:15 +0100
commitd823cab63ad61a5b9ba09e6f4ccfd246572cd5e3 (patch)
tree18a3b2e6c570fb4312ad7f3488d90f7305de48e1
parentaf5710e7a3ad42e1b64ee8882fd72b22ffe271ac (diff)
downloadfuse-d823cab63ad61a5b9ba09e6f4ccfd246572cd5e3.tar.gz
fuse_session_loop_mt: Accept a NULL config - use defaults
If an application does not want to bother with the session and wants to keep defaults, it can now just pass a NULL as config parameter.
-rw-r--r--include/fuse.h2
-rw-r--r--lib/fuse_loop_mt.c31
2 files changed, 25 insertions, 8 deletions
diff --git a/include/fuse.h b/include/fuse.h
index 917a91c..9897c85 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -1041,7 +1041,7 @@ int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
* in the callback function of fuse_operations is also thread-safe.
*
* @param f the FUSE handle
- * @param config loop configuration
+ * @param config loop configuration, may be NULL and defaults will be used then
* @return see fuse_session_loop()
*
* See also: fuse_loop()
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c
index 9ec1fb2..6002e19 100644
--- a/lib/fuse_loop_mt.c
+++ b/lib/fuse_loop_mt.c
@@ -328,10 +328,18 @@ int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *c
int err;
struct fuse_mt mt;
struct fuse_worker *w;
+ int created_config = 0;
+
+ if (config) {
+ err = fuse_loop_cfg_verify(config);
+ if (err)
+ return err;
+ } else {
+ /* The caller does not care about parameters - use the default */
+ config = fuse_loop_cfg_create();
+ created_config = 1;
+ }
- err = fuse_loop_cfg_verify(config);
- if (err)
- return err;
memset(&mt, 0, sizeof(struct fuse_mt));
mt.se = se;
@@ -372,6 +380,11 @@ int err;
err = se->error;
fuse_session_reset(se);
+ if (created_config) {
+ fuse_loop_cfg_destroy(config);
+ config = NULL;
+ }
+
return err;
}
@@ -380,12 +393,16 @@ FUSE_SYMVER("fuse_session_loop_mt_32", "fuse_session_loop_mt@FUSE_3.2")
int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config_v1 *config_v1)
{
int err;
+ struct fuse_loop_config *config = NULL;
- struct fuse_loop_config *config = fuse_loop_cfg_create();
- if (config == NULL)
- return ENOMEM;
+ if (config_v1 != NULL) {
+ /* convert the given v1 config */
+ config = fuse_loop_cfg_create();
+ if (config == NULL)
+ return ENOMEM;
- fuse_loop_cfg_convert(config, config_v1);
+ fuse_loop_cfg_convert(config, config_v1);
+ }
err = fuse_session_loop_mt_312(se, config);