common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestOverrideRuntimeDirKey = "ATOMFS_TEST_RUN_DIR"

Functions

func AmHostRoot

func AmHostRoot() bool

func EnsureDir

func EnsureDir(dir string) error

func FileChanged

func FileChanged(a os.FileInfo, path string) bool

func GetBackingDevice

func GetBackingDevice(mountpoint string) (string, error)

func GetMountNSName

func GetMountNSName() (string, error)

func GuestMount

func GuestMount(fsImgFile string, mountpoint string, fuseCmd FuseCmd) error

Mount a filesystem as container root, without host root privileges. We do this using fuse "cmd" which is passed in from actual filesystem backends.

func HostMount

func HostMount(fsImgFile string, fsType string, mountpoint string, rootHash string, veritySize int64, verityOffset uint64) error

func IsEmptyDir

func IsEmptyDir(path string) (bool, error)

func IsMountedAtDir

func IsMountedAtDir(_, dest string) (bool, error)

func IsMountpoint

func IsMountpoint(dest string) bool

func MaybeCleanupBackingDevice

func MaybeCleanupBackingDevice(devPath string) error

given a device path that had been used as the backing device for a squash mountpoint, cleans up and detaches verity device if it still exists.

If the device path does not exist, that is OK - this happens if the device was a regular loopback and not -verity.

func PathExists

func PathExists(d string) bool

func ReplacePathSeparators

func ReplacePathSeparators(p string) string

remove dir separators to make one dir name. It is OK that this can't be cleanly backed out, we don't need it to

func RuntimeDir

func RuntimeDir(metadir string) string

Allow overriding runtime dir for tests so we can assert empty dirs, etc.

func Umount

func Umount(mountpoint string) error

unmounts a squash mountpoint and detaches any verity / loop devices that back it. Only use this if you are sure the underlying devices aren't in use by other mount points.

func Which

func Which(name string) string

Which - like the unix utility, return empty string for not-found. this might fit well in lib/, but currently lib's test imports squashfs creating a import loop.

Types

type ExcludePaths

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

ExcludePaths represents a list of paths to exclude in a filesystem listing. Users should do something like filepath.Walk() over the whole filesystem, calling AddExclude() or AddInclude() based on whether they want to include or exclude a particular file. Note that if e.g. /usr is excluded, then everyting underneath is also implicitly excluded. The AddExclude()/AddInclude() methods do the math to figure out what is the correct set of things to exclude or include based on what paths have been previously included or excluded.

func NewExcludePaths

func NewExcludePaths() *ExcludePaths

func (*ExcludePaths) AddExclude

func (eps *ExcludePaths) AddExclude(p string)

func (*ExcludePaths) AddInclude

func (eps *ExcludePaths) AddInclude(orig string, isDir bool)

func (*ExcludePaths) String

func (eps *ExcludePaths) String() (string, error)

type FuseCmd

type FuseCmd func(fsImgFile, extractDir string) (*exec.Cmd, error)

Jump to

Keyboard shortcuts

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