All checks were successful
Test / Create distribution (push) Successful in 1m13s
Test / Sandbox (push) Successful in 3m1s
Test / Hakurei (push) Successful in 4m9s
Test / ShareFS (push) Successful in 4m17s
Test / Sandbox (race detector) (push) Successful in 5m36s
Test / Hakurei (race detector) (push) Successful in 6m42s
Test / Flake checks (push) Successful in 1m26s
This runs in the Rosa OS init, so recover as much as possible, as otherwise it is likely to require a full system reboot to resume event processing. The caller is responsible for reporting the error. Signed-off-by: Ophestra <cat@gensokyo.uk>
30 lines
828 B
Go
30 lines
828 B
Go
// Package uevent provides userspace client for consuming events from a
|
|
// NETLINK_KOBJECT_UEVENT socket, as well as helpers for supplementing
|
|
// events received from the kernel.
|
|
package uevent
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"hakurei.app/internal/netlink"
|
|
)
|
|
|
|
// Recoverable is satisfied by errors that are safe to recover from.
|
|
type Recoverable interface{ recoverable() }
|
|
|
|
// Conn represents a NETLINK_KOBJECT_UEVENT socket.
|
|
type Conn struct{ conn *netlink.Conn }
|
|
|
|
// Close closes the underlying socket.
|
|
func (c *Conn) Close() error { return c.conn.Close() }
|
|
|
|
// Dial returns the address of a newly connected [Conn].
|
|
func Dial() (*Conn, error) {
|
|
// kernel group is hard coded in lib/kobject_uevent.c, undocumented
|
|
c, err := netlink.Dial(syscall.NETLINK_KOBJECT_UEVENT, 1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Conn{c}, err
|
|
}
|