neinp

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: BSD-2-Clause Imports: 8 Imported by: 1

README

neinp

builds.sr.ht status GoDoc

about

neinp is a toolkit to implement 9p servers.

installation

go get go.rbn.im/neinp

usage

a example of how to use this can be found here: https://git.sr.ht/~rbn/rssfs

furthermore, the documentation of this package should cover most things. additional information about the 9p protocol can be found in the plan9 manual (should be available online at cat-v.org for example).

contact

email regarding this package (comments, questions, patches) can be send to [code ate rbn.im](mailto:code ate rbn.im).

Documentation

Overview

Package neinp is a toolkit to implement 9p servers.

A 9p filesystem is created by implementing the P2000 interface, which is then used as argument for NewServer. Server can then use an io.ReadWriter supplied to the Serve method handle requests using the aforementioned P2000 implementer.

See https://git.sr.ht/~rbn/rssfs for an example.

NB: This isn't really polished yet, things may break.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NopP2000

type NopP2000 struct{}

NopP2000 is a dummy impementation of interface P2000, returning error for every call. It can be embedded into own implementations if some functions aren't required. For a working mount (with p9p 9pfuse or linux kernel module), at least Version, Attach, Stat, Walk, Open, Read, and Clunk need to be implemented.

func (*NopP2000) Attach

func (*NopP2000) Auth

func (*NopP2000) Close

func (f *NopP2000) Close() error

func (*NopP2000) Clunk

func (*NopP2000) Create

func (*NopP2000) Open

func (*NopP2000) Read

func (*NopP2000) Remove

func (*NopP2000) Stat

func (*NopP2000) Version

func (*NopP2000) Walk

func (*NopP2000) Write

func (*NopP2000) Wstat

type P2000

P2000 is the interface which file systems must implement to be used with Server. To ease implementation of new filesystems, NopP2000 can be embedded. See the types defined in message for documentation of what they do.

type Server

type Server struct {
	Debug bool
	// contains filtered or unexported fields
}

Server muxes and demuxes 9p messages from a connection, calling the corresponding handlers of a P2000 interface.

Example
package main

import (
	"fmt"
	"go.rbn.im/neinp"
	"net"
)

func main() {
	fs := &neinp.NopP2000{}

	l, err := net.Listen("tcp", "localhost:9999")
	if err != nil {
		fmt.Println("listen:", err)
		return
	}

	for {
		c, err := l.Accept()
		if err != nil {
			fmt.Println("accept:", err)
			return
		}

		s := neinp.NewServer(fs)
		if err := s.Serve(c); err != nil {
			fmt.Println("serve:", err)
			return
		}
	}
}
Output:

func NewServer

func NewServer(fs P2000) *Server

NewServer returns a Server initialized to use fs for message handling.

func (*Server) Serve

func (s *Server) Serve(rw io.ReadWriter) error

Serve the filesystem on the connection given by rw.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown serving the filesystem.

Directories

Path Synopsis
Package basic handles en-/decoding of basic types to 9p wire format.
Package basic handles en-/decoding of basic types to 9p wire format.
Package fid supplies a fid type and the usual mutexed map for storing them.
Package fid supplies a fid type and the usual mutexed map for storing them.
Package fs provides helpers to implement 9p objects: directories and files.
Package fs provides helpers to implement 9p objects: directories and files.
Package id provides utility functions to convert unix uid/gid to strings.
Package id provides utility functions to convert unix uid/gid to strings.
Package message contains types for 9p messages.
Package message contains types for 9p messages.
Package qid provides the qid type and supporting functionality.
Package qid provides the qid type and supporting functionality.
Package stat provides functionality to handle 9p stat values.
Package stat provides functionality to handle 9p stat values.

Jump to

Keyboard shortcuts

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