xv6 reading homework

Throughout this semester, we expect that you will read the entire implementation of the xv6 kernel, accompanied by the xv6 book, which explains the rationale and design underlying the kernel's implementation. (The source code is also available as a Lions-style PDF)

For this lecture, read the kernel files buf.h, fs.h, bio.c, fs.c, sysfile.c, and file.c. You may find Chapter 10 of the book useful in understanding the file system code.

It's possible, by commenting out one line in in fs.c, to cause xv6 to behave (incorrectly) like this:

$ echo aaa > a
$ echo bbb > b
$ cat a
bbb

This behavior is incorrect because file a should contain aaa.

Which line can you comment out to cause this behavior?

Optional challenge: what pair of lines can you comment out in the xv6 kernel to produce this behavior?

$ echo aaa > a
$ rm a
$ echo bbb > b
$ cat a
bbb

Of course cat a should result in cat: cannot open a, and should not print b's content.

Submit your answer in an ASCII text file named homework.txt to the corresponding "Lecture N" assignment on Gradescope.


Questions or comments regarding 6.1810? Send e-mail to the course staff at 61810-staff@lists.csail.mit.edu.

Creative Commons License