osfs

package
v0.0.0-...-3a98d3a Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package osfs provides OS Filesystem access.

Index

Constants

This section is empty.

Variables

View Source
var LstatSemaphore = semaphore.New("osfs-lstat", runtimex.NumCPU()*2)

LstatSemaphore is a semaphore to control concurrent lstat, to protect from thread exhaustion. b/365856347

Functions

func HelperCmd

func HelperCmd() *subcommands.Command

Types

type FileSource

type FileSource struct {
	Fname string
	// contains filtered or unexported fields
}

FileSource is a file source.

func (FileSource) FileDigestFromXattr

func (fsc FileSource) FileDigestFromXattr(ctx context.Context) (digest.Digest, error)

FileDigestFromXattr returns file's digest via xattr if possible.

func (FileSource) IsLocal

func (FileSource) IsLocal()

IsLocal indicates FileSource is local file source.

func (FileSource) Open

func (fsc FileSource) Open(ctx context.Context) (io.ReadCloser, error)

Open opens the named file for reading.

func (FileSource) String

func (fsc FileSource) String() string

type OSFS

type OSFS struct {
	*iometrics.IOMetrics
	// contains filtered or unexported fields
}

OSFS provides OS Filesystem access. It counts metrics by iometrics. It would be an interface to communicate local filesystem server, in addition to local filesystem.

func New

func New(ctx context.Context, name string, opt Option) *OSFS

New creates new OSFS.

func (*OSFS) AsFileSource

func (*OSFS) AsFileSource(ds digest.Source) (FileSource, bool)

AsFileSource asserts digest.Source value holds FileSource type, and return bool whether it holds or not.

func (*OSFS) Chmod

func (ofs *OSFS) Chmod(ctx context.Context, name string, mode fs.FileMode) error

Chmod changes the mode of the named file to mode.

func (*OSFS) Chtimes

func (ofs *OSFS) Chtimes(ctx context.Context, name string, atime, mtime time.Time) error

Chtimes changes the access and modification times of the named file.

func (*OSFS) FileDigestFromXattr

func (ofs *OSFS) FileDigestFromXattr(ctx context.Context, name string, size int64) (digest.Digest, error)

FileDigestFromXattr returns file's digest via xattr if possible.

func (*OSFS) FileSource

func (ofs *OSFS) FileSource(name string, size int64) FileSource

FileSource creates new FileSource for name. For FileDigestFromXattr, if size is non-negative, it will be used. If size is negative, it will check file info.

func (*OSFS) Lstat

func (ofs *OSFS) Lstat(ctx context.Context, fname string) (fs.FileInfo, error)

Lstat returns a FileInfo describing the named file.

func (*OSFS) MkdirAll

func (ofs *OSFS) MkdirAll(ctx context.Context, dirname string, perm fs.FileMode) error

MkdirAll creates a directory named path, along with any necessary parents.

func (ofs *OSFS) Readlink(ctx context.Context, name string) (string, error)

Readlink returns the destination of the named symbolic link.

func (*OSFS) Remove

func (ofs *OSFS) Remove(ctx context.Context, name string) error

Remove removes the named file or directory.

func (*OSFS) Rename

func (ofs *OSFS) Rename(ctx context.Context, oldpath, newpath string) error

Rename renames oldpath to newpath.

func (ofs *OSFS) Symlink(ctx context.Context, oldname, newname string) error

Symlink creates newname as a symbolic link to oldname.

func (*OSFS) WriteDigestData

func (ofs *OSFS) WriteDigestData(ctx context.Context, name string, src digest.Source, perm fs.FileMode) error

WriteDigestData writes digest source into the named file.

func (*OSFS) WriteFile

func (ofs *OSFS) WriteFile(ctx context.Context, name string, data []byte, perm fs.FileMode) error

WriteFile writes data to the named file, creating it if necessary.

type Option

type Option struct {
	// DigestXattrName is xattr name for digest. When it is set, try to retrieve digest from the xattr.
	DigestXattrName string
}

Option is an option for osfs.

func (*Option) RegisterFlags

func (o *Option) RegisterFlags(flagSet *flag.FlagSet)

Jump to

Keyboard shortcuts

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