aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pfuse
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2007-01-18 12:52:54 +0000
committerrsc <devnull@localhost>2007-01-18 12:52:54 +0000
commit9b3fcf01c5d22d7be320a0e194cc54579f71c409 (patch)
tree62c73a298ebd2f52872ffb72ef6cec4a6b483165 /src/cmd/9pfuse
parente290e875f350dbbc2288ec988d939a57cc8f9bf2 (diff)
downloadplan9port-9b3fcf01c5d22d7be320a0e194cc54579f71c409.tar.gz
plan9port-9b3fcf01c5d22d7be320a0e194cc54579f71c409.tar.bz2
plan9port-9b3fcf01c5d22d7be320a0e194cc54579f71c409.zip
Mac FUSE support (thanks to Jeff Sickel)
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r--src/cmd/9pfuse/fuse.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c
index 2a6d13a4..b2ccd7fc 100644
--- a/src/cmd/9pfuse/fuse.c
+++ b/src/cmd/9pfuse/fuse.c
@@ -742,6 +742,11 @@ fusefmt(Fmt *fmt)
return 0;
}
+#if defined(__APPLE__)
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
+
/*
* Mounts a fuse file system on mtpt and returns
* a file descriptor for the corresponding fuse
@@ -788,6 +793,50 @@ mountfuse(char *mtpt)
_exit(1);
}
return fd;
+#elif defined(__APPLE__)
+ int i, pid, fd, r;
+ char buf[20];
+ struct vfsconf vfs;
+
+ if(getvfsbyname("fusefs", &vfs) < 0){
+ if((r=system("/System/Library/Extensions/fusefs.kext"
+ "/Contents/Resources/load_fusefs")) < 0){
+ werrstr("load fusefs: %r");
+ return -1;
+ }
+ if(r != 0){
+ werrstr("load_fusefs failed: exit %d", r);
+ return -1;
+ }
+ if(getvfsbyname("fusefs", &vfs) < 0){
+ werrstr("getvfsbyname fusefs: %r");
+ return -1;
+ }
+ }
+
+ /* Look for available FUSE device. */
+ for(i=0;; i++){
+ snprint(buf, sizeof buf, "/dev/fuse%d", i);
+ if(access(buf, 0) < 0){
+ werrstr("no available fuse devices");
+ return -1;
+ }
+ if((fd = open(buf, ORDWR)) >= 0)
+ break;
+ }
+
+ pid = fork();
+ if(pid < 0)
+ return -1;
+ if(pid == 0){
+ snprint(buf, sizeof buf, "%d", fd);
+ putenv("MOUNT_FUSEFS_CALL_BY_LIB", "");
+ execl("mount_fusefs", "mount_fusefs", buf, mtpt, nil);
+ fprint(2, "exec mount_fusefs: %r\n");
+ _exit(1);
+ }
+ return fd;
+
#else
werrstr("cannot mount fuse on this system");
return -1;