internal/uevent: wrap netlink socket
All checks were successful
Test / Create distribution (push) Successful in 1m18s
Test / Sandbox (push) Successful in 3m13s
Test / Hakurei (push) Successful in 4m14s
Test / ShareFS (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 5m37s
Test / Hakurei (race detector) (push) Successful in 6m41s
Test / Flake checks (push) Successful in 1m26s
All checks were successful
Test / Create distribution (push) Successful in 1m18s
Test / Sandbox (push) Successful in 3m13s
Test / Hakurei (push) Successful in 4m14s
Test / ShareFS (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 5m37s
Test / Hakurei (race detector) (push) Successful in 6m41s
Test / Flake checks (push) Successful in 1m26s
Unfortunately these messages do not have the same format as rtnetlink. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
26
internal/uevent/uevent.go
Normal file
26
internal/uevent/uevent.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user