sysutil

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package sysutil provides utilities for getting system-related information.

Index

Constants

View Source
const (
	// ChronosUID is the UID of the user "chronos".
	// A constant is defined since this is unlikely to be changed and since
	// it simplifies tests.
	ChronosUID uint32 = 1000

	// ChronosGID is the GID of the group "chronos", similar to ChronosUID.
	ChronosGID uint32 = 1000
)
View Source
const (
	// SelfPID can be used as an argument of MountInfoForPID to return
	// the result for the current process.
	SelfPID = 0
)

Variables

This section is empty.

Functions

func GetGID

func GetGID(group string) (uint32, error)

GetGID returns the GID corresponding to group.

func GetUID

func GetUID(username string) (uint32, error)

GetUID returns the UID corresponding to username.

func TemperatureInputMax

func TemperatureInputMax() (float64, error)

TemperatureInputMax returns the maximum currently observed temperature in Celsius.

Types

type KernelVersion

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

KernelVersion contains the Linux kernel major and minor revisions.

func KernelVersionAndArch

func KernelVersionAndArch() (*KernelVersion, string, error)

KernelVersionAndArch reads the Linux kernel version and arch of the system.

func (*KernelVersion) Is

func (v *KernelVersion) Is(major, minor int) bool

Is returns true if the kernel version is major.minor else false.

func (*KernelVersion) IsOrLater

func (v *KernelVersion) IsOrLater(major, minor int) bool

IsOrLater returns true if the kernel version is at least major.minor else false.

func (*KernelVersion) IsOrLess

func (v *KernelVersion) IsOrLess(major, minor int) bool

IsOrLess returns true if the kernel version is at most major.minor else false.

type MountInfo

type MountInfo struct {
	MountID       int
	ParentID      int
	Major         int
	Minor         int
	Root          string
	MountPath     string
	MountOpts     MountOpt
	Shared        int // 0 if not shared
	Master        int // 0 if not a slave mount
	PropagateFrom int // 0 if propagated_from is unavailable.
	Unbindable    bool
	Fstype        string
	MountSource   string
	SuperOpts     []string
}

MountInfo is a struct containing mount point info. TODO(chavey): crbug/1126921 - replace master in structure.

func MountInfoForPID

func MountInfoForPID(pid int) ([]MountInfo, error)

MountInfoForPID reads and parses the /proc/${PID}/mountinfo, and returns an array of mount point info for the given process. pid needs to be a valid PID or SelfPID.

func ParseMountInfo

func ParseMountInfo(b []byte) ([]MountInfo, error)

ParseMountInfo parses the content of a mountinfo file using parseLine, and returns an array of mount point info.

type MountOpt

type MountOpt uint32

MountOpt is a bit flag for the mount option.

const (
	// MntReadonly represents "ro".
	MntReadonly MountOpt = 1 << iota
	// MntNosuid represents "nosuid".
	MntNosuid
	// MntNodev represents "nodev".
	MntNodev
	// MntNoexec represents "noexec".
	MntNoexec
	// MntNoatime represents "noatime".
	MntNoatime
	// MntNodiratime represents "nodiratime".
	MntNodiratime
	// MntRelatime represents "relatime".
	MntRelatime
	// MntNosymfollow represents "nosymfollow".
	MntNosymfollow
)

type Utsname

type Utsname struct {
	// Sysname is the operating system name (e.g., "Linux").
	// Corresponds to `uname -s`.
	Sysname string
	// Nodename is the name within "some implementation-defined network".
	// Corresponds to `uname -n`.
	Nodename string
	// Release is the operating system release (e.g., "2.6.28").
	// Corresponds to `uname -r`.
	Release string
	// Version is the operating system version.
	// Corresponds to `uname -v`.
	Version string
	// Machine is the hardware identifier (e.g., "x86_64").
	// Corresponds to `uname -m`.
	Machine string
	// Domainname is the NIS or YP domain name. This is nonstandard GNU/Linux extension.
	Domainname string
}

Utsname contains system information.

func Uname

func Uname() (*Utsname, error)

Uname is a wrapper of uname system call. See man 2 uname.

Jump to

Keyboard shortcuts

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