posix

package
v0.0.0-...-4950cc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fid

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

Fid represents a file on the file system.

func Attach

func Attach(fs FileSystem, file File, path, username string, uid int, opts ...Option) (*Fid, error)

Attach introduces a new user to the file system, and establishes a fid as the root for that user on the file tree selected by export. If uid is not set to proto.NoUid (~0), is the uid of the user and is used in preference to username.

func (*Fid) Close

func (f *Fid) Close() error

Close closes the fid, rendering it unusable for I/O.

func (*Fid) Create

func (f *Fid) Create(name string, flags int, perm os.FileMode, gid int) error

Create creates a regular file name in directory represented by fid and prepares it for I/O. After the call fid represents the new file.

Flag contains Linux open(2) flags bits, e.g. O_RDONLY, O_WRONLY, and perm contains Linux creat(2) mode bits. Gid is the effective gid of the caller.

func (*Fid) Open

func (f *Fid) Open(flags int) error

Open prepares fid for file I/O. Flag contains Linux open(2) flags bits, e.g. O_RDONLY, O_WRONLY, O_RDWR.

func (*Fid) Remove

func (f *Fid) Remove() error

Remove removes the file system object represented by fid.

func (*Fid) Stat

func (f *Fid) Stat() (*Stat, error)

Stat returns a Stat describing the named file.

type File

type File interface {
	WriteAt(p []byte, offset int64) (int, error)
	ReadAt(p []byte, offset int64) (int, error)
	Close() error
}

File represents a file in the filesystem and is a set of operations corresponding to a single node.

type FileSystem

type FileSystem interface {
	Mknod(path string, perm os.FileMode, major, minor uint32, uid, gid int) error

	Create(path string, flags int, perm os.FileMode, uid, gid int) (File, error)
	Open(path string, flags int, uid, gid int) (File, error)
	Remove(path string, uid, gid int) error

	Stat(path string) (*Stat, error)

	Lookup(username string, uid int) (gid int, err error)

	Close() error
}

FileSystem is the filesystem interface. Any simulated or real system should implement this interface.

func Open

func Open(root string, uid, gid int) (FileSystem, error)

Open opens a FileSystem implementation backed by the underlying operating system's file system.

type Option

type Option func(*Fid) error

Option sets Fid options.

type Record

type Record struct {
	Ino    uint64
	Offset uint64
	Type   uint8
	Name   string
}

Record represents a platform independent directory entry. Ino is a number which is unique for each distinct file in the filesystem.

type Stat

type Stat = unix.Stat_t

Stat describes a file system object.

Jump to

Keyboard shortcuts

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