p9 is a Golang 9P2000.L client and server originally written for gVisor. p9 supports Windows, BSD, and Linux on most Go-available architectures.
For how to start a server given ap9.Attacher
implementation, see
cmd/p9ufs.
For how to implement ap9.Attacher
andp9.File
,see as an example
staticfs,a simple static file system.
Boilerplate templates forp9.File
implementations are in
templatefs.
A test suite for server-sidep9.Attacher
andp9.File
implementations is
being built atfsimpl/test.
import(
"log"
"net"
"github /hugelgupf/p9/p9"
)
funcmain() {
conn,err:=net.Dial("tcp","localhost:8000")
iferr!=nil{
log.Fatal(err)
}
// conn can be any net.Conn.
client,err:=p9.NewClient(conn)
iferr!=nil{
log.Fatal(err)
}
// root will be a p9.File and supports all those operations.
root,err:=client.Attach("/")
iferr!=nil{
log.Fatal(err)
}
// For example:
_,_,attrs,err:=root.GetAttr(p9.AttrMaskAll)
iferr!=nil{
log.Fatal(err)
}
log.Printf("Attrs of /: %v",attrs)
}