package fscommon

import "github.com/opencontainers/runc/libcontainer/cgroups/fscommon"

Index

Variables

var (
	ErrNotValidFormat = errors.New("line is not a valid key value format")
)
var (
	// TestMode is set to true by unit tests that need "fake" cgroupfs.
	TestMode bool
)

Functions

func GetCgroupParamInt

func GetCgroupParamInt(path, file string) (int64, error)

GetCgroupParamInt reads a single int64 value from specified cgroup file. If the value read is "max", the math.MaxInt64 is returned.

func GetCgroupParamString

func GetCgroupParamString(path, file string) (string, error)

GetCgroupParamString reads a string from the specified cgroup file.

func GetCgroupParamUint

func GetCgroupParamUint(path, file string) (uint64, error)

GetCgroupParamUint reads a single uint64 value from the specified cgroup file. If the value read is "max", the math.MaxUint64 is returned.

func GetValueByKey

func GetValueByKey(path, file, key string) (uint64, error)

GetValueByKey reads a key-value pairs from the specified cgroup file, and returns a value of the specified key. ParseUint is used for value conversion.

func OpenFile

func OpenFile(dir, file string, flags int) (*os.File, error)

OpenFile opens a cgroup file in a given dir with given flags. It is supposed to be used for cgroup files only.

func ParseKeyValue

func ParseKeyValue(t string) (string, uint64, error)

ParseKeyValue parses a space-separated "name value" kind of cgroup parameter and returns its key as a string, and its value as uint64 (ParseUint is used to convert the value). For example, "io_service_bytes 1234" will be returned as "io_service_bytes", 1234.

func ParseUint

func ParseUint(s string, base, bitSize int) (uint64, error)

ParseUint converts a string to an uint64 integer. Negative values are returned at zero as, due to kernel bugs, some of the memory cgroup stats can be negative.

func ReadFile

func ReadFile(dir, file string) (string, error)

ReadFile reads data from a cgroup file in dir. It is supposed to be used for cgroup files only.

func WriteFile

func WriteFile(dir, file, data string) error

WriteFile writes data to a cgroup file in dir. It is supposed to be used for cgroup files only.

Source Files

fscommon.go open.go utils.go

Version
v1.0.0-rc95
Published
May 19, 2021
Platform
linux/amd64
Imports
11 packages
Last checked
6 minutes ago

Tools for package owners.