aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/kobject/event.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-25 13:10:30 +0900
committerOphestra <cat@gensokyo.uk>2026-05-25 21:31:59 +0900
commitfadd1b14f77e2dfdc4e3f7f61bee5b22ccf66e2f (patch)
treea2e79190931677c4cb5ef6f87fc38866976e2adf /internal/kobject/event.go
parent345880668510be449524f615d7305ccf5f4da239 (diff)
internal/kobject: process uevent
This tracks kernel state by merging a stream of uevent. Inconsistencies are reported and recovered from gracefully. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/kobject/event.go')
-rw-r--r--internal/kobject/event.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/kobject/event.go b/internal/kobject/event.go
index 33cb91b8..38728599 100644
--- a/internal/kobject/event.go
+++ b/internal/kobject/event.go
@@ -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