OSDN Git Service

OS X utilities report error if fchmod() fails. Added empty chmod() handler as a worka...
[android-x86/external-exfat.git] / fuse / main.c
index 643df3f..84db40d 100644 (file)
@@ -230,6 +230,15 @@ static int fuse_exfat_utimens(const char* path, const struct timespec tv[2])
        return 0;
 }
 
+#ifdef __APPLE__
+static int fuse_exfat_chmod(const char* path, mode_t mode)
+{
+       exfat_debug("[fuse_exfat_chmod] %s 0%ho", path, mode);
+       /* make OS X utilities happy */
+       return 0;
+}
+#endif
+
 static int fuse_exfat_statfs(const char* path, struct statvfs* sfs)
 {
        sfs->f_bsize = CLUSTER_SIZE(*ef.sb);
@@ -278,6 +287,9 @@ static struct fuse_operations fuse_exfat_ops =
        .mkdir          = fuse_exfat_mkdir,
        .rename         = fuse_exfat_rename,
        .utimens        = fuse_exfat_utimens,
+#ifdef __APPLE__
+       .chmod          = fuse_exfat_chmod,
+#endif
        .statfs         = fuse_exfat_statfs,
        .destroy        = fuse_exfat_destroy,
 };
@@ -486,22 +498,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;