client

package
v0.0.0-...-aa70012 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Namespace

func Namespace() string

Namespace returns the path to the name space directory.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(network, addr string) (*Conn, error)

Dial makes a call to destination addr on a multiplexed network.

If the network in addr is net, dial will try all networks in succession that are common between the source and destination until the call succeeds.

func DialService

func DialService(service string) (*Conn, error)

DialService is a convenience function that wraps Dial by calling the named service.

func NewConn

func NewConn(rwc io.ReadWriteCloser) (*Conn, error)

func (*Conn) Attach

func (c *Conn) Attach(afid *Fid, user, aname string) (*Fsys, error)

Attach establishes a 9P fileserver connection for a given user.

The afid argument specifies a fid to reuse from a previous auth message. To connect without authentication, the afid field should be set to NOFID.

func (*Conn) Auth

func (c *Conn) Auth(uname, aname string) (*Fid, error)

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection and all Fids derived from it.

func (*Conn) Release

func (c *Conn) Release() error

Release marks the connection so that it will close automatically when the last Fid derived from it is closed.

If there are no current Fids, it closes immediately. After calling Release, c.Attach, c.Auth and c.Close will return an error.

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Fid

type Fid struct {
	// contains filtered or unexported fields
}

func (*Fid) Close

func (fid *Fid) Close() error

func (*Fid) Create

func (fid *Fid) Create(name string, mode uint8, perm uint32) error

func (*Fid) Dirread

func (fid *Fid) Dirread() ([]*plan9.Dir, error)

func (*Fid) Dirreadall

func (fid *Fid) Dirreadall() ([]*plan9.Dir, error)

func (*Fid) Open

func (fid *Fid) Open(mode uint8) error

func (*Fid) Qid

func (fid *Fid) Qid() plan9.Qid

func (*Fid) Read

func (fid *Fid) Read(b []byte) (n int, err error)

func (*Fid) ReadAt

func (fid *Fid) ReadAt(b []byte, offset int64) (n int, err error)

func (*Fid) ReadFull

func (fid *Fid) ReadFull(b []byte) (n int, err error)

func (*Fid) Remove

func (fid *Fid) Remove() error

func (*Fid) Seek

func (fid *Fid) Seek(n int64, whence int) (int64, error)

func (*Fid) Stat

func (fid *Fid) Stat() (*plan9.Dir, error)

func (*Fid) Walk

func (fid *Fid) Walk(name string) (*Fid, error)

TODO(rsc): Could use ...string instead?

func (*Fid) Write

func (fid *Fid) Write(b []byte) (n int, err error)

func (*Fid) WriteAt

func (fid *Fid) WriteAt(b []byte, offset int64) (n int, err error)

func (*Fid) Wstat

func (fid *Fid) Wstat(d *plan9.Dir) error

type Fsys

type Fsys struct {
	// contains filtered or unexported fields
}

Fsys represents a connection to a 9P server.

func Mount

func Mount(network, addr string) (*Fsys, error)

Mount mounts a 9P server's files into the file system.

func MountService

func MountService(service string) (*Fsys, error)

func MountServiceAname

func MountServiceAname(service, aname string) (*Fsys, error)

func (*Fsys) Access

func (fs *Fsys) Access(name string, mode int) error

func (*Fsys) Close

func (fs *Fsys) Close() error

Close closes the file associated with a file descriptor.

Provide the file descriptor is a valid open descriptor, close is guaranteed to close it; there will be no error. Files are closed automatically upon termination of a process; close allows the file descriptor to be reused.

func (*Fsys) Create

func (fs *Fsys) Create(name string, mode uint8, perm uint32) (*Fid, error)

Create creates a new file or prepares to rewrite an existinf file.

The filename is opened according to omode (as described for open), and returns the an associated file descriptor. If the file is new, the owner is set to the userid of the creating process group; the group to that of the containing directory; the permissions to perm ANDed with the permissions of the containing directory.

If the file already exists, it is truncated to 0 length, and the permissions, owner, and group remain unchanged. The created file is a directory if the DMDIR bit is set in perm, an exclusive-use file if the DMEXCL bit is set, and append-only file if the DMAPPEND bit is set.

Exclusive-use files may be open for I/O by only one client at a time, but the file descriptor may become invalid if no I/O is done for an extended period.

Create fails if the path up to the last element of a file cannot be evaluated, if the user doesn't have write permission in the final directory, if the file already exists and does not permit the access defined by omode, or if there are no free file descriptors. In the last case, the file may be created even when an error is returned.

Since create may succeed even if the file exists, a special mechanism is necessary for those applications that require an atomic create operation. If th OEXCL (0x1000) bit is set in the mode for a create, the call succeeds only if the file does not already exist.

See: open(9p)

func (*Fsys) Open

func (fs *Fsys) Open(name string, mode uint8) (*Fid, error)

Open opens the file for I/O and returns an associated file descriptor.

Omode is one of OREAD, OWRITE, ORDWR or OEXEC, asking for permssion to read, write, read and write, or execute, respecitvely. In addition, there are three values that can be ORed with omode: OTRUN says to truncate the file to zero length before opening it; OCEXEC says to close the file when an exec(3) or execl system is made; ORCLOSE says to remove the file when it is closed (by everyone who has a copy of the file descriptor); and OAPPEND says to open the file in append-only mode, so that writes are always appened to the end of the file.

Open fails if the file does not exist or the user does not have permission to open it for the requested purpose. See: stat(3). The user must have write permission on the file if the OTRUNC bit is set. For the open system call, unlike the implicit open in exec(3), OEXEC is actually identical to OREAD.

func (*Fsys) Remove

func (fs *Fsys) Remove(name string) error

func (*Fsys) Stat

func (fs *Fsys) Stat(name string) (*plan9.Dir, error)

func (*Fsys) Wstat

func (fs *Fsys) Wstat(name string, d *plan9.Dir) error

Jump to

Keyboard shortcuts

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