Full-featured Go-FUSE library available

326 views
Skip to first unread message

Han-Wen Nienhuys

unread,
Dec 29, 2010, 12:04:48 PM12/29/10
to golan...@googlegroups.com
Hi there,

I've been spending the past few days writing a library in Go to talk
to the FUSE kernel module.

It supports all basic syscalls and has both a lowlevel (inode based)
and high-level (path based) API.
It does not do file locking, Xattrs and exotics things like bmap,
ioctl, poll (yet).

It's available from

https://github.com/hanwen/go-fuse

Excerpt from README follows:

**
GO-FUSE: native bindings for the FUSE kernel module.

See passthrough.go for a file system that exercises all available
functionality. To test it, a tool is provided to mount a local
directory as a loopback:

(cd example ; gomake)
mkdir mountpoint
./example/main -debug -threaded=false mountpoint
/directory/of/some/other/project
(cd mountpoint ; ls)

on my machine, compiles over loopback (threaded, without debug) are
about 10x slower compared to normal compiles.
**

--
Han-Wen Nienhuys
Google Engineering Belo Horizonte
han...@google.com

Dave Cheney

unread,
Dec 30, 2010, 1:24:20 AM12/30/10
to Han-Wen Nienhuys, golan...@googlegroups.com
Hi Han-Wen,

go-fuse is fantastic, I had been wanting to play with fuse for a while now.

I _almost_ have it running on OS X, well compiling at least. To do so
I needed to patch the passthrough.go to compile on OS X (although the
patch is not required on linux/i386)

diff --git a/examplelib/passthrough.go b/examplelib/passthrough.go
index 8e6746f..9cda84f 100644
--- a/examplelib/passthrough.go
+++ b/examplelib/passthrough.go
@@ -120,7 +120,7 @@ func (self *PassThroughFuse) Link(orig string,
newName string) (code fuse.Status
}

func (self *PassThroughFuse) Access(name string, mode uint32) (code
fuse.Status) {
- return fuse.Status(syscall.Access(self.GetPath(name), mode))
+ return fuse.Status(syscall.Access(self.GetPath(name), int(mode)))
}

I also had to patch the go syscall package to expose syscall.Iovec

diff -r 51c777dbccb9 src/pkg/syscall/syscall_darwin_386.go
--- a/src/pkg/syscall/syscall_darwin_386.go Thu Dec 23 13:32:20 2010 +1100
+++ b/src/pkg/syscall/syscall_darwin_386.go Thu Dec 30 17:23:04 2010 +1100
@@ -39,3 +39,7 @@
k.Filter = int16(mode)
k.Flags = uint16(flags)
}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
diff -r 51c777dbccb9 src/pkg/syscall/syscall_darwin_amd64.go
--- a/src/pkg/syscall/syscall_darwin_amd64.go Thu Dec 23 13:32:20 2010 +1100
+++ b/src/pkg/syscall/syscall_darwin_amd64.go Thu Dec 30 17:23:04 2010 +1100
@@ -39,3 +39,7 @@
k.Filter = int16(mode)
k.Flags = uint16(flags)
}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}

I hope this helps.

Cheers

Dave

Han-Wen Nienhuys

unread,
Dec 30, 2010, 8:31:46 AM12/30/10
to Dave Cheney, golan...@googlegroups.com
On Thu, Dec 30, 2010 at 4:24 AM, Dave Cheney <da...@cheney.net> wrote:
> Hi Han-Wen,
>
> go-fuse is fantastic, I had been wanting to play with fuse for a while now.

Thanks! Do pull the latest release, as I fixed a bug that made it go
from doing reads at 1mb/s to 100mb/s

> I _almost_ have it running on OS X, well compiling at least. To do so
> I needed to patch the passthrough.go to compile on OS X (although the
> patch is not required on linux/i386)

It looks like the linux access() syscall has the wrong signature.
I'll open a bug.

> I also had to patch the go syscall package to expose syscall.Iovec

It looks like the whole syscall package is a bit haphazard wrt calls
exposed and signatures. How is it generated anyway?

Gustavo Niemeyer

unread,
Dec 30, 2010, 9:15:37 AM12/30/10
to Han-Wen Nienhuys, Dave Cheney, golan...@googlegroups.com
> go-fuse is fantastic, I had been wanting to play with fuse for a while now.

Same thing here. Can even see a few use cases already. Please keep
us posted on your progress.

--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter

Brad Fitzpatrick

unread,
Dec 30, 2010, 3:26:53 PM12/30/10
to Han-Wen Nienhuys, golan...@googlegroups.com
Nice!  I have an upcoming use for this, so I'll be sure to bug you with any feature requests / pull requests.

Thanks!

Russ Cox

unread,
Jan 4, 2011, 5:15:52 PM1/4/11
to Han-Wen Nienhuys, Dave Cheney, golan...@googlegroups.com
> It looks like the whole syscall package is a bit haphazard wrt calls
> exposed and signatures. How is it generated anyway?

The z* files are generated by the script mkall.sh and its helpers.

Russ

Han-Wen Nienhuys

unread,
Jan 5, 2011, 9:18:59 AM1/5/11
to r...@golang.org, Dave Cheney, golan...@googlegroups.com
I tried running

GOOS=linux GOARCH=386 sh mkall.sh

for

-//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int,
flags int) (n int64, errno int)
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int,
flags int) (n int, errno int)

but I am getting all kinds of other changes, eg.

diff -r 51c777dbccb9 src/pkg/syscall/zerrors_linux_386.go
--- a/src/pkg/syscall/zerrors_linux_386.go Thu Dec 23 13:32:20 2010 +1100
+++ b/src/pkg/syscall/zerrors_linux_386.go Wed Jan 05 12:21:31 2011 -0200
@@ -211,6 +211,7 @@
F_GETLK64 = 0xc
F_GETOWN = 0x9
F_GETOWN_EX = 0x10
+ F_GETPIPE_SZ = 0x408
F_GETSIG = 0xb
F_LOCK = 0x1
F_NOTIFY = 0x402

is there a standard platform on which the script should be run ?

also, there are no tests under syscall/ . Is that intentional?

--

Russ Cox

unread,
Jan 5, 2011, 2:50:47 PM1/5/11
to Han-Wen Nienhuys, Dave Cheney, golan...@googlegroups.com
> is there a standard platform on which the script should be run ?

Yes; right now that platform is standard Ubuntu Lucid.
In this specific case you can run

mkall.sh -n

to find out the mksyscall script invocations and run just
those, which are not sensitive to the surrounding system.

> also, there are no tests under syscall/ .  Is that intentional?

More or less. Syscall exists primarily for the implementation
of higher level packages like net and os. It is assumed that
the ones that matter get tested there.

Russ

Reply all
Reply to author
Forward
0 new messages