internal/kobject: process uevent
All checks were successful
Test / Create distribution (push) Successful in 2m38s
Test / Sandbox (push) Successful in 2m49s
Test / ShareFS (push) Successful in 3m44s
Test / Hakurei (push) Successful in 4m0s
Test / Sandbox (race detector) (push) Successful in 5m24s
Test / Hakurei (race detector) (push) Successful in 6m32s
Test / Flake checks (push) Successful in 1m21s

This tracks kernel state by merging a stream of uevent. Inconsistencies are reported and recovered from gracefully.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-25 13:10:30 +09:00
parent 3458806685
commit fadd1b14f7
9 changed files with 2533 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package kobject
import (
"errors"
"maps"
"strconv"
"strings"
"unsafe"
@@ -28,6 +29,22 @@ type Event struct {
Subsystem string `json:"subsystem"`
}
// Clone returns a copy of e.
func (e *Event) Clone() Event {
v := *e
v.Env = maps.Clone(e.Env)
return v
}
// makeColdboot allocates a new [Object] from e in [StateColdboot].
func (e *Event) makeColdboot() *Object {
return &Object{
State: StateColdboot,
DevPath: e.DevPath,
Subsystem: e.Subsystem,
}
}
// Populate populates e with the contents of a [uevent.Message].
//
// The ACTION and DEVPATH environment variables are ignored and assumed to be