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
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user