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
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
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?
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
The z* files are generated by the script mkall.sh and its helpers.
Russ
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?
--
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