debugfs

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

debugfs

Go helpers for reading Linux debugfs data.

This module provides a small set of composable primitives for resolving files under a debugfs mount, reading pseudo-files safely, decoding typed values, and building subsystem-specific readers on top.

The module path is defined in go.mod.

This project is licensed under the Apache License 2.0. See LICENSE.

API documentation lives in the Go package docs so it stays close to the code and renders cleanly in go doc and pkg.go.dev:

https://pkg.go.dev/github.com/vexxhost/debugfs

Documentation

Overview

Package debugfs resolves files under a Linux debugfs mount.

The package intentionally stays close to filesystem primitives. FS uses the standard library io/fs path model for names and globbing, resolves them under a configured debugfs mount point, and returns file.File values. Bounded pseudo-file reads live in package file. Typed decoding lives in package value, and subsystem-specific readers live in packages such as kvm.

A direct read starts with DefaultFS or NewFS, then uses the returned file.File:

dfs, err := debugfs.DefaultFS()
if err != nil {
	return err
}

file, err := dfs.Open("kvm", "1234-16", "nested_run")
if err != nil {
	return err
}

raw, err := file.ReadAll()

For typed values, use package value. For KVM-specific data, use package kvm.

Index

Constants

View Source
const (
	// DefaultMountPoint is the conventional Linux debugfs mount point.
	DefaultMountPoint = "/sys/kernel/debug"
)

Variables

View Source
var ErrInvalidPath = errors.New("invalid debugfs path")

ErrInvalidPath reports a path that cannot be resolved under an FS mount point.

Functions

This section is empty.

Types

type FS

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

FS resolves debugfs files relative to a mount point.

func DefaultFS

func DefaultFS() (FS, error)

DefaultFS returns an FS rooted at DefaultMountPoint.

func NewFS

func NewFS(mountPoint string) (FS, error)

NewFS returns an FS rooted at mountPoint.

func (FS) Glob

func (fs FS) Glob(elem ...string) ([]debugfile.File, error)

Glob returns files matching a pattern under the debugfs mount point.

func (FS) MountPoint

func (fs FS) MountPoint() string

MountPoint returns the debugfs mount point used by fs.

func (FS) Open

func (fs FS) Open(elem ...string) (debugfile.File, error)

Open resolves elem under fs and returns the resulting debugfs file.

Directories

Path Synopsis
Package file provides bounded reads for resolved debugfs pseudo-files.
Package file provides bounded reads for resolved debugfs pseudo-files.
Package kvm reads KVM-specific debugfs data.
Package kvm reads KVM-specific debugfs data.
Package value decodes typed values from resolved debugfs files.
Package value decodes typed values from resolved debugfs files.

Jump to

Keyboard shortcuts

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