/** * minit.c - A minimal init; as stupid as it gets. * * Copyright (c) 2025 - Yaroslav de la Peña Smirnov * * This is free software, which you can redistribute and/or modify under the * terms of the GNU General Public License, version 2.0 only. For more * information read the COPYING and LICENSE files provided in the original * source repository. */ #include #include #include #include #include #include #include [[noreturn]] int main(int argc, char *argv[]) { if (argc < 2) { puts("usage: minit "); puts("more info: git.yaroslavps.com/minit/about/"); exit(1); } puts("=== minit v1.0.0 ==="); 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); }