Documentation
¶
Overview ¶
Package sysfs reads system metadata with bounded reusable buffers.
Index ¶
- func Bytes(path string) ([]byte, error)
- func DirNames(path string) ([]string, error)
- func Each(data []byte, visit func(key, value string) bool)
- func Field(data []byte, key string) string
- func IsSocket(path string) bool
- func LinkBase(path string) string
- func Path(root, path string) string
- func String(path string) (string, error)
- func Trimmed(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirNames ¶
DirNames lists the entry names of a directory. It uses Readdirnames so the kernel is never asked to stat entries the caller may not care about.
func Each ¶
Each walks a KEY=VALUE file, calling visit for every pair. Returning false from visit stops the walk. Blank lines and # comments are skipped, and matching surrounding quotes are stripped from values.
func Field ¶
Field returns the value of key in a KEY=VALUE file, or "" when it is absent. Nothing is allocated until the key matches.
func IsSocket ¶
IsSocket reports whether path exists and is a unix socket. This is the cheapest possible "is there a display server here" check.
func LinkBase ¶
LinkBase reads a symlink and returns the last element of its target. Sysfs uses this shape everywhere: /sys/class/drm/card0/device points at ../../../0000:00:02.0, whose base is the PCI address.
Types ¶
This section is empty.