Skip to content
/ p9 Public

Idiomatic Go 9P2000.L client and server, extracted from gVisor for general use

License

Notifications You must be signed in to change notification settings

hugelgupf/p9

Repository files navigation

p9

CircleCI Go Report Card GoDoc

p9 is a Golang 9P2000.L client and server originally written for gVisor. p9 supports Windows, BSD, and Linux on most Go-available architectures.

Server Example

For how to start a server given ap9.Attacherimplementation, see cmd/p9ufs.

For how to implement ap9.Attacherandp9.File,see as an example staticfs,a simple static file system. Boilerplate templates forp9.Fileimplementations are in templatefs.

A test suite for server-sidep9.Attacherandp9.Fileimplementations is being built atfsimpl/test.

Client Example

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)
}