From f53494c28e362fb7752bbc83417b9ba47cff0bf5 Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 3 Sep 2008 04:50:04 +0000 Subject: DO NOT MAIL: xv6 web pages --- web/xv6-disk.html | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 web/xv6-disk.html (limited to 'web/xv6-disk.html') diff --git a/web/xv6-disk.html b/web/xv6-disk.html new file mode 100644 index 0000000..65bcf8f --- /dev/null +++ b/web/xv6-disk.html @@ -0,0 +1,63 @@ + + +Homework: Files and Disk I/O + + + +

Homework: Files and Disk I/O

+ +

+Read: bio.c, fd.c, fs.c, and ide.c + +

+This homework should be turned in at the beginning of lecture. + +

+File and Disk I/O + +

Insert a print statement in bwrite so that you get a +print every time a block is written to disk: + +

+  cprintf("bwrite sector %d\n", sector);
+
+ +

Build and boot a new kernel and run these three commands at the shell: +

+  echo >a
+  echo >a
+  rm a
+  mkdir d
+
+ +(You can try rm d if you are curious, but it should look +almost identical to rm a.) + +

You should see a sequence of bwrite prints after running each command. +Record the list and annotate it with the calling function and +what block is being written. +For example, this is the second echo >a: + +

+$ echo >a
+bwrite sector 121  # writei  (data block)
+bwrite sector 3    # iupdate (inode block)
+$ 
+
+ +

Hint: the easiest way to get the name of the +calling function is to add a string argument to bwrite, +edit all the calls to bwrite to pass the name of the +calling function, and just print it. +You should be able to reason about what kind of +block is being written just from the calling function. + +

You need not write the following up, but try to +understand why each write is happening. This will +help your understanding of the file system layout +and the code. + +

+This completes the homework. + + -- cgit v1.2.3