forked from rosa/hakurei
internal/uevent: enumerate objects via sysfs
This is not a great way to implement cold boot, but I already have the implementation lying around. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -19,6 +19,10 @@ const (
|
||||
KOBJ_OFFLINE
|
||||
KOBJ_BIND
|
||||
KOBJ_UNBIND
|
||||
|
||||
// Synthetic denotes a [Message] that originates from outside the kernel. It
|
||||
// is not valid in the wire format and is only meaningful within this package.
|
||||
Synthetic KobjectAction = 0xfeed
|
||||
)
|
||||
|
||||
// lib/kobject_uevent.c
|
||||
@@ -38,6 +42,10 @@ func (act KobjectAction) Valid() bool { return int(act) < len(kobject_actions) }
|
||||
|
||||
// String returns the corresponding string sent over netlink.
|
||||
func (act KobjectAction) String() string {
|
||||
if act == Synthetic {
|
||||
return "synthetic"
|
||||
}
|
||||
|
||||
if !act.Valid() {
|
||||
return "unsupported kobject_action " + strconv.Itoa(int(act))
|
||||
}
|
||||
@@ -45,7 +53,7 @@ func (act KobjectAction) String() string {
|
||||
}
|
||||
|
||||
func (act KobjectAction) AppendText(b []byte) ([]byte, error) {
|
||||
if !act.Valid() {
|
||||
if !act.Valid() && act != Synthetic {
|
||||
return b, syscall.EINVAL
|
||||
}
|
||||
return append(b, act.String()...), nil
|
||||
|
||||
Reference in New Issue
Block a user