CSL373 : Operating Systems


xv6 file system

Read: sysfile.c (create(), sys_unlink()), fs.c (readi(), writei(), dirlink(), ialloc(), iupdate(), iget(), ilock(), iunlock(), iput(), itrunc()), bio.c (bget(), bread(), bwrite(), brelse())

Add the following line at the beginning of the log_write() function in log.c

cprintf("log_write %d\n", b->sector);
This will record all writes to the file system along with the sector number.

Start a new session on xv6 with a fresh disk (using make clean followed by make qemu, and type the following command:

$ echo > a
This command creates a new file. You will see a series of disk writes (printed in log_write()).

Turn in: Report the printed output and explain what is being written in each disk write. What is the third disk write (to sector 29)? You may want to insert cprintf() statements in xv6 code to see where the writes are coming from.

Interrupt the previous command (leave the newly created file unchanged). Next, execute the following command to write data to this file:

$ echo x > a

Turn in: Report the printed output and explain what is being written in each disk write. Why do you see writes to block 4 (and to 426) twice? You may want to insert cprintf() statements in xv6 code to see where the writes are coming from.

Next, delete the file by typing the following command:

$ rm a

Turn in: Report the printed output and explain what is being written in each disk write.