From d823cab63ad61a5b9ba09e6f4ccfd246572cd5e3 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Mon, 11 Apr 2022 12:02:54 +0200 Subject: 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. --- lib/fuse_loop_mt.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'lib') 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); -- cgit v1.2.1