aboutsummaryrefslogtreecommitdiff
path: root/example/hello_ll.c
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-02 11:30:43 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-02 13:56:40 -0700
commit5698ee09cf7a8495da70659ffae1eaec9f57db27 (patch)
tree798a58a4f49d7f82e3f948463daad4405173483e /example/hello_ll.c
parentf164e9b8ca319dd1279384ff495b5fa91e778d9e (diff)
Turn struct fuse_chan into an implementation detail
The only struct fuse_chan that's accessible to the user application is the "master" channel that is returned by fuse_mount and stored in struct fuse_session. When using the multi-threaded main loop with the "clone_fd" option, each worker thread gets its own struct fuse_chan. However, none of these are available to the user application, nor do they hold references to struct fuse_session (the pointer is always null). Therefore, any presence of struct fuse_chan can be removed without loss of functionality by relying on struct fuse_session instead. This reduces the number of API functions and removes a potential source of confusion (since the new API no longer looks as if it might be possible to add multiple channels to one session, or to share one channel between multiple sessions). Fixes issue #17.
Diffstat (limited to 'example/hello_ll.c')
-rwxr-xr-xexample/hello_ll.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/example/hello_ll.c b/example/hello_ll.c
index 528b216..07529d1 100755
--- a/example/hello_ll.c
+++ b/example/hello_ll.c
@@ -186,31 +186,35 @@ static struct fuse_lowlevel_ops hello_ll_oper = {
int main(int argc, char *argv[])
{
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
- struct fuse_chan *ch;
+ struct fuse_session *se;
char *mountpoint;
int err = -1;
- if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
- (ch = fuse_session_mount(mountpoint, &args)) != NULL) {
- struct fuse_session *se;
-
- se = fuse_session_new(&args, &hello_ll_oper,
- sizeof(hello_ll_oper), NULL);
- if (se != NULL) {
- if (fuse_set_signal_handlers(se) != -1) {
- fuse_session_add_chan(se, ch);
-
- /* Block until ctrl+c or fusermount -u */
- err = fuse_session_loop(se);
-
- fuse_remove_signal_handlers(se);
- fuse_session_remove_chan(ch);
- }
- fuse_session_destroy(se);
- }
- fuse_session_unmount(mountpoint, ch);
- }
+ if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != 0)
+ goto err_out;
+
+ se = fuse_session_new(&args, &hello_ll_oper,
+ sizeof(hello_ll_oper), NULL);
fuse_opt_free_args(&args);
+ if (se == NULL)
+ goto err_out;
+
+ if (fuse_set_signal_handlers(se) != 0)
+ goto err_out1;
+
+ if (fuse_session_mount(se, mountpoint) != 0)
+ goto err_out2;
+
+ /* Block until ctrl+c or fusermount -u */
+ err = fuse_session_loop(se);
+
+ fuse_session_unmount(se);
+err_out2:
+ fuse_remove_signal_handlers(se);
+err_out1:
+ fuse_session_destroy(se);
+err_out:
+ free(mountpoint);
return err ? 1 : 0;
}