OSDN Git Service

Improved error handling.
authorresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Sun, 28 Oct 2012 15:14:25 +0000 (15:14 +0000)
committerresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Sun, 28 Oct 2012 15:14:25 +0000 (15:14 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@294 60bc1c72-a15a-11de-b98f-4500b42dc123

fuse/main.c

index 643df3f..76404ce 100644 (file)
@@ -486,22 +486,27 @@ int main(int argc, char* argv[])
        }
 
        /* exit session on HUP, TERM and INT signals and ignore PIPE signal */
-       if (fuse_set_signal_handlers(fuse_get_session(fh)))
+       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 */
-       fuse_daemonize(debug);
-
-       /* FUSE main loop */
-       fuse_loop(fh);
+       /* 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");
 
-       /* it's quite illogical but fuse_unmount() must be called BEFORE
-          fuse_destroy() */
+       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;