forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init creates console, opens 0/1/2, runs sh
sh accepts 0-argument commands (like userfs) reads from console
- Loading branch information
rtm
committed
Aug 11, 2006
1 parent
5be0039
commit 17a8565
Showing
11 changed files
with
163 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "user.h" | ||
#include "types.h" | ||
#include "fs.h" | ||
#include "fcntl.h" | ||
|
||
char *args[100]; | ||
|
||
int | ||
main(void) | ||
{ | ||
char buf[128]; | ||
int pid; | ||
|
||
while(1){ | ||
write(1, "$ ", 2); | ||
gets(buf, sizeof(buf)); | ||
if(buf[0] == '\0') | ||
continue; | ||
pid = fork(); | ||
if(pid == 0){ | ||
args[0] = buf; | ||
args[1] = 0; | ||
exec(buf, args); | ||
write(1, buf, strlen(buf)); | ||
write(1, ": not found\n", 12); | ||
exit(); | ||
} | ||
if(pid > 0) | ||
wait(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters