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
Framework for exporting system header to user space (#59)
[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 45bbf929de7fbafcc082ccd86fad4eabf6fdaecb..67a73f995835e71442612ce38f7f63fcc721f058 100644
(file)
--- a/
lunaix-os/usr/init/init.c
+++ b/
lunaix-os/usr/init/init.c
@@
-1,11
+1,13
@@
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
-#include <
lunaix/lunaix
.h>
-#include <
lunaix
/mount.h>
+#include <
sys/wait
.h>
+#include <
sys
/mount.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
+#include <sys/lunaix.h>
+
#define must_mount(src, target, fs, opts) \
do { \
int err = 0; \
#define must_mount(src, target, fs, opts) \
do { \
int err = 0; \
@@
-15,6
+17,14
@@
} \
} while (0)
} \
} 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; \
#define check(statement) \
({ \
int err = 0; \
@@
-31,24
+41,26
@@
init_termios(int fd) {
check(tcgetattr(fd, &term));
check(tcgetattr(fd, &term));
- term.c_lflag = ICANON | IEXTEN | ISIG | ECHO | ECHOE
| ECHONL
;
+ term.c_lflag = ICANON | IEXTEN | ISIG | ECHO | ECHOE;
term.c_iflag = ICRNL | IGNBRK;
term.c_oflag = ONLCR | OPOST;
term.c_cflag = CREAD | CLOCAL | CS8 | CPARENB;
term.c_cc[VERASE] = 0x7f;
term.c_iflag = ICRNL | IGNBRK;
term.c_oflag = ONLCR | OPOST;
term.c_cflag = CREAD | CLOCAL | CS8 | CPARENB;
term.c_cc[VERASE] = 0x7f;
+
+ cfsetispeed(&term, B9600);
+ cfsetospeed(&term, B9600);
check(tcsetattr(fd, 0, &term));
return 0;
}
check(tcsetattr(fd, 0, &term));
return 0;
}
+const char* sh_argv[] = { "/bin/sh", 0 };
+const char* sh_envp[] = { 0 };
+
int
main(int argc, const char** argv)
{
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);
must_mount(NULL, "/dev", "devfs", 0);
must_mount(NULL, "/sys", "twifs", MNT_RO);
must_mount(NULL, "/task", "taskfs", MNT_RO);
@@
-59,12
+71,10
@@
main(int argc, const char** argv)
check(dup(fd));
check(dup(fd));
- check(symlink("/usr", "/mnt/lunaix-os/usr"));
-
pid_t pid;
int err = 0;
if (!(pid = fork())) {
pid_t pid;
int err = 0;
if (!(pid = fork())) {
- err = execve(
"/usr/bin/sh", NULL, NULL
);
+ err = execve(
sh_argv[0], sh_argv, sh_envp
);
printf("fail to execute (%d)\n", errno);
_exit(err);
}
printf("fail to execute (%d)\n", errno);
_exit(err);
}