Help us shape the future of Go! Take the 2026 Go Developer Survey

rootfs

package
v0.19.1278 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package rootfs provides an Afero filesystem pinned to an OS directory handle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveFS

func RemoveFS(backing afero.Fs, parentPath, name string) error

RemoveFS removes one directory without following its final symlink, including after failed initialization has closed the job handles. parentPath is trusted.

Types

type Billy

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

Billy adapts a borrowed Afero filesystem for go-git. Close releases only the child handles opened by Chroot, not the borrowed filesystem.

func NewBilly

func NewBilly(fs afero.Fs) *Billy

func (*Billy) Chmod

func (b *Billy) Chmod(name string, mode os.FileMode) error

func (*Billy) Chroot

func (b *Billy) Chroot(name string) (billy.Filesystem, error)

func (*Billy) Close

func (b *Billy) Close() error

func (*Billy) Create

func (b *Billy) Create(name string) (billy.File, error)

func (*Billy) Join

func (b *Billy) Join(elem ...string) string

func (*Billy) Lstat

func (b *Billy) Lstat(name string) (os.FileInfo, error)

func (*Billy) MkdirAll

func (b *Billy) MkdirAll(name string, perm os.FileMode) error

func (*Billy) Open

func (b *Billy) Open(name string) (billy.File, error)

func (*Billy) OpenFile

func (b *Billy) OpenFile(name string, flag int, perm os.FileMode) (billy.File, error)

func (*Billy) ReadDir

func (b *Billy) ReadDir(name string) ([]os.FileInfo, error)
func (b *Billy) Readlink(name string) (string, error)

func (*Billy) Remove

func (b *Billy) Remove(name string) error

func (*Billy) Rename

func (b *Billy) Rename(oldname, newname string) error

func (*Billy) Root

func (b *Billy) Root() string

func (*Billy) Stat

func (b *Billy) Stat(name string) (os.FileInfo, error)
func (b *Billy) Symlink(target, name string) error

func (*Billy) TempFile

func (b *Billy) TempFile(dir, prefix string) (billy.File, error)

type FS

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

FS owns a directory handle. Root is a display path, never an authority for I/O. Names must be relative. Symlink targets are preserved verbatim, but absolute and escaping links cannot be followed, even when they point back into Root.

func Open

func Open(path string) (*FS, error)

Open pins an existing directory, rejecting a symlink at the root itself. Ancestors of path must be trusted; use Sub for untrusted descendants.

func Prepare

func Prepare(parentPath, name string, replace bool) (parent, child *FS, err error)

Prepare creates a private single-component directory under a trusted parent. The caller owns both returned handles and must close both, including on later initialization failure. Existing symlink roots are rejected even with replace.

func PrepareFS

func PrepareFS(backing afero.Fs, parentPath, name string, replace bool) (*FS, afero.Fs, error)

PrepareFS selects the pinned OS backend for nil or OsFs, and a private job namespace for MemMapFs. Other injected backends fail closed rather than accidentally treating a host filesystem as a relative namespace. On success the caller owns the OS parent and child handles, if present.

func (*FS) Chmod

func (f *FS) Chmod(name string, mode os.FileMode) error

func (*FS) Chown

func (f *FS) Chown(name string, uid, gid int) error

func (*FS) Chtimes

func (f *FS) Chtimes(name string, atime, mtime time.Time) error

func (*FS) Close

func (f *FS) Close() error

func (*FS) Create

func (f *FS) Create(name string) (afero.File, error)

func (*FS) LstatIfPossible

func (f *FS) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (*FS) Mkdir

func (f *FS) Mkdir(name string, perm os.FileMode) error

func (*FS) MkdirAll

func (f *FS) MkdirAll(name string, perm os.FileMode) error

func (*FS) Name

func (f *FS) Name() string

func (*FS) Open

func (f *FS) Open(name string) (afero.File, error)

func (*FS) OpenFile

func (f *FS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*FS) ReadlinkIfPossible

func (f *FS) ReadlinkIfPossible(name string) (string, error)

func (*FS) Remove

func (f *FS) Remove(name string) error

func (*FS) RemoveAll

func (f *FS) RemoveAll(name string) error

func (*FS) Rename

func (f *FS) Rename(oldname, newname string) error

func (*FS) Root

func (f *FS) Root() string

func (*FS) Stat

func (f *FS) Stat(name string) (os.FileInfo, error)

func (*FS) Sub

func (f *FS) Sub(name string) (*FS, error)

Sub derives an independently owned handle through the pinned parent, not through its possibly replaced display path. Closing either handle does not close the other.

func (*FS) SymlinkIfPossible

func (f *FS) SymlinkIfPossible(target, name string) error

Jump to

Keyboard shortcuts

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