vfs

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error is the common error type used by vfs implementations.

func Err

func Err(op string, kind Kind, path string, err error) *Error

Err creates a new Error. All fields are optional.

func (*Error) Cause

func (e *Error) Cause() error

Cause returns the causing error, is there is one. Returns nil if the error is the root cause of an error.

func (*Error) Error

func (e *Error) Error() string

Error builds the error message of the underlying error.

func (*Error) Errors

func (e *Error) Errors() []error

Errors returns the error cause as a list. The Errors method is avaialble for compatiblity with other error packages and libraries consuming errors (e.g. zap or multierr).

func (*Error) Kind

func (e *Error) Kind() error

Kind returns the error code for use by the applications error handling code.

func (*Error) Op

func (e *Error) Op() string

Op reports the failed operation.

func (*Error) Path

func (e *Error) Path() string

Path returns the path of the file an operation failed for.

type File

type File interface {
	io.Closer
	io.WriterAt
	io.ReaderAt

	Name() string
	Size() (int64, error)
	Truncate(int64) error

	Lock(exclusive, blocking bool) error
	Unlock() error

	MMap(sz int) ([]byte, error)
	MUnmap([]byte) error

	// If a write/flush fails due to IO errors or the disk running out of space,
	// the kernel internally marks the error on the 'page'. Fsync will finally
	// return the error, but reset the error on failed writes. Subsequent fsync
	// operations will not report errors for former failed pages, even if the
	// pages are not written again. Therefore, if fsync fails, we must assume all
	// write operations - since the last successfull fsync - have failed and
	// reinitiate all writes.
	// According to [1] Linux, OpenBSD, and NetBSD are known to silently clear
	// errors on fsync fail.
	//
	// [1]: https://lwn.net/Articles/752098/
	Sync(flags SyncFlag) error
}

type Kind

type Kind int

Kind encodes an error code for use by applications. Implementations of vfs must unify errors, using the Error type and the error codes defined here.

const (
	ErrOSOther      Kind = iota // unknown OS error
	ErrPermission               // permission denied
	ErrExist                    // file already exists
	ErrNotExist                 // file does not exist
	ErrClosed                   // file already closed
	ErrNoSpace                  // no space or quota exhausted
	ErrFDLimit                  // process file desciptor limit reached
	ErrResolvePath              // cannot resolve path
	ErrIO                       // read/write IO error
	ErrNotSupported             // operation not supported
	ErrLockFailed               // file lock failed
	ErrUnlockFailed             // file unlock failed

)

func (Kind) Error

func (k Kind) Error() string

Error returns the error codes descriptive text.

func (Kind) String

func (i Kind) String() string

type SyncFlag

type SyncFlag uint8
const (
	SyncAll SyncFlag = 0

	// SyncDataOnly will only flush the file data, without enforcing an update on
	// the file metadata (like file size or modification time).
	SyncDataOnly SyncFlag = 1 << iota
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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