init: Special case logd

Logd is a special case. Every other service effectively has an implicit
dependency on it for sending log messages to it and even init itself
depends on it for it's own log messages.
This commit is contained in:
bjorn3
2026-02-26 12:14:17 +01:00
parent e46bfb0005
commit fb051cd486
6 changed files with 22 additions and 20 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"unit": {
"default_dependencies": false,
"requires_weak": ["00_randd.service"]
},
"service": {
"cmd": "ramfs",
"args": ["logging"],
"type": {
"scheme": "logging"
}
}
}
+2 -1
View File
@@ -6,7 +6,8 @@
"00_nulld.service",
"00_randd.service",
"00_rtcd.service",
"00_zerod.service"
"00_zerod.service",
"00_logging_ramfs.service"
]
}
}
-4
View File
@@ -1,4 +0,0 @@
requires_weak 00_runtime.target
scheme log logd
stdio /scheme/log
scheme logging ramfs logging
-1
View File
@@ -1,4 +1,3 @@
requires_weak 10_logging
scheme input inputd
notify FRAMEBUFFER_ADDR=$ FRAMEBUFFER_VIRT=$ FRAMEBUFFER_WIDTH=$ FRAMEBUFFER_HEIGHT=$ FRAMEBUFFER_STRIDE=$ vesad
scheme fbbootlog fbbootlogd
+7 -5
View File
@@ -135,11 +135,6 @@ fn run_command(cmd: Command, config: &mut InitConfig) {
Command::RequiresWeak(_) => {} // handled by unit parsing code
Command::Nothing => {}
Command::Echo(text) => println!("{text}"),
Command::Stdio(stdio) => {
if let Err(err) = switch_stdio(&stdio) {
eprintln!("init: failed to switch stdio to '{}': {}", stdio, err);
}
}
Command::Service(service) => {
if config.skip_cmd.contains(&service.cmd) {
eprintln!(
@@ -166,6 +161,13 @@ fn main() {
}
.apply(&mut pending_units, &mut unit_store, &mut init_config);
let mut command = std::process::Command::new("logd");
command.env_clear().envs(&init_config.envs);
daemon::SchemeDaemon::spawn(command, "log");
if let Err(err) = switch_stdio("/scheme/log") {
eprintln!("init: failed to switch stdio to '/scheme/log': {err}");
}
let runtime_target = UnitId("00_runtime.target".to_owned());
'a: while let Some(unit) = pending_units.pop_front() {
-9
View File
@@ -45,9 +45,6 @@ pub enum Command {
// Service
Service(Service),
// Modify env
Stdio(String),
// Misc
Echo(String),
Nothing,
@@ -62,12 +59,6 @@ impl Command {
match cmd.as_str() {
"requires_weak" => Ok(Command::RequiresWeak(args.map(UnitId).collect::<Vec<_>>())),
"echo" => Ok(Command::Echo(args.collect::<Vec<_>>().join(" "))),
"stdio" => {
let Some(stdio) = args.next() else {
return Err("init: failed to set stdio: no argument".to_owned());
};
Ok(Command::Stdio(stdio))
}
"notify" => {
let process = Process::parse(args)?;