internal/uevent: optionally pass UUID during coldboot
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m42s
Test / Hakurei (push) Successful in 3m49s
Test / ShareFS (push) Successful in 3m47s
Test / Sandbox (race detector) (push) Successful in 5m12s
Test / Hakurei (race detector) (push) Successful in 6m20s
Test / Flake checks (push) Successful in 1m20s

This enables rejection of non-coldboot synthetic events.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-06 11:43:16 +09:00
parent a69273ab2a
commit cd0beeaf8e
4 changed files with 184 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import (
"log"
"os"
"path/filepath"
"slices"
)
// synthAdd is prepared bytes written to uevent to cause a synthetic add event
@@ -26,6 +27,7 @@ var synthAdd = []byte(KOBJ_ADD.String())
func Coldboot(
ctx context.Context,
pathname string,
uuid *UUID,
visited chan<- string,
handleWalkErr func(error) error,
) error {
@@ -39,6 +41,11 @@ func Coldboot(
}
}
add := synthAdd
if uuid != nil {
add = slices.Concat(add, []byte{' '}, []byte(uuid.String()))
}
return filepath.WalkDir(filepath.Join(pathname, "devices"), func(
path string,
d fs.DirEntry,
@@ -54,7 +61,7 @@ func Coldboot(
if d.IsDir() || d.Name() != "uevent" {
return nil
}
if err = os.WriteFile(path, synthAdd, 0); err != nil {
if err = os.WriteFile(path, add, 0); err != nil {
return handleWalkErr(err)
}