diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-06 11:43:16 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-06 12:42:47 +0900 |
| commit | cd0beeaf8ed5fb81ba20375517c7a3bf34fd27cd (patch) | |
| tree | a56c41401901878d0fc6beaec4c642ab7a4e5a25 /internal/uevent/coldboot.go | |
| parent | a69273ab2a7040ba906876e6d7888b4edeb74ebc (diff) | |
internal/uevent: optionally pass UUID during coldboot
This enables rejection of non-coldboot synthetic events.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/uevent/coldboot.go')
| -rw-r--r-- | internal/uevent/coldboot.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/uevent/coldboot.go b/internal/uevent/coldboot.go index 07f6497f..660f0284 100644 --- a/internal/uevent/coldboot.go +++ b/internal/uevent/coldboot.go @@ -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) } |
