Documentation
¶
Index ¶
- Constants
- Variables
- func Base(path string) string
- func Bool(ctx context.Context, key ContextKey) bool
- func Checksum(fs ReadFS, path string, algorithm crypto.Hash) ([]byte, error)
- func Clean(path string) string
- func Dir(path string) string
- func Duration(ctx context.Context, key ContextKey) time.Duration
- func FileReadSeekCloser(fs FS, path string) (io.ReadSeekCloser, error)
- func FileWriteCloser(fs FS, path string, flags int) (io.WriteCloser, error)
- func Int(ctx context.Context, key ContextKey) int
- func IsAbs(path string) bool
- func IsPathSeparator(c uint8) bool
- func Iterate(lister ListerAt, batchSize int) iter.Seq[FileInfo]
- func Join(paths ...string) string
- func Logger(ctx context.Context) *logrus.Entry
- func MkdirAll(fs MkdirFS, path string, perm os.FileMode) error
- func ReadFile(fs FS, path string) ([]byte, error)
- func RemoveAll(fs WalkRemoveFS, path string) error
- func RunTestSuiteRO(t *testing.T, fs FS)
- func RunTestSuiteRW(t *testing.T, fs FS)
- func SetExtendedAttrs(fs SetExtendedAttrFS, path string, attrs Attributes) error
- func Split(path string) (string, string)
- func String(ctx context.Context, key ContextKey) string
- func Walk(fs WalkableFS, root string, fn WalkFunc) error
- func WriteFile(fs FS, path string, data []byte, flags int) error
- type AdvancedFS
- type AdvancedLinkFS
- type Attributes
- type ChecksumFS
- type ContextKey
- type FS
- type File
- type FileInfo
- type FileInfoListerAt
- type HandleFS
- type HandleFileInfo
- type HandleResolveFS
- type LinkFS
- type ListerAt
- type MkdirFS
- type NotImplementedAdvancedFS
- func (n NotImplementedAdvancedFS) Checksum(path string, algorithm crypto.Hash) ([]byte, error)
- func (n NotImplementedAdvancedFS) Handle(path string) ([]byte, error)
- func (n NotImplementedAdvancedFS) Open(path string) (File, error)
- func (n NotImplementedAdvancedFS) OpenFile(path string, mode int, perm os.FileMode) (File, error)
- func (n NotImplementedAdvancedFS) Path(handle []byte) (string, error)
- func (n NotImplementedAdvancedFS) Walk(path string, fn WalkFunc) error
- type NotImplementedFS
- func (n NotImplementedFS) Chmod(path string, mode os.FileMode) error
- func (n NotImplementedFS) Chown(path string, uid, gid int) error
- func (n NotImplementedFS) Chtimes(path string, atime, mtime time.Time) error
- func (n NotImplementedFS) Close() error
- func (n NotImplementedFS) FileRead(path string) (ReaderAt, error)
- func (n NotImplementedFS) FileWrite(path string, flag int) (WriterAt, error)
- func (n NotImplementedFS) List(path string) (ListerAt, error)
- func (n NotImplementedFS) Mkdir(path string, perm os.FileMode) error
- func (n NotImplementedFS) Remove(path string) error
- func (n NotImplementedFS) Rename(oldpath, newpath string) error
- func (n NotImplementedFS) Rmdir(path string) error
- func (n NotImplementedFS) SetExtendedAttr(path, name string, value []byte) error
- func (n NotImplementedFS) SetExtendedAttrs(path string, attrs Attributes) error
- func (n NotImplementedFS) Stat(path string) (FileInfo, error)
- func (n NotImplementedFS) Truncate(path string, size int64) error
- func (n NotImplementedFS) UnsetExtendedAttr(path, name string) error
- type NotImplementedRootFS
- func (n NotImplementedRootFS) Link(path, target string) error
- func (n NotImplementedRootFS) Lstat(path string) (FileInfo, error)
- func (n NotImplementedRootFS) Mount(path string, fs FS, index byte) error
- func (n NotImplementedRootFS) Readlink(path string) (string, error)
- func (n NotImplementedRootFS) RealPath(path string) (string, error)
- func (n NotImplementedRootFS) Symlink(path, target string) error
- type OpenFS
- type OpenFileFS
- type OpenableFS
- type Permissions
- type ReadFS
- type ReaderAt
- type RootFS
- type SetExtendedAttrFS
- type SetExtendedAttrsFS
- type SymlinkFS
- type WalkFS
- type WalkFunc
- type WalkRemoveFS
- type WalkableFS
- type WriterAt
- type WriterAtReaderAt
Constants ¶
const ListBufSize = 512
const ReadDirBufSize = 512
const Separator = '/'
Variables ¶
var ( SkipDir = filepath.SkipDir //nolint:errname SkipAll = filepath.SkipAll //nolint:errname SkipSubDirs = api.SkipSubDirs //nolint:errname )
var ( // Log context key to specify which logger. // Set a context value either to a *logrus.Logger or a *logrus.Entry to use a custom logger. // Defaults to logrus.StandardLogger Log = ContextKey("logger") // Boolean indicating whether List and Walk methods should return extended attributes. // If false, implementations may choose to not include them if Extended() is called on the returned file infos. ListWithXattrs = ContextKey("list-with-xattrs") // String indicating which local storage can be used as persistent storage for the inode handle database. PersistentStorage = ContextKey("persistent-storage") // Boolean indicating whether or not the inode handle database should be persisted. DisablePersistentHandleDB = ContextKey("disable-persistent-handle-db") // Boolean indicating whether or not server inodes should be used when exposing a native posix file system. UseServerInodes = ContextKey("use-serverino") // Boolean indicating whether or not chown is supported when exposing a native posix file system. AllowServerChown = ContextKey("allow-chown") )
var ErrInvalidHandle = fmt.Errorf("%w: invalid handle", syscall.EINVAL)
var ErrNotImplemented = fmt.Errorf("%w: not implemented", syscall.EPERM)
var ErrNotSupported = syscall.EOPNOTSUPP
Functions ¶
func Bool ¶
func Bool(ctx context.Context, key ContextKey) bool
Bool returns the boolean value associated with the given context key. If the key is not present in the context, it returns false.
func Clean ¶
Clean strips trailing separators from the path, except for the root directory, which will never be stripped. It also removes ./ and ../ elements.
func Dir ¶
Dir returns all but the last element of path, typically the path's directory. On the root directory, Dir returns "" and prints a warning.
func Duration ¶
func Duration(ctx context.Context, key ContextKey) time.Duration
Duration returns the time.Duration value associated with the given context key. If the key is not present in the context, it returns 0.
func FileReadSeekCloser ¶
func FileReadSeekCloser(fs FS, path string) (io.ReadSeekCloser, error)
func FileWriteCloser ¶
func Int ¶
func Int(ctx context.Context, key ContextKey) int
Int returns the int value associated with the given context key. If the key is not present in the context, it returns 0.
func IsPathSeparator ¶
func Join ¶
Join joins any number of path elements into a single path, separating them with slashes.
func RemoveAll ¶
func RemoveAll(fs WalkRemoveFS, path string) error
func RunTestSuiteRO ¶
RunTestSuiteRO runs comprehensive read-only tests for FS implementations
func RunTestSuiteRW ¶
RunTestSuiteRW runs comprehensive read-write tests for FS implementations
func SetExtendedAttrs ¶
func SetExtendedAttrs(fs SetExtendedAttrFS, path string, attrs Attributes) error
Types ¶
type AdvancedFS ¶
type AdvancedFS interface {
OpenFileFS
HandleResolveFS
SetExtendedAttrsFS
ChecksumFS
}
type AdvancedLinkFS ¶
type Attributes ¶
func (Attributes) Delete ¶
func (a Attributes) Delete(name string)
func (Attributes) Set ¶
func (a Attributes) Set(name string, value []byte)
func (Attributes) SetString ¶
func (a Attributes) SetString(name, value string)
type ChecksumFS ¶ added in v0.0.25
type ContextKey ¶
type ContextKey string
type FS ¶
type FS interface {
Stat(path string) (FileInfo, error)
List(path string) (ListerAt, error)
FileRead(path string) (ReaderAt, error)
FileWrite(path string, flags int) (WriterAt, error)
Chmod(path string, mode os.FileMode) error
Chown(path string, uid, gid int) error
Chtimes(path string, atime, mtime time.Time) error
Truncate(path string, size int64) error
SetExtendedAttr(path string, name string, value []byte) error
UnsetExtendedAttr(path string, name string) error
Rename(oldpath, newpath string) error
Rmdir(path string) error
Remove(path string) error
Mkdir(path string, perm os.FileMode) error
Close() error
}
FS interface Implementing file systems should implement all methods.
type File ¶
type FileInfo ¶
type FileInfo interface {
os.FileInfo
Uid() uint32
Gid() uint32
NumLinks() uint64
Extended() (Attributes, error)
Permissions() (*Permissions, error) // Returns an indicative permission set to indicate which permissions the client has
}
type FileInfoListerAt ¶
type FileInfoListerAt []FileInfo
func (FileInfoListerAt) Close ¶
func (f FileInfoListerAt) Close() error
type HandleFileInfo ¶ added in v0.0.24
type HandleResolveFS ¶
type NotImplementedAdvancedFS ¶
type NotImplementedAdvancedFS struct {
NotImplementedFS
}
func (NotImplementedAdvancedFS) Handle ¶
func (n NotImplementedAdvancedFS) Handle(path string) ([]byte, error)
func (NotImplementedAdvancedFS) Open ¶
func (n NotImplementedAdvancedFS) Open(path string) (File, error)
type NotImplementedFS ¶
type NotImplementedFS struct{}
Base for partial implementations
func (NotImplementedFS) Chmod ¶
func (n NotImplementedFS) Chmod(path string, mode os.FileMode) error
func (NotImplementedFS) Chtimes ¶
func (n NotImplementedFS) Chtimes(path string, atime, mtime time.Time) error
func (NotImplementedFS) Close ¶
func (n NotImplementedFS) Close() error
func (NotImplementedFS) FileRead ¶
func (n NotImplementedFS) FileRead(path string) (ReaderAt, error)
func (NotImplementedFS) FileWrite ¶
func (n NotImplementedFS) FileWrite(path string, flag int) (WriterAt, error)
func (NotImplementedFS) Mkdir ¶
func (n NotImplementedFS) Mkdir(path string, perm os.FileMode) error
func (NotImplementedFS) Remove ¶
func (n NotImplementedFS) Remove(path string) error
func (NotImplementedFS) Rename ¶
func (n NotImplementedFS) Rename(oldpath, newpath string) error
func (NotImplementedFS) Rmdir ¶
func (n NotImplementedFS) Rmdir(path string) error
func (NotImplementedFS) SetExtendedAttr ¶
func (n NotImplementedFS) SetExtendedAttr(path, name string, value []byte) error
func (NotImplementedFS) SetExtendedAttrs ¶
func (n NotImplementedFS) SetExtendedAttrs(path string, attrs Attributes) error
func (NotImplementedFS) Truncate ¶
func (n NotImplementedFS) Truncate(path string, size int64) error
func (NotImplementedFS) UnsetExtendedAttr ¶
func (n NotImplementedFS) UnsetExtendedAttr(path, name string) error
type NotImplementedRootFS ¶
type NotImplementedRootFS struct {
NotImplementedAdvancedFS
}
func (NotImplementedRootFS) Link ¶
func (n NotImplementedRootFS) Link(path, target string) error
func (NotImplementedRootFS) Lstat ¶
func (n NotImplementedRootFS) Lstat(path string) (FileInfo, error)
func (NotImplementedRootFS) Mount ¶
func (n NotImplementedRootFS) Mount(path string, fs FS, index byte) error
func (NotImplementedRootFS) Readlink ¶
func (n NotImplementedRootFS) Readlink(path string) (string, error)
func (NotImplementedRootFS) RealPath ¶
func (n NotImplementedRootFS) RealPath(path string) (string, error)
func (NotImplementedRootFS) Symlink ¶
func (n NotImplementedRootFS) Symlink(path, target string) error
type OpenFileFS ¶
type OpenableFS ¶
type Permissions ¶
type SetExtendedAttrFS ¶
type SetExtendedAttrsFS ¶
type SetExtendedAttrsFS interface {
FS
SetExtendedAttrs(path string, attrs Attributes) error
}
type WalkRemoveFS ¶
type WalkRemoveFS interface {
WalkableFS
Remove(path string) error
Rmdir(path string) error
}