From 8198eb4b6fcf31b15984a9cd0f1d00695d3b9d91 Mon Sep 17 00:00:00 2001 From: Oded Arbel Date: Wed, 29 Aug 2018 19:20:56 +0300 Subject: [PATCH] return different non-zero error codes (#290) Return different error codes from fuse_main() --- include/fuse.h | 9 +++++++++ lib/helper.c | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/fuse.h b/include/fuse.h index 740119d..7b63c42 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -812,6 +812,15 @@ struct fuse_context { * * Note: this is currently implemented as a macro. * + * The following error codes may be returned from fuse_main(): + * 1: Invalid option arguments + * 2: No mount point specified + * 3: FUSE setup failed + * 4: Mounting failed + * 5: Failed to daemonize (detach from session) + * 6: Failed to set up signal handlers + * 7: An error occured during the life of the file system + * * @param argc the argument counter passed to the main() function * @param argv the argument vector passed to the main() function * @param op the file system operation diff --git a/lib/helper.c b/lib/helper.c index 4e82692..07cef81 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -303,30 +303,30 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, if (!opts.show_help && !opts.mountpoint) { fprintf(stderr, "error: no mountpoint specified\n"); - res = 1; + res = 2; goto out1; } fuse = fuse_new_31(&args, op, op_size, user_data); if (fuse == NULL) { - res = 1; + res = 3; goto out1; } if (fuse_mount(fuse,opts.mountpoint) != 0) { - res = 1; + res = 4; goto out2; } if (fuse_daemonize(opts.foreground) != 0) { - res = 1; + res = 5; goto out3; } struct fuse_session *se = fuse_get_session(fuse); if (fuse_set_signal_handlers(se) != 0) { - res = 1; + res = 6; goto out3; } @@ -339,7 +339,7 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, res = fuse_loop_mt_32(fuse, &loop_config); } if (res) - res = 1; + res = 7; fuse_remove_signal_handlers(se); out3: -- 2.30.2