aa64: finalise context switch, page fault handler and syscall
[lunaix-os.git] / lunaix-os / usr / init / init.c
index 47fcf68e0ae7739e4cc73ea97dfaeb2b6773f700..25996ce6c03b368b1d5d57d1a66532bc7c89af55 100644 (file)
         }                                                                      \
     } while (0)
 
+#define maybe_mount(src, target, fs, opts)                                      \
+    do {                                                                       \
+        int err = 0;                                                           \
+        if ((err = mount(src, target, fs, opts))) {                            \
+            syslog(2, "mount fs %s to %s failed (%d)\n", fs, target, errno);   \
+        }                                                                      \
+    } while (0)
+
 #define check(statement)                                                       \
     ({                                                                         \
         int err = 0;                                                           \
@@ -45,16 +53,12 @@ init_termios(int fd) {
     return 0;
 }
 
-const char* sh_argv[] = { "/usr/bin/sh", 0  };
+const char* sh_argv[] = { "/bin/sh", 0  };
 const char* sh_envp[] = {  0  };
 
 int
 main(int argc, const char** argv)
 {
-    mkdir("/dev");
-    mkdir("/sys");
-    mkdir("/task");
-
     must_mount(NULL, "/dev", "devfs", 0);
     must_mount(NULL, "/sys", "twifs", MNT_RO);
     must_mount(NULL, "/task", "taskfs", MNT_RO);
@@ -65,13 +69,9 @@ main(int argc, const char** argv)
 
     check(dup(fd));
 
-    check(symlink("/usr", "/mnt/lunaix-os/usr"));
-
     pid_t pid;
     int err = 0;
     if (!(pid = fork())) {
-
-        
         err = execve(sh_argv[0], sh_argv, sh_envp);
         printf("fail to execute (%d)\n", errno);
         _exit(err);