Finish lab 5.

This commit is contained in:
2019-05-16 18:50:16 -07:00
parent e9f683f6d6
commit 4199ce9c37
10 changed files with 139 additions and 20 deletions

View File

@@ -53,9 +53,16 @@ again:
// then check whether 'fd' is 0.
// If not, dup 'fd' onto file descriptor 0,
// then close the original 'fd'.
// LAB 5: Your code here.
panic("< redirection not implemented");
if ((fd = open(t, O_RDONLY)) < 0) {
cprintf("open %s for read: %e", t, fd);
}
if(fd != 0) {
dup(fd, 0);
close(fd);
}
break;
case '>': // Output redirection