diff options
author | rtm <rtm> | 2006-08-11 13:55:18 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-08-11 13:55:18 +0000 |
commit | 17a856577f9db766b8ef7099d0575d378dff5dd1 (patch) | |
tree | 53d0c687d9c9bf83d097a2171c48d04a569c5a61 /init.c | |
parent | 5be0039ce9e22f140a29e167526c64c723c5be3c (diff) | |
download | xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.gz xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.bz2 xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.zip |
init creates console, opens 0/1/2, runs sh
sh accepts 0-argument commands (like userfs)
reads from console
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#include "user.h" +#include "types.h" +#include "fs.h" +#include "fcntl.h" + +char *sh_args[] = { "sh", 0 }; + +int +main(void) +{ + int pid; + + if(open("console", 0) < 0){ + mknod("console", T_DEV, 1, 1); + open("console", 0); + } + open("console", 1); + open("console", 1); + + write(1, "init...\n", 8); + + while(1){ + write(1, "running sh...\n", 14); + pid = fork(); + if(pid == 0){ + exec("sh", sh_args); + exit(); + } + if(pid > 0) + wait(); + } +} |