cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
redbear-usb-hotplugd
USB device hotplug daemon — port scanning, debounce state machine, and driver dispatch.
Status: FEATURE-INCOMPLETE
Category: system
Build: cargo template — compiled as part of build-redbear.sh redbear-full
Purpose
Monitors all USB host controllers for device connect/disconnect events and spawns
the appropriate driver daemon when a new device is detected. Implements the USB 2.0
§7.1.7.3 connect debounce requirement (100ms stable, 2000ms timeout) and follows
Linux 7.1's hub_port_connect_change() / hub_port_debounce() algorithm.
Interface
- Scheme: None — scans
/scheme/usb/<controller>/for ports - Init service: Spawned as a system daemon (not a static init service wired in recipe.toml; launched via init config
[services]) - Configuration: Driver dispatch table is compiled-in (
DRIVER_MAPinsrc/main.rs)
Architecture
| File | Purpose |
|---|---|
src/main.rs |
Daemon entry — scans controllers, enumerates ports, debounces connections, reads descriptors, dispatches drivers |
Dependencies: redox_syscall, libredox, xhcid, common. All path deps to local forks.
Driver dispatch table (class, subclass → binary):
| Class | Subclass | Driver | Device Type |
|---|---|---|---|
| 0x01 | 0x01, 0x02 | redbear-usbaudiod |
USB Audio |
| 0x02 | 0x02 | redbear-acmd |
CDC ACM (serial) |
| 0x02 | 0x06 | redbear-ecmd |
CDC ECM (Ethernet) |
| 0x02 | 0xFF | redbear-acmd |
CDC ACM (vendor) |
| 0x03 | 0x00, 0x01 | usbhidd |
HID (keyboard/mouse) |
| 0x08 | 0x06 | usbscsid |
Mass Storage (BOT) |
| 0x09 | 0x00 | usbhubd |
USB Hub |
| 0xFF | 0x00, 0xFF | redbear-ftdi |
FTDI (vendor) |
Port state machine (Linux 7.1 hub.c equivalent):
- Disconnected → port scanned, no device present
- DebouncingConnect — 25ms-step polling, 100ms stable required, 2000ms timeout
- Connected — device present, descriptors read, driver spawned
- Active — driver child process monitored for exit; disconnect → kill child
Consumers
- System init — launches
redbear-usb-hotplugdas a persistent daemon - All USB class drivers (
redbear-acmd,redbear-ecmd,redbear-ftdi,redbear-usbaudiod,usbhidd,usbscsid,usbhubd) are spawned by this daemon
Status Notes
- Compiles against the current kernel/xhcid forks.
- Debounce state machine is fully implemented with timing constants matching Linux 7.1.
- Controller scanning walks
/scheme/usb/for*_xhci,*_ehci,*_ohci,*_uhcidirectories. - Port scanning recursively discovers all
port<N>nodes under each controller. - Driver dispatch uses a static compiled-in table — no runtime configuration or TOML policy surface yet.
- No runtime validation on bare metal with real hotplug events. QEMU with USB passthrough is the expected test path.
- Driver respawn on exit is handled (child process → re-enter Connected state).