Documentation
¶
Overview ¶
Package bpffs provides functions to check and mount the BPF filesystem.
Index ¶
Constants ¶
const ( // DefaultMountPoint is the standard location for the BPF // filesystem. DefaultMountPoint = "/sys/fs/bpf" // DefaultMountInfoPath is the path to the mountinfo file. DefaultMountInfoPath = "/proc/self/mountinfo" )
Variables ¶
This section is empty.
Functions ¶
func EnsureMounted ¶
EnsureMounted ensures a bpffs is mounted at mountPoint. It checks mountInfoPath (e.g. /proc/self/mountinfo) for an existing bpf mount at mountPoint; if none is found, it mounts one.
Equivalent to:
if ! findmnt --noheadings --types bpf <mountPoint>; then mount bpffs <mountPoint> -t bpf fi
func IsMounted ¶
IsMounted reports whether a bpffs is mounted at mountPoint by parsing mountInfoPath (e.g. /proc/self/mountinfo).
The mountinfo format is documented in proc(5). Each line contains:
mount_id parent_id major:minor root mount_point options [optional_fields...] - fstype source super_options
Example bpffs entry:
30 22 0:27 / /sys/fs/bpf rw,nosuid shared:9 - bpf bpf rw,mode=700
↑ ↑
mount_point (fields[4]) fstype (after " - ")
The key insight from libmount (util-linux) is that the separator " - " must be found using string search, not by assuming a fixed field position. This is because optional fields (like "shared:N" for mount propagation) may be present between the mount options and the separator.
Types ¶
This section is empty.