#include #include #include #include #include #include void spawn_shell() { pid_t pid = fork(); if (pid == 0) { char *argv[] = { "gmsh", NULL }; char *envp[] = { "PATH=/bin", "HOME=/", "TERM=linux", NULL }; execve("/bin/gmsh", argv, envp); perror("[init] Failed to exec gmsh"); exit(1); } else if (pid > 0) { int status; waitpid(pid, &status, 0); fprintf(stdout, "[init] gmsh exited (status %d).\n", status); } else { perror("[init] fork failed"); } } int main() { printf("[init] System Initializing...\n"); if (mount("proc", "/proc", "proc", 0, NULL) != 0) perror("mount /proc"); if (mount("sysfs", "/sys", "sysfs", 0, NULL) != 0) perror("mount /sys"); // if (mount("devtmpfs", "/dev", "devtmpfs", 0, NULL) != 0) // perror("mount /dev"); mkdir("/tmp", 0777); if (mount("tmpfs", "/tmp", "tmpfs", 0, "mode=1777") != 0) { perror("[init] Failed to mount /tmp"); } mkdir("/home", 0755); if (mount("/dev/sda2", "/home", "ext4", 0, NULL) != 0) { perror("[init] Failed to mount /home"); } while (1) spawn_shell(); return 0; }