diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-09 05:04:08 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-09 05:18:19 +0900 |
| commit | 87b5c30ef6d5b7b8a10d6a5a8610054c403923e6 (patch) | |
| tree | 805116c39a623bb30fc532af47ea3ed78b7304c0 /container/init.go | |
| parent | df9b77b077d967d35082adb8ab3b00dd67d7bc97 (diff) | |
message: relocate from container
This package is quite useful. This change allows it to be imported without importing container.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init.go')
| -rw-r--r-- | container/init.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/container/init.go b/container/init.go index 9481acd1..923a36e8 100644 --- a/container/init.go +++ b/container/init.go @@ -14,6 +14,7 @@ import ( "hakurei.app/container/fhs" "hakurei.app/container/seccomp" + "hakurei.app/message" ) const ( @@ -61,7 +62,7 @@ type ( setupState struct { nonrepeatable uintptr *Params - Msg + message.Msg } ) @@ -95,14 +96,14 @@ type initParams struct { } // Init is called by [TryArgv0] if the current process is the container init. -func Init(msg Msg) { +func Init(msg message.Msg) { if msg == nil { panic("attempting to call initEntrypoint with nil msg") } initEntrypoint(direct{}, msg) } -func initEntrypoint(k syscallDispatcher, msg Msg) { +func initEntrypoint(k syscallDispatcher, msg message.Msg) { k.lockOSThread() if k.getpid() != 1 { @@ -125,7 +126,7 @@ func initEntrypoint(k syscallDispatcher, msg Msg) { k.fatal(msg, "invalid setup descriptor") } if errors.Is(err, ErrReceiveEnv) { - k.fatal(msg, "HAKUREI_SETUP not set") + k.fatal(msg, setupEnv+" not set") } k.fatalf(msg, "cannot decode init setup payload: %v", err) @@ -448,11 +449,11 @@ const initName = "init" // TryArgv0 calls [Init] if the last element of argv0 is "init". // If a nil msg is passed, the system logger is used instead. -func TryArgv0(msg Msg) { +func TryArgv0(msg message.Msg) { if msg == nil { log.SetPrefix(initName + ": ") log.SetFlags(0) - msg = NewMsg(log.Default()) + msg = message.NewMsg(log.Default()) } if len(os.Args) > 0 && path.Base(os.Args[0]) == initName { |
