simple-init

A set of init binaries for linux
git clone git://depsterr.com/git/simple-init
Log | Files | Refs | README | LICENSE

commit 3e282c51f437b6dc5a9cc27444716edb199e530b
parent 3bef9432e80a1f366df02549f329c76ff0ddccef
Author: depsterr <depsterr@protonmail.com>
Date:   Sun, 31 May 2020 17:51:49 +0200

added device manager killer and improved log

Diffstat:
Minitscripts/init.c | 1+
Minitscripts/util.c | 20++++++++++----------
2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/initscripts/init.c b/initscripts/init.c @@ -66,6 +66,7 @@ int main() { spawn_process(netloopcmd); log_message("Killing device managers"); + char* udevcmd5[] = { udevcmd2[0], "control", "--exit", 0}; wait_for_children(); log_message("Boot completed, starting ttys"); diff --git a/initscripts/util.c b/initscripts/util.c @@ -9,6 +9,15 @@ #include <mntent.h> #include <stdio.h> +void log_message(char* msg) { + printf("\033[31;1m=>\033[m %s\n", msg); + if(access("/dev/kmsg", F_OK|W_OK) != -1) { + FILE* fp = fopen("/dev/kmsg", "w"); + fprintf(fp, "init: %s\n", msg); + fclose(fp); + } +} + int spawn_process(char** argv) { int child_pid; if ((child_pid = fork()) == 0) { @@ -24,7 +33,7 @@ void wait_for_children() { int status = 0; while(wait(&status) > 0) { if (WEXITSTATUS(status) != 0 || !WIFEXITED(status)) { - perror("Child failed, dropping to shell. Exit shell to continue boot.\n"); + log_message("Child failed, dropping to shell. Exit shell to continue boot."); char* shellcmd[] = { "/bin/sh", 0 }; int pid; pid = spawn_process(shellcmd); @@ -47,15 +56,6 @@ void make_path(char* path) { } } -void log_message(char* msg) { - printf("\033[31;1m=>\033[m %s\n", msg); - if(access("/dev/kmsg", F_OK|W_OK) != -1) { - FILE* fp = fopen("/dev/kmsg", "w"); - fprintf(fp, "init: %s\n", msg); - fclose(fp); - } -} - int is_mounted(char* path) { if (access(path, F_OK) == -1) return 0;