git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: make pci device driver loading passive, pci bus scanner will not load them...
[lunaix-os.git]
/
lunaix-os
/
usr
/
init
/
init.c
diff --git
a/lunaix-os/usr/init/init.c
b/lunaix-os/usr/init/init.c
index 7f7ca5e95fcc39d9b8239cde1c76f64b59d31543..1b80f495d05770b7dca832831a5b625f6f8733d5 100644
(file)
--- a/
lunaix-os/usr/init/init.c
+++ b/
lunaix-os/usr/init/init.c
@@
-1,27
+1,45
@@
#include <errno.h>
#include <fcntl.h>
#include <lunaix/lunaix.h>
#include <errno.h>
#include <fcntl.h>
#include <lunaix/lunaix.h>
+#include <lunaix/mount.h>
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
+#define must_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); \
+ return err; \
+ } \
+ } while (0)
+
int
main(int argc, const char** argv)
{
int err = 0;
int
main(int argc, const char** argv)
{
int err = 0;
+ 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);
+
if ((err = open("/dev/tty", 0)) < 0) {
syslog(2, "fail to open tty (%d)\n", errno);
if ((err = open("/dev/tty", 0)) < 0) {
syslog(2, "fail to open tty (%d)\n", errno);
- return
0
;
+ return
err
;
}
if ((err = dup(err)) < 0) {
syslog(2, "fail to setup tty i/o (%d)\n", errno);
}
if ((err = dup(err)) < 0) {
syslog(2, "fail to setup tty i/o (%d)\n", errno);
- return
0
;
+ return
err
;
}
if ((err = symlink("/usr", "/mnt/lunaix-os/usr"))) {
syslog(2, "symlink /usr:/mnt/lunaix-os/usr (%d)\n", errno);
}
if ((err = symlink("/usr", "/mnt/lunaix-os/usr"))) {
syslog(2, "symlink /usr:/mnt/lunaix-os/usr (%d)\n", errno);
- return
0
;
+ return
err
;
}
pid_t pid;
}
pid_t pid;
@@
-37,5
+55,5
@@
main(int argc, const char** argv)
printf("shell exit abnormally (%d)", err);
}
printf("shell exit abnormally (%d)", err);
}
- return
0
;
+ return
err
;
}
\ No newline at end of file
}
\ No newline at end of file