3 #include <lunaix/lunaix.h>
4 #include <lunaix/mount.h>
9 #define must_mount(src, target, fs, opts) \
12 if ((err = mount(src, target, fs, opts))) { \
13 syslog(2, "mount fs %s to %s failed (%d)\n", fs, target, errno); \
18 #define check(statement) \
21 if ((err = (statement)) < 0) { \
22 syslog(2, #statement " failed: %d", err); \
29 init_termios(int fd) {
32 check(tcgetattr(fd, &term));
34 term.c_lflag = ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHONL;
35 term.c_iflag = ICRNL | IGNBRK;
36 term.c_oflag = ONLCR | OPOST;
37 term.c_cflag = CREAD | CLOCAL | CS8 | CPARENB;
38 term.c_cc[VERASE] = 0x7f;
40 check(tcsetattr(fd, 0, &term));
46 main(int argc, const char** argv)
52 must_mount(NULL, "/dev", "devfs", 0);
53 must_mount(NULL, "/sys", "twifs", MNT_RO);
54 must_mount(NULL, "/task", "taskfs", MNT_RO);
56 int fd = check(open("/dev/tty", 0));
58 check(init_termios(fd));
62 check(symlink("/usr", "/mnt/lunaix-os/usr"));
66 if (!(pid = fork())) {
67 err = execve("/usr/bin/sh", NULL, NULL);
68 printf("fail to execute (%d)\n", errno);
72 waitpid(pid, &err, 0);
74 if (WEXITSTATUS(err)) {
75 printf("shell exit abnormally (%d)\n", err);
78 printf("init exiting\n");