gosysutils

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 6 Imported by: 0

README

gosysutils

System utility functions (incl. some convenience wrappers for syscall). Explicitly uses only the more modern x/sys/ and not the deprecated syscall library.

For now, only linux/unix is supported (cross platform support will be added as needed).

Documentation

Index

Constants

View Source
const Version = "v0.4.1"

Version exposes the current package version.

Variables

This section is empty.

Functions

func DirExists

func DirExists(dirname string) (bool, error)

DirExists checks whether dirname exists and is a dir (it returns (somehwat peculiar?) true, error if exists but is not a dir)

func DirSize

func DirSize(currentPath string, info os.FileInfo) (int64, error)

DirSize returns the total size in bytes of the dir contents (recursively scanned) Adapted from https://ispycode.com/Blog/golang/2017-01/DU-estimate-file-space-usage work-alike with linux/unix du util

func FileExists

func FileExists(filename string) (bool, error)

FileExists checks whether filename exists and is a (regular) file (it returns (somehwat peculiar?) true, error if exists but is a dir)

func FileFallocate

func FileFallocate(filepath string, size int64, mode os.FileMode, force bool) error

func FsStatFromPath

func FsStatFromPath(path string) (*disk.UsageStat, error)

we can use github.com/minio/minio/pkg/disk or github.com/shirou/gopsutil/disk, the latter may be useful for much more so we go with that

func IsSymlink(path string) bool

func LsDirs

func LsDirs(dir string) ([]string, error)

LsDirs returns a string slice of all directory names found in the dir argument

func LsNames

func LsNames(dir string) ([]string, error)

LsNames returns a string slice of all (file) names found in the dir argument, excluding "." and ".."

func LsNamesAbs

func LsNamesAbs(dir string) ([]string, error)

LsNames returns a string slice with the absolute path of all (file) names found in the dir argument, excluding "." and ".."

func MountBind

func MountBind(src, tgt string) error

MountBind bind mounts src on target The calling process needs to run under root for this!

func MountBindAll

func MountBindAll(dirs ...string) error

MountBindAll bind mounts the source dirs in args[:nargs-2] in args[nargs-1], creating mount points based on the source dir names as needed

func ResolveSymlinks(paths []string) ([]string, error)

ResolveSymlinks takes a list of paths and returns the resolved symlinks

func UmountAll

func UmountAll(mpr string) error

UmountAll unmounts all mountpoints under mount point root mpr "not mounted" errors are ignored, other errors are collected and returned

func Unmount

func Unmount(mountpoint string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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