linux

package
v6.0.1-0...-ae41ae8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ABSTRACT_UNIX_SOCK_LEN int = C.ABSTRACT_UNIX_SOCK_LEN
View Source
const CLOSE_RANGE_CLOEXEC uint32 = C.CLOSE_RANGE_CLOEXEC
View Source
const CLOSE_RANGE_UNSHARE uint32 = C.CLOSE_RANGE_UNSHARE
View Source
const (
	FilesystemSuperMagicZfs = 0x2fc12fc1
)

Filesystem magic numbers.

View Source
const SystemdListenFDsStart = 3

SystemdListenFDsStart is the number of the first file descriptor that might have been opened by systemd when socket activation is enabled. It's always 3 in real-world usage (i.e. the first file descriptor opened after stdin, stdout and stderr), so this constant should always be the value passed to GetListeners, except for unit tests.

Variables

This section is empty.

Functions

func AvailableStorageDrivers

func AvailableStorageDrivers(path string, supportedDrivers []api.ServerStorageDriverInfo, poolType util.PoolType) []string

AvailableStorageDrivers returns a list of storage drivers that are available.

func CloseRange

func CloseRange(FirstFd uint32, LastFd uint32, Flags uint32) error

func CreateMemfd

func CreateMemfd(content []byte) (*os.File, error)

CreateMemfd creates a new memfd for the provided byte slice.

func DetectFilesystem

func DetectFilesystem(path string) (string, error)

DetectFilesystem returns the filesystem on which the passed-in path sits.

func DeviceTotalMemory

func DeviceTotalMemory() (int64, error)

DeviceTotalMemory returns the total amount of memory on the system (in bytes).

func ExitStatus

func ExitStatus(err error) (int, error)

ExitStatus extracts the exit status from the error returned by exec.Cmd. If a nil err is provided then an exit status of 0 is returned along with the nil error. If a valid exit status can be extracted from err then it is returned along with a nil error. If no valid exit status can be extracted then a -1 exit status is returned along with the err provided.

func FSTypeToName

func FSTypeToName(fsType int32) (string, error)

FSTypeToName returns the name of the given fs type. The fsType is from the Type field of unix.Statfs_t. We use int32 so that this function behaves the same on both 32bit and 64bit platforms by requiring any 64bit FS types to be overflowed before being passed in. They will then be compared with equally overflowed FS type constant values.

func GetAllXattr

func GetAllXattr(path string) (map[string]string, error)

GetAllXattr retrieves all extended attributes associated with a file, directory or symbolic link.

func GetErrno

func GetErrno(err error) (errno error, iserrno bool)

GetErrno checks if the Go error is a kernel errno.

func GetMeminfo

func GetMeminfo(field string) (int64, error)

GetMeminfo parses /proc/meminfo for the specified field.

func GetMountinfo

func GetMountinfo(path string) ([]string, error)

GetMountinfo tracks down the mount entry for the path and returns all MountInfo fields.

func GetPollRevents

func GetPollRevents(fd int, timeout int, flags int) (int, int, error)

GetPollRevents poll for events on provided fd.

func GetSystemdListeners

func GetSystemdListeners(start int) []net.Listener

GetSystemdListeners returns the socket-activated network listeners, if any.

The 'start' parameter must be SystemdListenFDsStart, except in unit tests, see the docstring of SystemdListenFDsStart below.

func GetUcred

func GetUcred(conn *net.UnixConn) (*unix.Ucred, error)

GetUcred returns the credentials from the remote end of a unix socket.

func IsBlockdev

func IsBlockdev(fm os.FileMode) bool

IsBlockdev checks if the provided file is a block device.

func IsBlockdevPath

func IsBlockdevPath(pathName string) bool

IsBlockdevPath checks if the provided path is a block device.

func IsMountPoint

func IsMountPoint(path string) bool

IsMountPoint returns true if path is a mount point.

func LoadModule

func LoadModule(module string) error

LoadModule loads the kernel module with the given name, by invoking modprobe. This respects any modprobe configuration on the system.

func NewExecWrapper

func NewExecWrapper(ctx context.Context, f *os.File) io.ReadWriteCloser

NewExecWrapper returns a new ReadWriteCloser wrapper for an os.File. The ctx is used to indicate when the executed process has ended, at which point any further Read calls will return io.EOF rather than potentially blocking on the poll syscall if the process is a shell that still has background processes running that are not producing any output.

func OpenPty

func OpenPty(uid, gid int64) (*os.File, *os.File, error)

OpenPty creates a new PTS pair, configures them and returns them.

func OpenPtyInDevpts

func OpenPtyInDevpts(devpts_fd int, uid, gid int64) (*os.File, *os.File, error)

OpenPtyInDevpts creates a new PTS pair, configures them and returns them.

func PathNameDecode

func PathNameDecode(text string) string

PathNameDecode decodes a string containing an encoded path back to its original form. The decoding scheme converts "-" back to "/" and "--" back to "-".

func PathNameEncode

func PathNameEncode(text string) string

PathNameEncode encodes a path string to be used as part of a file name. The encoding scheme replaces "-" with "--" and then "/" with "-".

func PidFdOpen

func PidFdOpen(Pid int, Flags uint32) (*os.File, error)

func PidfdSendSignal

func PidfdSendSignal(Pidfd int, Signal int, Flags uint32) error

func ReadPid

func ReadPid(r *os.File) int

func ResolveMountOptions

func ResolveMountOptions(options []string) (uintptr, string)

ResolveMountOptions resolves the provided mount options.

func RunningInUserNS

func RunningInUserNS() bool

func SetPtySize

func SetPtySize(fd int, width int, height int) (err error)

SetPtySize issues the correct ioctl to resize a pty.

func StatVFS

func StatVFS(path string) (*unix.Statfs_t, error)

StatVFS retrieves Virtual File System (VFS) info about a path.

func SyncFS

func SyncFS(path string) error

SyncFS will force a filesystem sync for the filesystem backing the provided path.

Types

type Utsname

type Utsname struct {
	Sysname    string
	Nodename   string
	Release    string
	Version    string
	Machine    string
	Domainname string
}

Utsname returns the same info as unix.Utsname, as strings.

func Uname

func Uname() (*Utsname, error)

Uname returns Utsname as strings.

Jump to

Keyboard shortcuts

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