rclone: github.com/rclone/rclone/vfs Index | Files | Directories

package vfs

import "github.com/rclone/rclone/vfs"

Package vfs provides a virtual filing system layer over rclone's native objects.

It attempts to behave in a similar way to Go's filing system manipulation code in the os package. The same named function should behave in an identical fashion. The objects also obey Go's standard interfaces.

Note that paths don't start or end with /, so the root directory may be referred to as "". However Stat strips slashes so you can use paths with slashes in.

It also includes directory caching

The vfs package returns Error values to signal precisely which error conditions have ocurred. It may also return general errors it receives. It tries to use os Error values (eg os.ErrExist) where possible.

Index

Package Files

cache.go dir.go dir_handle.go errors.go file.go help.go rc.go read.go read_write.go vfs.go write.go

Variables

var (
    ENOENT  = os.ErrNotExist
    EEXIST  = os.ErrExist
    EPERM   = os.ErrPermission
    EINVAL  = os.ErrInvalid
    ECLOSED = os.ErrClosed
)

Errors which have exact counterparts in os

var DefaultOpt = Options{
    NoModTime:         false,
    NoChecksum:        false,
    NoSeek:            false,
    DirCacheTime:      5 * 60 * time.Second,
    PollInterval:      time.Minute,
    ReadOnly:          false,
    Umask:             0,
    UID:               ^uint32(0),
    GID:               ^uint32(0),
    DirPerms:          os.FileMode(0777),
    FilePerms:         os.FileMode(0666),
    CacheMode:         CacheModeOff,
    CacheMaxAge:       3600 * time.Second,
    CachePollInterval: 60 * time.Second,
    ChunkSize:         128 * fs.MebiByte,
    ChunkSizeLimit:    -1,
    CacheMaxSize:      -1,
    CaseInsensitive:   runtime.GOOS == "windows" || runtime.GOOS == "darwin",
}

DefaultOpt is the default values uses for Opt

var Help = `
### Directory Cache

Using the ` + "`--dir-cache-time`" + "" /* 306 byte string literal not displayed */+
    "`SIGHUP`" + "" /* 470 byte string literal not displayed */+
    "`--buffer-size`" + "" /* 590 byte string literal not displayed */+
    "`--buffer-size * open files`" + "" /* 909 byte string literal not displayed */+
    "`-vv`" + "" /* 152 byte string literal not displayed */+
    "`--cache-dir`" + ` or setting the appropriate
environment variable.

The cache has 4 different modes selected by ` + "`--vfs-cache-mode`" + "" /* 2452 byte string literal not displayed */+
    "`--vfs-cache-max-age`" + "" /* 149 byte string literal not displayed */

Help contains text describing file and directory caching to add to the command help.

type CacheMode Uses

type CacheMode byte

CacheMode controls the functionality of the cache

const (
    CacheModeOff     CacheMode = iota // cache nothing - return errors for writes which can't be satisfied
    CacheModeMinimal                  // cache only the minimum, eg read/write opens
    CacheModeWrites                   // cache all files opened with write intent
    CacheModeFull                     // cache all files opened in any mode
)

CacheMode options

func (*CacheMode) Set Uses

func (l *CacheMode) Set(s string) error

Set a CacheMode

func (CacheMode) String Uses

func (l CacheMode) String() string

String turns a CacheMode into a string

func (*CacheMode) Type Uses

func (l *CacheMode) Type() string

Type of the value

type Dir Uses

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

Dir represents a directory entry

func (*Dir) Create Uses

func (d *Dir) Create(name string, flags int) (*File, error)

Create makes a new file node

func (*Dir) DirEntry Uses

func (d *Dir) DirEntry() (entry fs.DirEntry)

DirEntry returns the underlying fs.DirEntry

func (*Dir) ForgetAll Uses

func (d *Dir) ForgetAll()

ForgetAll ensures the directory and all its children are purged from the cache.

func (*Dir) ForgetPath Uses

func (d *Dir) ForgetPath(relativePath string, entryType fs.EntryType)

ForgetPath clears the cache for itself and all subdirectories if they match the given path. The path is specified relative from the directory it is called from. The cache of the parent directory is marked as stale, but not cleared otherwise. It is not possible to traverse the directory tree upwards, i.e. you cannot clear the cache for the Dir's ancestors or siblings.

func (*Dir) Inode Uses

func (d *Dir) Inode() uint64

Inode returns the inode number - satisfies Node interface

func (*Dir) IsDir Uses

func (d *Dir) IsDir() bool

IsDir returns true for Dir - satisfies Node interface

func (*Dir) IsFile Uses

func (d *Dir) IsFile() bool

IsFile returns false for Dir - satisfies Node interface

func (*Dir) Mkdir Uses

func (d *Dir) Mkdir(name string) (*Dir, error)

Mkdir creates a new directory

func (*Dir) ModTime Uses

func (d *Dir) ModTime() time.Time

ModTime returns the modification time of the directory

func (*Dir) Mode Uses

func (d *Dir) Mode() (mode os.FileMode)

Mode bits of the directory - satisfies Node interface

func (*Dir) Name Uses

func (d *Dir) Name() (name string)

Name (base) of the directory - satisfies Node interface

func (*Dir) Node Uses

func (d *Dir) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (*Dir) Open Uses

func (d *Dir) Open(flags int) (fd Handle, err error)

Open the directory according to the flags provided

func (*Dir) Path Uses

func (d *Dir) Path() (name string)

Path of the directory - satisfies Node interface

func (*Dir) ReadDirAll Uses

func (d *Dir) ReadDirAll() (items Nodes, err error)

ReadDirAll reads the contents of the directory sorted

func (*Dir) Remove Uses

func (d *Dir) Remove() error

Remove the directory

func (*Dir) RemoveAll Uses

func (d *Dir) RemoveAll() error

RemoveAll removes the directory and any contents recursively

func (*Dir) RemoveName Uses

func (d *Dir) RemoveName(name string) error

RemoveName removes the entry with the given name from the receiver, which must be a directory. The entry to be removed may correspond to a file (unlink) or to a directory (rmdir).

func (*Dir) Rename Uses

func (d *Dir) Rename(oldName, newName string, destDir *Dir) error

Rename the file

func (*Dir) SetModTime Uses

func (d *Dir) SetModTime(modTime time.Time) error

SetModTime sets the modTime for this dir

func (*Dir) Size Uses

func (d *Dir) Size() int64

Size of the directory

func (*Dir) Stat Uses

func (d *Dir) Stat(name string) (node Node, err error)

Stat looks up a specific entry in the receiver.

Stat should return a Node corresponding to the entry. If the name does not exist in the directory, Stat should return ENOENT.

Stat need not to handle the names "." and "..".

func (*Dir) String Uses

func (d *Dir) String() string

String converts it to printablee

func (*Dir) Sync Uses

func (d *Dir) Sync() error

Sync the directory

Note that we don't do anything except return OK

func (*Dir) Sys Uses

func (d *Dir) Sys() interface{}

Sys returns underlying data source (can be nil) - satisfies Node interface

func (*Dir) Truncate Uses

func (d *Dir) Truncate(size int64) error

Truncate changes the size of the named file.

func (*Dir) VFS Uses

func (d *Dir) VFS() *VFS

VFS returns the instance of the VFS

type DirHandle Uses

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

DirHandle represents an open directory

func (DirHandle) Chdir Uses

func (h DirHandle) Chdir() error

func (DirHandle) Chmod Uses

func (h DirHandle) Chmod(mode os.FileMode) error

func (DirHandle) Chown Uses

func (h DirHandle) Chown(uid, gid int) error

func (*DirHandle) Close Uses

func (fh *DirHandle) Close() (err error)

Close closes the handle

func (DirHandle) Fd Uses

func (h DirHandle) Fd() uintptr

func (DirHandle) Flush Uses

func (h DirHandle) Flush() (err error)

func (DirHandle) Name Uses

func (h DirHandle) Name() string

func (*DirHandle) Node Uses

func (fh *DirHandle) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (DirHandle) Read Uses

func (h DirHandle) Read(b []byte) (n int, err error)

func (DirHandle) ReadAt Uses

func (h DirHandle) ReadAt(b []byte, off int64) (n int, err error)

func (*DirHandle) Readdir Uses

func (fh *DirHandle) Readdir(n int) (fis []os.FileInfo, err error)

Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos.

If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF.

If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error.

func (*DirHandle) Readdirnames Uses

func (fh *DirHandle) Readdirnames(n int) (names []string, err error)

Readdirnames reads and returns a slice of names from the directory f.

If n > 0, Readdirnames returns at most n names. In this case, if Readdirnames returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF.

If n <= 0, Readdirnames returns all the names from the directory in a single slice. In this case, if Readdirnames succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdirnames returns the names read until that point and a non-nil error.

func (DirHandle) Release Uses

func (h DirHandle) Release() (err error)

func (DirHandle) Seek Uses

func (h DirHandle) Seek(offset int64, whence int) (ret int64, err error)

func (*DirHandle) Stat Uses

func (fh *DirHandle) Stat() (fi os.FileInfo, err error)

Stat returns info about the current directory

func (*DirHandle) String Uses

func (fh *DirHandle) String() string

String converts it to printable

func (DirHandle) Sync Uses

func (h DirHandle) Sync() error

func (DirHandle) Truncate Uses

func (h DirHandle) Truncate(size int64) error

func (DirHandle) Write Uses

func (h DirHandle) Write(b []byte) (n int, err error)

func (DirHandle) WriteAt Uses

func (h DirHandle) WriteAt(b []byte, off int64) (n int, err error)

func (DirHandle) WriteString Uses

func (h DirHandle) WriteString(s string) (n int, err error)

type Error Uses

type Error byte

Error describes low level errors in a cross platform way.

const (
    OK  Error = iota
    ENOTEMPTY
    ESPIPE
    EBADF
    EROFS
    ENOSYS
)

Low level errors

func (Error) Error Uses

func (e Error) Error() string

Error renders the error as a string

type File Uses

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

File represents a file

func (*File) Dir Uses

func (f *File) Dir() *Dir

Dir returns the directory this file is in

func (*File) DirEntry Uses

func (f *File) DirEntry() (entry fs.DirEntry)

DirEntry returns the underlying fs.DirEntry - may be nil

func (*File) Inode Uses

func (f *File) Inode() uint64

Inode returns the inode number - satisfies Node interface

func (*File) IsDir Uses

func (f *File) IsDir() bool

IsDir returns false for File - satisfies Node interface

func (*File) IsFile Uses

func (f *File) IsFile() bool

IsFile returns true for File - satisfies Node interface

func (*File) ModTime Uses

func (f *File) ModTime() (modTime time.Time)

ModTime returns the modified time of the file

if NoModTime is set then it returns the mod time of the directory

func (*File) Mode Uses

func (f *File) Mode() (mode os.FileMode)

Mode bits of the file or directory - satisfies Node interface

func (*File) Name Uses

func (f *File) Name() (name string)

Name (base) of the directory - satisfies Node interface

func (*File) Node Uses

func (f *File) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (*File) Open Uses

func (f *File) Open(flags int) (fd Handle, err error)

Open a file according to the flags provided

O_RDONLY open the file read-only.
O_WRONLY open the file write-only.
O_RDWR   open the file read-write.

O_APPEND append data to the file when writing.
O_CREATE create a new file if none exists.
O_EXCL   used with O_CREATE, file must not exist
O_SYNC   open for synchronous I/O.
O_TRUNC  if possible, truncate file when opene

We ignore O_SYNC and O_EXCL

func (*File) Path Uses

func (f *File) Path() string

Path returns the full path of the file

func (*File) Remove Uses

func (f *File) Remove() error

Remove the file

func (*File) RemoveAll Uses

func (f *File) RemoveAll() error

RemoveAll the file - same as remove for files

func (*File) SetModTime Uses

func (f *File) SetModTime(modTime time.Time) error

SetModTime sets the modtime for the file

func (*File) Size Uses

func (f *File) Size() int64

Size of the file

func (*File) String Uses

func (f *File) String() string

String converts it to printable

func (*File) Sync Uses

func (f *File) Sync() error

Sync the file

Note that we don't do anything except return OK

func (*File) Sys Uses

func (f *File) Sys() interface{}

Sys returns underlying data source (can be nil) - satisfies Node interface

func (*File) Truncate Uses

func (f *File) Truncate(size int64) (err error)

Truncate changes the size of the named file.

func (*File) VFS Uses

func (f *File) VFS() *VFS

VFS returns the instance of the VFS

type Handle Uses

type Handle interface {
    OsFiler
    // Additional methods useful for FUSE filesystems
    Flush() error
    Release() error
    Node() Node
}

Handle is the interface statisified by open files or directories. It is the methods on *os.File, plus a few more useful for FUSE filingsystems. Not all of them are supported.

type Node Uses

type Node interface {
    os.FileInfo
    IsFile() bool
    Inode() uint64
    SetModTime(modTime time.Time) error
    Sync() error
    Remove() error
    RemoveAll() error
    DirEntry() fs.DirEntry
    VFS() *VFS
    Open(flags int) (Handle, error)
    Truncate(size int64) error
    Path() string
}

Node represents either a directory (*Dir) or a file (*File)

type Noder Uses

type Noder interface {
    fmt.Stringer
    Node() Node
}

Noder represents something which can return a node

type Nodes Uses

type Nodes []Node

Nodes is a slice of Node

func (Nodes) Len Uses

func (ns Nodes) Len() int

Sort functions

func (Nodes) Less Uses

func (ns Nodes) Less(i, j int) bool

func (Nodes) Swap Uses

func (ns Nodes) Swap(i, j int)

type Options Uses

type Options struct {
    NoSeek            bool          // don't allow seeking if set
    NoChecksum        bool          // don't check checksums if set
    ReadOnly          bool          // if set VFS is read only
    NoModTime         bool          // don't read mod times for files
    DirCacheTime      time.Duration // how long to consider directory listing cache valid
    PollInterval      time.Duration
    Umask             int
    UID               uint32
    GID               uint32
    DirPerms          os.FileMode
    FilePerms         os.FileMode
    ChunkSize         fs.SizeSuffix // if > 0 read files in chunks
    ChunkSizeLimit    fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
    CacheMode         CacheMode
    CacheMaxAge       time.Duration
    CacheMaxSize      fs.SizeSuffix
    CachePollInterval time.Duration
    CaseInsensitive   bool
}

Options is options for creating the vfs

type OsFiler Uses

type OsFiler interface {
    Chdir() error
    Chmod(mode os.FileMode) error
    Chown(uid, gid int) error
    Close() error
    Fd() uintptr
    Name() string
    Read(b []byte) (n int, err error)
    ReadAt(b []byte, off int64) (n int, err error)
    Readdir(n int) ([]os.FileInfo, error)
    Readdirnames(n int) (names []string, err error)
    Seek(offset int64, whence int) (ret int64, err error)
    Stat() (os.FileInfo, error)
    Sync() error
    Truncate(size int64) error
    Write(b []byte) (n int, err error)
    WriteAt(b []byte, off int64) (n int, err error)
    WriteString(s string) (n int, err error)
}

OsFiler is the methods on *os.File

type RWFileHandle Uses

type RWFileHandle struct {
    *os.File
    // contains filtered or unexported fields
}

RWFileHandle is a handle that can be open for read and write.

It will be open to a temporary file which, when closed, will be transferred to the remote.

func (*RWFileHandle) Close Uses

func (fh *RWFileHandle) Close() error

Close closes the file

func (*RWFileHandle) Flush Uses

func (fh *RWFileHandle) Flush() error

Flush is called each time the file or directory is closed. Because there can be multiple file descriptors referring to a single opened file, Flush can be called multiple times.

func (*RWFileHandle) Node Uses

func (fh *RWFileHandle) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (*RWFileHandle) Read Uses

func (fh *RWFileHandle) Read(b []byte) (n int, err error)

Read bytes from the file

func (*RWFileHandle) ReadAt Uses

func (fh *RWFileHandle) ReadAt(b []byte, off int64) (n int, err error)

ReadAt bytes from the file at off

func (*RWFileHandle) Release Uses

func (fh *RWFileHandle) Release() error

Release is called when we are finished with the file handle

It isn't called directly from userspace so the error is ignored by the kernel

func (*RWFileHandle) Seek Uses

func (fh *RWFileHandle) Seek(offset int64, whence int) (ret int64, err error)

Seek to new file position

func (*RWFileHandle) Size Uses

func (fh *RWFileHandle) Size() int64

Size returns the size of the underlying file

func (*RWFileHandle) Stat Uses

func (fh *RWFileHandle) Stat() (os.FileInfo, error)

Stat returns info about the file

func (*RWFileHandle) String Uses

func (fh *RWFileHandle) String() string

String converts it to printable

func (*RWFileHandle) Sync Uses

func (fh *RWFileHandle) Sync() error

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func (*RWFileHandle) Truncate Uses

func (fh *RWFileHandle) Truncate(size int64) (err error)

Truncate file to given size

func (*RWFileHandle) Write Uses

func (fh *RWFileHandle) Write(b []byte) (n int, err error)

Write bytes to the file

func (*RWFileHandle) WriteAt Uses

func (fh *RWFileHandle) WriteAt(b []byte, off int64) (n int, err error)

WriteAt bytes to the file at off

func (*RWFileHandle) WriteString Uses

func (fh *RWFileHandle) WriteString(s string) (n int, err error)

WriteString a string to the file

type ReadFileHandle Uses

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

ReadFileHandle is an open for read file handle on a File

func (ReadFileHandle) Chdir Uses

func (h ReadFileHandle) Chdir() error

func (ReadFileHandle) Chmod Uses

func (h ReadFileHandle) Chmod(mode os.FileMode) error

func (ReadFileHandle) Chown Uses

func (h ReadFileHandle) Chown(uid, gid int) error

func (*ReadFileHandle) Close Uses

func (fh *ReadFileHandle) Close() error

Close closes the file

func (ReadFileHandle) Fd Uses

func (h ReadFileHandle) Fd() uintptr

func (*ReadFileHandle) Flush Uses

func (fh *ReadFileHandle) Flush() error

Flush is called each time the file or directory is closed. Because there can be multiple file descriptors referring to a single opened file, Flush can be called multiple times.

func (ReadFileHandle) Name Uses

func (h ReadFileHandle) Name() string

func (*ReadFileHandle) Node Uses

func (fh *ReadFileHandle) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (*ReadFileHandle) Read Uses

func (fh *ReadFileHandle) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.

When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.

Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

Implementations of Read are discouraged from returning a zero byte count with a nil error, except when len(p) == 0. Callers should treat a return of 0 and nil as indicating that nothing happened; in particular it does not indicate EOF.

Implementations must not retain p.

func (*ReadFileHandle) ReadAt Uses

func (fh *ReadFileHandle) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.

When ReadAt returns n < len(p), it returns a non-nil error explaining why more bytes were not returned. In this respect, ReadAt is stricter than Read.

Even if ReadAt returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, ReadAt blocks until either all the data is available or an error occurs. In this respect ReadAt is different from Read.

If the n = len(p) bytes returned by ReadAt are at the end of the input source, ReadAt may return either err == EOF or err == nil.

If ReadAt is reading from an input source with a seek offset, ReadAt should not affect nor be affected by the underlying seek offset.

Clients of ReadAt can execute parallel ReadAt calls on the same input source.

Implementations must not retain p.

func (ReadFileHandle) Readdir Uses

func (h ReadFileHandle) Readdir(n int) ([]os.FileInfo, error)

func (ReadFileHandle) Readdirnames Uses

func (h ReadFileHandle) Readdirnames(n int) (names []string, err error)

func (*ReadFileHandle) Release Uses

func (fh *ReadFileHandle) Release() error

Release is called when we are finished with the file handle

It isn't called directly from userspace so the error is ignored by the kernel

func (*ReadFileHandle) Seek Uses

func (fh *ReadFileHandle) Seek(offset int64, whence int) (n int64, err error)

Seek the file - returns ESPIPE if seeking isn't possible

func (*ReadFileHandle) Size Uses

func (fh *ReadFileHandle) Size() int64

Size returns the size of the underlying file

func (*ReadFileHandle) Stat Uses

func (fh *ReadFileHandle) Stat() (os.FileInfo, error)

Stat returns info about the file

func (*ReadFileHandle) String Uses

func (fh *ReadFileHandle) String() string

String converts it to printable

func (ReadFileHandle) Sync Uses

func (h ReadFileHandle) Sync() error

func (ReadFileHandle) Truncate Uses

func (h ReadFileHandle) Truncate(size int64) error

func (ReadFileHandle) Write Uses

func (h ReadFileHandle) Write(b []byte) (n int, err error)

func (ReadFileHandle) WriteAt Uses

func (h ReadFileHandle) WriteAt(b []byte, off int64) (n int, err error)

func (ReadFileHandle) WriteString Uses

func (h ReadFileHandle) WriteString(s string) (n int, err error)

type VFS Uses

type VFS struct {
    Opt Options
    // contains filtered or unexported fields
}

VFS represents the top level filing system

func New Uses

func New(f fs.Fs, opt *Options) *VFS

New creates a new VFS and root directory. If opt is nil, then DefaultOpt will be used

func (*VFS) CleanUp Uses

func (vfs *VFS) CleanUp() error

CleanUp deletes the contents of the on disk cache

func (*VFS) FlushDirCache Uses

func (vfs *VFS) FlushDirCache()

FlushDirCache empties the directory cache

func (*VFS) Fs Uses

func (vfs *VFS) Fs() fs.Fs

Fs returns the Fs passed into the New call

func (*VFS) OpenFile Uses

func (vfs *VFS) OpenFile(name string, flags int, perm os.FileMode) (fd Handle, err error)

OpenFile a file according to the flags and perm provided

func (*VFS) Rename Uses

func (vfs *VFS) Rename(oldName, newName string) error

Rename oldName to newName

func (*VFS) Root Uses

func (vfs *VFS) Root() (*Dir, error)

Root returns the root node

func (*VFS) SetCacheMode Uses

func (vfs *VFS) SetCacheMode(cacheMode CacheMode)

SetCacheMode change the cache mode

func (*VFS) Shutdown Uses

func (vfs *VFS) Shutdown()

Shutdown stops any background go-routines

func (*VFS) Stat Uses

func (vfs *VFS) Stat(path string) (node Node, err error)

Stat finds the Node by path starting from the root

It is the equivalent of os.Stat - Node contains the os.FileInfo interface.

func (*VFS) StatParent Uses

func (vfs *VFS) StatParent(name string) (dir *Dir, leaf string, err error)

StatParent finds the parent directory and the leaf name of a path

func (*VFS) Statfs Uses

func (vfs *VFS) Statfs() (total, used, free int64)

Statfs returns into about the filing system if known

The values will be -1 if they aren't known

This information is cached for the DirCacheTime interval

func (*VFS) WaitForWriters Uses

func (vfs *VFS) WaitForWriters(timeout time.Duration)

WaitForWriters sleeps until all writers have finished or time.Duration has elapsed

type WriteFileHandle Uses

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

WriteFileHandle is an open for write handle on a File

func (WriteFileHandle) Chdir Uses

func (h WriteFileHandle) Chdir() error

func (WriteFileHandle) Chmod Uses

func (h WriteFileHandle) Chmod(mode os.FileMode) error

func (WriteFileHandle) Chown Uses

func (h WriteFileHandle) Chown(uid, gid int) error

func (*WriteFileHandle) Close Uses

func (fh *WriteFileHandle) Close() error

Close closes the file

func (WriteFileHandle) Fd Uses

func (h WriteFileHandle) Fd() uintptr

func (*WriteFileHandle) Flush Uses

func (fh *WriteFileHandle) Flush() error

Flush is called on each close() of a file descriptor. So if a filesystem wants to return write errors in close() and the file has cached dirty data, this is a good place to write back data and return any errors. Since many applications ignore close() errors this is not always useful.

NOTE: The flush() method may be called more than once for each open(). This happens if more than one file descriptor refers to an opened file due to dup(), dup2() or fork() calls. It is not possible to determine if a flush is final, so each flush should be treated equally. Multiple write-flush sequences are relatively rare, so this shouldn't be a problem.

Filesystems shouldn't assume that flush will always be called after some writes, or that if will be called at all.

func (WriteFileHandle) Name Uses

func (h WriteFileHandle) Name() string

func (*WriteFileHandle) Node Uses

func (fh *WriteFileHandle) Node() Node

Node returns the Node assocuated with this - satisfies Noder interface

func (*WriteFileHandle) Offset Uses

func (fh *WriteFileHandle) Offset() (offset int64)

Offset returns the offset of the file pointer

func (*WriteFileHandle) Read Uses

func (fh *WriteFileHandle) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes into p.

func (*WriteFileHandle) ReadAt Uses

func (fh *WriteFileHandle) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.

func (WriteFileHandle) Readdir Uses

func (h WriteFileHandle) Readdir(n int) ([]os.FileInfo, error)

func (WriteFileHandle) Readdirnames Uses

func (h WriteFileHandle) Readdirnames(n int) (names []string, err error)

func (*WriteFileHandle) Release Uses

func (fh *WriteFileHandle) Release() error

Release is called when we are finished with the file handle

It isn't called directly from userspace so the error is ignored by the kernel

func (WriteFileHandle) Seek Uses

func (h WriteFileHandle) Seek(offset int64, whence int) (ret int64, err error)

func (*WriteFileHandle) Stat Uses

func (fh *WriteFileHandle) Stat() (os.FileInfo, error)

Stat returns info about the file

func (*WriteFileHandle) String Uses

func (fh *WriteFileHandle) String() string

String converts it to printable

func (*WriteFileHandle) Sync Uses

func (fh *WriteFileHandle) Sync() error

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func (*WriteFileHandle) Truncate Uses

func (fh *WriteFileHandle) Truncate(size int64) (err error)

Truncate file to given size

func (*WriteFileHandle) Write Uses

func (fh *WriteFileHandle) Write(p []byte) (n int, err error)

Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write must return a non-nil error if it returns n < len(p). Write must not modify the slice data, even temporarily.

Implementations must not retain p.

func (*WriteFileHandle) WriteAt Uses

func (fh *WriteFileHandle) WriteAt(p []byte, off int64) (n int, err error)

WriteAt writes len(p) bytes from p to the underlying data stream at offset off. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. WriteAt must return a non-nil error if it returns n < len(p).

If WriteAt is writing to a destination with a seek offset, WriteAt should not affect nor be affected by the underlying seek offset.

Clients of WriteAt can execute parallel WriteAt calls on the same destination if the ranges do not overlap.

Implementations must not retain p.

func (*WriteFileHandle) WriteString Uses

func (fh *WriteFileHandle) WriteString(s string) (n int, err error)

WriteString a string to the file

Directories

PathSynopsis
test_vfsTest the VFS to exhaustion, specifically looking for deadlocks
vfsflagsPackage vfsflags implements command line flags to set up a vfs

Package vfs imports 29 packages (graph) and is imported by 24 packages. Updated 2019-09-18. Refresh now. Tools for package owners.