simple-nfs-server
is an example nfs server implementation that serves files from memory. xdrrpc
is a golang library to create XDRRPC services also known as SUNRPC or ONCRPC (RFC 5531). Both are written in pure go, without using rpcgen toolchain (Sun Microsystems ONC RPC generator). xdrrpc
conforms to golang net/rpc
ServerCodec interface. API documentation for xdrrpc
can be found in .
$ go get -u github.com/dzeromsk/xdrrpc/...
This will make the simple-nfs-server
tool available in ${GOPATH}/bin
, which by default means ~/go/bin
.
simple-nfs-server
serves all files from memory with limited support for attributes.
Usage of simple-nfs-server:
-debug
Enable debug prints
-listen string
Server listen address (default ":12049")
Start simple-nfs-server
$ simple-nfs-server --debug -listen :12049
Mount on the client using fixed protocol (tcp), port (12049) and any mount point on localhost:
$ sudo mount -vvv -o nfsvers=3,proto=tcp,port=12049,mountvers=3,mountport=12049,mountproto=tcp 127.0.0.1:/ /mnt/example
Low level usage of xdrrpc
package
import (
"net/rpc"
"github.com/dzeromsk/xdrrpc"
)
func init() {
xdrrpc.Register(100005, 3, 0, "Mount", "Null")
}
type Mount struct {}
func (m *Mount) Null(args *mount.NullArgs, res *mount.NullRes) error {
return nil
}
func main() {
rpc.Register(mount)
ln, _ := net.Listen("tcp", *listen)
for {
conn, _ := ln.Accept()
go xdrrpc.ServeConn(conn)
}
}
For helpers like nfs.ServeMux
usage please take a look at xdrrpc/nfs
and xdrrpc/example/memfs
packages. Skimming through RFC 1813 will help too.
- Simple.
- Memory only.
- Compatible with Linux kernel NFS Client.
- Implements stdlib ServerCodec.
- Some features are missing.
xdrrpc
conforms to golang net/rpc
ServerCodec interface. At some point in future we should consider replacing net/rpc
with custom RPC server implementation.
I made this to debug Linux NFS Client attribute caching behavior at work. Feel free to fork it.