init+initrd: Create /tmp and mount it on boot

This commit is contained in:
apio 2023-06-03 11:34:53 +02:00
parent cc72a1655d
commit 0540879959
Signed by: apio
GPG Key ID: B8A7D06E42258954
4 changed files with 25 additions and 1 deletions

View File

@ -149,10 +149,28 @@ static Result<void> load_service(const os::Path& path)
if (parts[0].view() == "Command")
{
if (!service.command.is_empty())
{
fprintf(g_init_log, "[init] 'Command' cannot be specified after 'Script' has already been set! (%s)\n",
line.chars());
return {};
}
service.command = move(parts[1]);
continue;
}
if (parts[0].view() == "Script")
{
if (!service.command.is_empty())
{
fprintf(g_init_log, "[init] 'Script' cannot be specified after 'Command' has already been set! (%s)\n",
line.chars());
return {};
}
service.command = TRY(String::format("/bin/sh -- %s"_sv, parts[1].chars()));
continue;
}
if (parts[0].view() == "Restart")
{
if (parts[1].view() == "true" || parts[1].view().to_uint().value_or(0) == 1)
@ -210,7 +228,7 @@ static Result<void> load_service(const os::Path& path)
if (service.command.is_empty())
{
fprintf(g_init_log, "[init] service file is missing 'Command' entry, aborting!\n");
fprintf(g_init_log, "[init] service file is missing 'Command' or 'Script' entry, aborting!\n");
return {};
}

3
initrd/etc/init/00-tmpfs Normal file
View File

@ -0,0 +1,3 @@
Name=tmpfs
Script=/sbin/mount-tmpfs
Wait=true

3
initrd/sbin/mount-tmpfs Normal file
View File

@ -0,0 +1,3 @@
mkdir -p /tmp
mount -t tmpfs /tmp
chmod 1777 /tmp