Homework 4: Simple xv6 shellThis assignment will make you familiar with how Unix systems use the system call interface. Specifically, you will build a simple shell for the xv6 system. This assignment requires xv6, so you have to follow the setup instructions here Xv6 Setup Instructions. Now you're ready to read the Chapter 0 of the xv6 book. Building a shellFirst of all, xv6 already comes with a shell, you should take a look at the source code here: sh.c Your job is to write a similar, but simpler shell. It should be able to run commands with arguments, handle input and output redirection, and set up two-element pipelines. Your shell should act like the xv6 shell sh for these examples as well as similar commands: echo hello there echo something > file.txt ls | grep READ grep lion < data.txt | wc > count echo echo hello | nsh You should put your shell source in nsh.c inside the xv6 root folder, and modify the Makefile to compile it (take a look at how other programs are compiled for xv6, e.g., wc). We'll test your nsh.c with our copies of other xv6 files; so while you can modify other files, your shell should not depend on those modifications. Your shell should use @ (at sign) as a prompt rather than $, to avoid confusion with the real shell. An xv6 session with your shell might look like this: xv6 kernel is booting $ nsh @ grep Ken < README xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix @ One restriction for this homework: you cannot use a memory allocator provided by xv6 (malloc()). Instead you should use only local (stack-allocated) variables and global variables. It's OK to impose reasonable fixed limits on things like the maximum length of a command name, the maximum number of arguments, or the maximum length of any single argument. We supply you with an xv6 test program testsh, source in testsh.c. You're done with the lab if your shell passes all the tests, like this: $ testsh nsh simple echo: PASS simple grep: PASS two commands: PASS output redirection: PASS input redirection: PASS both redirections: PASS simple pipe: PASS pipe and redirects: PASS lots of commands: PASS passed all tests |