feat: standard vga support (mode switching, framebuffer remapping)
[lunaix-os.git] / lunaix-os / usr / init / init.c
1 #include <errno.h>
2 #include <fcntl.h>
3 #include <lunaix/lunaix.h>
4 #include <stdio.h>
5 #include <unistd.h>
6
7 int
8 main(int argc, const char** argv)
9 {
10     int err = 0;
11
12     if ((err = open("/dev/tty", 0)) < 0) {
13         syslog(2, "fail to open tty (%d)\n", errno);
14         return 0;
15     }
16
17     if ((err = dup(err)) < 0) {
18         syslog(2, "fail to setup tty i/o (%d)\n", errno);
19         return 0;
20     }
21
22     if ((err = symlink("/usr", "/mnt/lunaix-os/usr"))) {
23         syslog(2, "symlink /usr:/mnt/lunaix-os/usr (%d)\n", errno);
24         return 0;
25     }
26
27     pid_t pid;
28     if (!(pid = fork())) {
29         err = execve("/usr/bin/sh", NULL, NULL);
30         printf("fail to execute (%d)\n", errno);
31         _exit(err);
32     }
33
34     waitpid(pid, &err, 0);
35
36     if (WEXITSTATUS(err)) {
37         printf("shell exit abnormally (%d)", err);
38     }
39
40     return 0;
41 }