From dde2f75cfe70775dd05d3780c8f7abc327a351c4 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 10 Nov 2026 00:35:58 +0900 Subject: cmd/earlyinit: suppress printk on fatal This removes printk noise after the system is unable to continue its boot process, so the error message does not get scrolled away. Signed-off-by: Ophestra --- cmd/earlyinit/main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go index b1f49b90..02841620 100644 --- a/cmd/earlyinit/main.go +++ b/cmd/earlyinit/main.go @@ -7,6 +7,7 @@ package main import ( "context" "crypto/rand" + "fmt" "io" "log" "os" @@ -51,9 +52,15 @@ func init() { // fatal calls [log.Println] with v and blocks forever. Must be called from // main. Must not be used after error reporting is set up. func fatal(v ...any) { - log.Println(v...) - log.Println("unable to continue, please reboot and resolve the problem manually") log.SetOutput(io.Discard) + fmt.Println(v...) + fmt.Println("unable to continue, please reboot and resolve the problem manually") + + const SYSLOG_ACTION_CONSOLE_OFF = 6 + if _, err := Klogctl(SYSLOG_ACTION_CONSOLE_OFF, nil); err != nil { + log.Printf("cannot set SYSLOG_ACTION_CONSOLE_OFF: %v", err) + } + select {} } @@ -350,7 +357,7 @@ func main() { } cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr if err := cmd.Run(); err != nil { - log.Fatalln(err) + fatal(err) } mustSyscall("power off", Reboot(LINUX_REBOOT_CMD_POWER_OFF)) panic("not reached") -- cgit v1.3.1