Documentation ¶
Overview ¶
Package fileutils contains utilities and helpers to manage and manipulate files.
Index ¶
- func CheckFileDigest(path string, digest string) bool
- func CopyFileContainer(src string, dest string) error
- func DiscUsageMegaBytes(path string) (string, error)
- func Exist(path string) bool
- func GetFileDigest(path string) string
- func Mount(src, dest string, mode uintptr) error
- func MountBind(src, dest string) error
- func MountBindRO(src, dest string) error
- func MountCgroup(dest string) error
- func MountDevPts(dest string) error
- func MountMqueue(dest string) error
- func MountProc(dest string) error
- func MountShm(dest string) error
- func MountTmpfs(dest string) error
- func ReadFile(path string) ([]byte, error)
- func Umount(dest string) error
- func UntarFile(path string, target string, userns string) error
- func WriteFile(path string, content []byte, perm uint32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFileDigest ¶
CheckFileDigest will compare input digest to the checksum of input file. Returns whether the input digest is equal to the input file's one.
func CopyFileContainer ¶
CopyFileContainer will copy file from src to dest.
func DiscUsageMegaBytes ¶
DiscUsageMegaBytes returns disk usage for input path in MB (rounded).
func GetFileDigest ¶
GetFileDigest will return the sha256sum of input file. Empty if error occurs.
func MountBind ¶
MountBind will bind-mount src path in dest path. Said mount will be created with mode: rbind,rprivate.
func MountBindRO ¶
MountBindRO will bind-mount read-only src path in dest path. Said mount will be created with mode: rbind,rprivate,ro,nosuid,noexec,nodev.
func MountCgroup ¶
MountCgroup will mount a new cgroup/cgroup2 fs on dest.
func MountDevPts ¶
MountDevPts will mount a new devpts in dest path. Said mount will be created with mode: noexec,nosuid,newinstance,ptmxmode=0666,mode=0620.
func MountMqueue ¶
MountMqueue will mount a new mqueue tmpfs in dest path. Said mount will be created with mode: noexec,nosuid,nodev.
func MountProc ¶
MountProc will mount a new procfs in dest path. Said mount will be created with mode: noexec,nosuid,nodev.
func MountShm ¶
MountShm will mount a new shm tmpfs to dest path. Said mount will be created with mode: noexec,nosuid,nodev,mode=1777,size=65536k.
func MountTmpfs ¶
MountTmpfs will mount a new tmpfs in dest path.
func ReadFile ¶
ReadFile will return the content of input file or error. This is a linux-only implementation using syscalls for performance benefits.
Types ¶
This section is empty.