t9pfuse: support osxfuse>=3.3.0 - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9f34853f7c6b459fb473d75cb78372406f69d7b2
 (DIR) parent c819ee640c1e0369b7ae513985b8bb44e154c0a1
 (HTM) Author: James Porter <james@jamesporter.me>
       Date:   Wed, 30 Nov 2016 23:00:38 -0500
       
       9pfuse: support osxfuse>=3.3.0
       
       Change-Id: Ibca68261016b0f588e169e9f319748b5ba7d15ac
       Reviewed-on: https://plan9port-review.googlesource.com/2700
       Reviewed-by: michaelian ennis <michaelian.ennis@gmail.com>
       Reviewed-by: Russ Cox <rsc@swtch.com>
       
       Diffstat:
         M src/cmd/9pfuse/fuse.c               |      35 +++++++++++++++++++++++++-------
       
       1 file changed, 28 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c
       t@@ -799,10 +799,14 @@ mountfuse(char *mtpt)
                char buf[20];
                struct vfsconf vfs;
                char *f, *v;
       -        
       -        if(getvfsbyname(v="osxfusefs", &vfs) < 0 && getvfsbyname(v="fusefs", &vfs) < 0){
       +
       +        if(getvfsbyname(v="osxfusefs", &vfs) < 0 &&
       +           getvfsbyname(v="osxfuse", &vfs) < 0 &&
       +           getvfsbyname(v="fusefs", &vfs) < 0){
                        if(access((v="osxfusefs", f="/Library/Filesystems/osxfusefs.fs"
                                "/Support/load_osxfusefs"), 0) < 0 &&
       +                   access((v="osxfuse", f="/Library/Filesystems/osxfuse.fs"
       +                        "/Contents/Resources/load_osxfuse"), 0) < 0 &&
                           access((v="fusefs", f="/System/Library/Extensions/fusefs.kext"
                                "/Contents/Resources/load_fusefs"), 0) < 0 &&
                           access(f="/Library/Extensions/fusefs.kext"
       t@@ -827,10 +831,20 @@ mountfuse(char *mtpt)
                                return -1;
                        }
                }
       -        
       +
                /* Look for available FUSE device. */
       +        /*
       +         * We need to truncate `fs` from the end of the vfs name if
       +         * it's present
       +         */
       +        int len;
       +        if (strcmp(v, "osxfuse") == 0) {
       +                len = strlen(v);
       +        } else {
       +                len = strlen(v)-2;
       +        }
                for(i=0;; i++){
       -                snprint(buf, sizeof buf, "/dev/%.*s%d", strlen(v)-2, v, i);
       +                snprint(buf, sizeof buf, "/dev/%.*s%d", len, v, i);
                        if(access(buf, 0) < 0){
                                werrstr("no available fuse devices");
                                return -1;
       t@@ -844,12 +858,19 @@ mountfuse(char *mtpt)
                        return -1;
                if(pid == 0){
                        snprint(buf, sizeof buf, "%d", fd);
       +                /* OSXFUSE >=3.3 changed the name of the environment variable, set both */
                        putenv("MOUNT_FUSEFS_CALL_BY_LIB", "");
       +                putenv("MOUNT_OSXFUSE_CALL_BY_LIB", "");
                        /*
       -                 * Different versions of MacFUSE put the
       -                 * mount_fusefs binary in different places.
       -                 * Try all.
       +                 * Different versions of OSXFUSE and MacFUSE put the
       +                 * mount_fusefs binary in different places.  Try all.
                         */
       +                /*  OSXFUSE >=3.3  greater location */
       +                putenv("MOUNT_OSXFUSE_DAEMON_PATH",
       +                           "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse");
       +                execl("/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse",
       +                          "mount_osxfuse", buf, mtpt, nil);
       +
                        /* Lion OSXFUSE location */
                        putenv("MOUNT_FUSEFS_DAEMON_PATH",
                                   "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs");