- /* create arguments for fuse_new() */
- if (fuse_opt_add_arg(&newfs_args, "") != 0 ||
- (debug && fuse_opt_add_arg(&newfs_args, "-d") != 0))
- {
- fuse_unmount(mount_point, fc);
- exfat_unmount(&ef);
- return 1;
- }
-
- /* create new FUSE file system */
- fh = fuse_new(fc, &newfs_args, &fuse_exfat_ops,
- sizeof(struct fuse_operations), NULL);
- fuse_opt_free_args(&newfs_args);
- if (fh == NULL)
- {
- fuse_unmount(mount_point, fc);
- exfat_unmount(&ef);
- return 1;
- }
-
- /* exit session on HUP, TERM and INT signals and ignore PIPE signal */
- if (fuse_set_signal_handlers(fuse_get_session(fh)) != 0)
- {
- fuse_unmount(mount_point, fc);
- fuse_destroy(fh);
- exfat_unmount(&ef);
- exfat_error("failed to set signal handlers");
- return 1;
- }
-
- /* go to background (unless "-d" option is passed) and run FUSE
- main loop */
- if (fuse_daemonize(debug) == 0)
- {
- if (fuse_loop(fh) != 0)
- exfat_error("FUSE loop failure");
- }
- else
- exfat_error("failed to daemonize");
-
- fuse_remove_signal_handlers(fuse_get_session(fh));
- /* note that fuse_unmount() must be called BEFORE fuse_destroy() */
- fuse_unmount(mount_point, fc);
- fuse_destroy(fh);
- return 0;