From f6a1cdd50b3ab0116be6d853a0577e22b2e69f8c Mon Sep 17 00:00:00 2001 From: Yaroslav de la Peña Smirnov Date: Mon, 11 Aug 2025 20:20:47 +0300 Subject: init minit commit, innit --- minit.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 minit.c (limited to 'minit.c') diff --git a/minit.c b/minit.c new file mode 100644 index 0000000..7ea9688 --- /dev/null +++ b/minit.c @@ -0,0 +1,40 @@ +#include +#include +#include + +#include +#include +#include +#include + +[[noreturn]] +int main(int argc, char *argv[]) +{ + if (argc < 2) { + puts("usage: minit "); + exit(1); + } + + int rc = mount("proc", "/proc", "proc", 0, NULL); + if (rc) + puts("warning: unable to mount proc!"); + + rc = mount("sysfs", "/sys", "sysfs", 0, NULL); + if (rc) { + puts("warning: unable to mount sysfs!"); + } else { + rc = mount("debugfs", "/sys/kernel/debug", "debugfs", 0, NULL); + if (rc) + puts("warning: unable to mount debugfs!"); + } + + rc = system(argv[1]); + if (rc) { + puts("the command exited with failure"); + } + + sync(); + rc = reboot(LINUX_REBOOT_CMD_HALT); + /* If we made it here something went wrong with the reboot command */ + exit(rc); +} -- cgit v1.2.3