aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/earlyinit
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-11-10 00:35:58 +0900
committerOphestra <cat@gensokyo.uk>2026-11-10 00:35:58 +0900
commitdde2f75cfe70775dd05d3780c8f7abc327a351c4 (patch)
tree005483fc0895d67fd26cd8419c80d3f2c11ab2fd /cmd/earlyinit
parent87dc1097553a562c585a8ae3982a911d1c4f51e1 (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'cmd/earlyinit')
-rw-r--r--cmd/earlyinit/main.go13
1 files changed, 10 insertions, 3 deletions
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")