aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-27 17:58:01 +0900
committerOphestra <cat@gensokyo.uk>2026-05-27 17:58:01 +0900
commitb18f40d974ffc33f3703d46bfe42d6fa2f844a01 (patch)
tree1b713d0d797ab99da540d772255009775fe3c1c3 /cmd
parent12a606105124d1ef3133594afb9e6e0bc2e0ad33 (diff)
internal/kobject: pass action kind for range
Useful for handling most uevents. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/earlyinit/main.go8
-rw-r--r--cmd/earlyinit/mount.go6
-rw-r--r--cmd/earlyinit/uevent.go5
3 files changed, 14 insertions, 5 deletions
diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go
index df454e3d..b5e8bcde 100644
--- a/cmd/earlyinit/main.go
+++ b/cmd/earlyinit/main.go
@@ -19,6 +19,7 @@ import (
"hakurei.app/internal/kobject"
"hakurei.app/internal/report"
"hakurei.app/internal/uevent"
+ "hakurei.app/message"
)
var r report.Reporter
@@ -79,6 +80,8 @@ const (
// optionSystem specifies devpath of the system device.
optionSystem = "system"
+ // flagVerbose increases output verbosity.
+ flagVerbose = "verbose"
// flagStrict sets [report.DStrict] on r.
flagStrict = "strict"
// flagNoRecover sets [report.DNoRecover] on r.
@@ -116,6 +119,9 @@ func main() {
r.SetFlags(flag)
}
+ msg := message.New(log.Default())
+ msg.SwapVerbose(slices.Contains(flags, flagVerbose))
+
mustSyscall("mount devtmpfs", Mount(
"devtmpfs",
"/dev/",
@@ -193,7 +199,7 @@ func main() {
must1(rand.Read(uuid[:]))
ctx, cancel := context.WithCancel(context.Background())
- go consume(ctx, &r, conn, uuid, events)
+ go consume(ctx, msg, &r, conn, uuid, events)
s := kobject.New(uuid, func(o *kobject.Object, env map[string]string) {
log.Printf("change %s: %q", o.DevPath, env)
}, func(err error) {
diff --git a/cmd/earlyinit/mount.go b/cmd/earlyinit/mount.go
index 6ac59a46..51d4ecc9 100644
--- a/cmd/earlyinit/mount.go
+++ b/cmd/earlyinit/mount.go
@@ -12,6 +12,7 @@ import (
"hakurei.app/check"
"hakurei.app/fhs"
"hakurei.app/internal/kobject"
+ "hakurei.app/internal/uevent"
)
// mustMountSystem waits for and mounts a system device matching pattern.
@@ -26,8 +27,9 @@ func mustMountSystem(
for {
var matchErr error
var systemPath *check.Absolute
- s.Range(c, func(o *kobject.Object) bool {
- if o.Subsystem != "block" ||
+ s.Range(c, func(o *kobject.Object, act uevent.KobjectAction) bool {
+ if (act != uevent.KOBJ_ADD && act != uevent.KOBJ_CHANGE) ||
+ o.Subsystem != "block" ||
o.Env["DEVTYPE"] != "disk" {
return true
}
diff --git a/cmd/earlyinit/uevent.go b/cmd/earlyinit/uevent.go
index 0ab134cf..64f548ba 100644
--- a/cmd/earlyinit/uevent.go
+++ b/cmd/earlyinit/uevent.go
@@ -2,12 +2,12 @@ package main
import (
"context"
- "log"
"time"
"hakurei.app/fhs"
"hakurei.app/internal/report"
"hakurei.app/internal/uevent"
+ "hakurei.app/message"
)
// newRejectColdboot returns a function to be called on every subsequent pending
@@ -56,6 +56,7 @@ func newRejectColdboot() func() bool {
// consume continuously consumes events from conn with retries.
func consume(
ctx context.Context,
+ msg message.Msg,
r *report.Reporter,
conn *uevent.Conn,
uuid uevent.UUID,
@@ -67,7 +68,7 @@ func consume(
coldboot := true
retry:
if dispatchErr := conn.Consume(ctx, fhs.Sys, &uuid, events, coldboot, func(path string) {
- log.Println("coldboot visited", path)
+ msg.Verbose("coldboot visited", path)
}, func(err error) bool {
if _, ok := err.(uevent.NeedsColdboot); ok && !nextColdboot() {
r.Dispatch(