sysfs

package
v1.13.13 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MPL-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sysfs reads attributes from the sysfs filesystem.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidReadCount = errors.New("invalid read count")

ErrInvalidReadCount is returned when a read reports a byte count outside the buffer it was given.

A sysfs show() callback returning a negative value which is not an errno makes read(2) return it as is, and the Go standard library passes it through as the byte count, so os.ReadFile and io.ReadAll panic with "slice bounds out of range".

Functions

func CPUFreqStats

func CPUFreqStats(root string) ([]*machine.CPUFreqStats, error)

CPUFreqStats returns the current, minimum and maximum frequency (in kHz) and the governor of each online CPU, in CPU number order, read from sysfs mounted at root.

A CPU which has no cpufreq policy, or whose frequency cannot be read, gets empty stats.

func ReadAll

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads from r until EOF.

Unlike io.ReadAll, it returns ErrInvalidReadCount instead of panicking when r returns a byte count outside the buffer it was given.

func ReadFile

func ReadFile(name string) ([]byte, error)

ReadFile reads a sysfs attribute.

Unlike os.ReadFile, it returns an error instead of panicking when the kernel returns a bogus byte count.

Types

This section is empty.

Jump to

Keyboard shortcuts

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