ya9p

package module
v0.0.0-...-5ef25d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: MIT Imports: 11 Imported by: 3

README

ya9p

Go Reference

This package is experimental.

Package ya9p provides 9P server implementations. This package provides only the minimum functionality required to serve 9P. In addition, it can serve filesystems defined in fs.FS.

example

Let's serve the local file system with 9P.

package main

import (
	"os"
	"net"
	"log"

	"github.com/rmatsuoka/ya9p"
)

func main() {
	listener, err := net.Listen("tcp", "localhost:8000")
	if err != nil {
		log.Fatal(err)
	}
	for {
		conn, err := listener.Accept()
		if err != nil {
			log.Print(err)
		}
		go ya9p.ServeFS(conn, os.DirFS("/"))
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoAuthRequired = errors.New("no authentication required")
	ErrAuth        = errors.New("authentication failed")
	ErrBadOffset   = errors.New("bad offset")
	ErrBadUseFid   = errors.New("bad use of fid")
	ErrNoCreate    = errors.New("create prohibited")
	ErrNoRemove    = errors.New("remove prohibited")
	ErrNoStat      = errors.New("stat prohibited")
	ErrNoWrite     = errors.New("write prohibited")
	ErrNoWstat     = errors.New("wstat prohibited")
	ErrPerm        = errors.New("permission denied")
	ErrWalkNoDir   = errors.New("walk in non-directory")
)
View Source
var (
	Version = "9P2000"
)

Functions

func FSFid

func FSFid(fsys fs.FS, name string) (Fid, Qid, error)

func Serve

func Serve(rwc io.ReadWriteCloser, s Srv) error

Types

type Dir

type Dir = plan9.Dir

func FileInfoToDir

func FileInfoToDir(info fs.FileInfo) *Dir

type Fcall

type Fcall = plan9.Fcall

type Fid

type Fid interface {
	Walk(name []string) (Fid, []Qid, error)
	Open(mode uint8) (Qid, uint32, error)
	Create(name string, mode uint8, perm Perm) (Qid, uint32, error)
	io.ReaderAt
	io.WriterAt
	Clunk() error
	Remove() error
	Stat() (*Dir, error)
	WStat(*Dir) error
}

type Perm

type Perm = plan9.Perm

func Plan9FileMode

func Plan9FileMode(m fs.FileMode) Perm

type Qid

type Qid = plan9.Qid

func FileInfoToQid

func FileInfoToQid(info fs.FileInfo) Qid

type Srv

type Srv interface {
	Auth(user, aname string) (Fid, Qid, error)
	Attach(afid Fid, user, aname string) (Fid, Qid, error)
}

func FS

func FS(fsys fs.FS) Srv

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL