tpt-linux-hw

Rust

Async, unified Linux hardware discovery — sysfs walking, PCI/USB/block enumeration, and netlink event streaming in pure Rust. MIT OR Apache-2.0.

0 stars0 forks0 watchers

Languages

Rust100.0%
README

tpt-linux-hw

License: MIT OR Apache-2.0 Rust CI MSRV

TPT Solutions — Linux Hardware Discovery & Event Management

A workspace of small, focused, pure-Rust crates that provide a unified, async-friendly abstraction over Linux hardware discovery: sysfs walking, block/PCI/USB enumeration, ACPI table parsing, netlink udev event streaming, and udev rule evaluation — replacing the fragmented lshw/lsblk/lspci/ lsusb + libudev suite with one consistent API.

Design principles

  • Pure Rust for new surface area — async netlink events and unified enumeration are implemented without FFI; well-covered ground is not reinvented.
  • Resilient to kernel quirks — sysfs parsing uses Option<T> and graceful degradation; malformed content never panics.
  • Async event streaming — hardware events are exposed as tokio::sync::mpsc streams.
  • Explicit privilege model — every privileged operation surfaced as a distinct, well-typed error variant rather than a generic I/O error.

Crates

CrateDescriptionPrivilege
tpt-l-sysfs-walkerTraverse /sys, resolve symlink trees, parse uevent/attributesunprivileged
tpt-l-mountinfoZero-alloc parser for /proc/self/mountinfo and /etc/fstabunprivileged
tpt-l-hwdb-readerPure-Rust reader for the systemd hwdb binary trieunprivileged
tpt-l-pci-enumeratorEnumerate /sys/bus/pci + config spaceunpriv (sysfs) / CAP_SYS_ADMIN (config)
tpt-l-usb-enumeratorEnumerate /sys/bus/usb + descriptorsunprivileged
tpt-l-block-deviceUnified block-device abstractionunprivileged
tpt-l-netlink-udevudev events over NETLINK_KOBJECT_UEVENTmay need CAP_NET_ADMIN
tpt-l-udev-rulesParser/evaluator for /etc/udev/rules.dunpriv (parse); RUN{} caller-controlled
tpt-l-acpi-parserACPI table discovery + static field extractionunprivileged
tpt-l-hw-cliUnified CLI (list pci/usb/block/mounts, watch)see subcommands

Building

cargo build --workspace
cargo test --workspace

Usage

The tpt-hw binary unifies discovery:

# Human-readable listings
tpt-hw list pci
tpt-hw list usb
tpt-hw list block
tpt-hw list mounts

# Structured output
tpt-hw list pci --json
tpt-hw list usb --yaml

# Live event stream (Linux; needs NETLINK_KOBJECT_UEVENT)
tpt-hw watch
tpt-hw watch --json

# Opt into privileged operations (e.g. raw PCI config space) — explicit & acknowledged
tpt-hw list pci --privileged

Note: --privileged only enables operations that require CAP_SYS_ADMIN / root. Unprivileged enumeration works without it.

Status

PhaseStatus
0 — Workspace bootstrapdone
1 — Core discovery & parsingdone
2 — Device enumeratorsdone
3 — Event handling & rulesdone (ACPI AML interpreter deferred to Milestone B)
4 — CLI integrationdone
5 — Docs & polishdone

License

Licensed under either of MIT or Apache-2.0 at your option.