TWiki> CS385spring11 Web>Homework10 (2011-04-14, Main.jakob)EditAttach

Homework 10 - a read/write filesystem (15 points!)

In this homework, we extend our simple read-only file system from the previous homework to also support creating new files and writing to these.

After checking out the template, you may mount the template filesystem using the following commands:

sudo insmod ./hw10fs.ko
sudo mount -t hw10fs -o loop test.img mnt

The test.img file is identical to the previous test.img, with the exception of a large amount of empty space appended to it, where you should store the contents of new files.

turn-in directions: put all your code in the file hw10fs.c.

HINT: check your logs in a separate window, using tail -f var/log/messages. You will be docked points for kernel warning messages appearing in this file (not your debug output).

1. File creation

Support the creation of new files in the mounted directory. Again, our filesystem does not support directories, so all you need to handle is regular file creation. Test it like this:

touch mnt/mynewfile
ls -l mnt

you should now see "mynewfile" appear in the listing, with a size of zero.

hint: you'll need to add a file pointer to your inode_operations struct.

2. Persistent file creation

Make sure your file still exists after unmounting and re-mounting your image. To do this, you'll need to write out your updated superblock to disk.

hint: This template does not memcpy the superblock to a kmalloced bit of memory. Instead, it holds on to the buffer_head* from sb_bread. See how other filesystems (fat or ext2) use sync_dirty_buffer to write this out to disk in an easy way. Double-check your updated disk image with hexdump -C test.img | less

3. Writing to files

Support writing data to files. Test this as follows:

echo my test > mnt/testfile
ls -l mnt
cat mnt/testfile

the ls -l should show the new file with size 8, and the cat should output "my test". Make sure that your written output survives an unmount/mount.

hint: you'll need to add several function pointers to your address_space_operations and file_operations. Look at the fat implementation to get some ideas.

4. Writing large files

Make sure you can handle writes of more than one block correctly. Try cat hw10fs.c > mnt/testfile to try with a large file.

5. Handle "out of space" errors correctly

Our filesystem does not support growing files that are "wedged" between other files (we use contiguous allocation without any support for moving files around). Make sure writing to a "wedged" file does not overwrite the contents of other files, and instead makes the terminal display "out of space" or some other user-friendly error.

Topic revision: r4 - 2011-04-14 - 03:55:28 - Main.jakob
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF