1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
## p9
[](https://circleci.com/gh/hugelgupf/p9)
[](https://goreportcard.com/report/github.com/hugelgupf/p9)
[](https://godoc.org/github.com/hugelgupf/p9)
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 a `p9.Attacher` implementation, see
[cmd/p9ufs](cmd/p9ufs/p9ufs.go).
For how to implement a `p9.Attacher` and `p9.File`, see as an example
[staticfs](fsimpl/staticfs/staticfs.go), a simple static file system.
Boilerplate templates for `p9.File` implementations are in
[templatefs](fsimpl/templatefs/).
A test suite for server-side `p9.Attacher` and `p9.File` implementations is
being built at [fsimpl/test](fsimpl/test/filetest.go).
### Client Example
```go
import (
"log"
"net"
"github.com/hugelgupf/p9/p9"
)
func main() {
conn, err := net.Dial("tcp", "localhost:8000")
if err != nil {
log.Fatal(err)
}
// conn can be any net.Conn.
client, err := p9.NewClient(conn)
if err != nil {
log.Fatal(err)
}
// root will be a p9.File and supports all those operations.
root, err := client.Attach("/")
if err != nil {
log.Fatal(err)
}
// For example:
_, _, attrs, err := root.GetAttr(p9.AttrMaskAll)
if err != nil {
log.Fatal(err)
}
log.Printf("Attrs of /: %v", attrs)
}
```
|