TWiki> CS385spring11 Web>Homework10 (revision 3)EditAttach

DRAFT

Homework10 - a read/write filesystem

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

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

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: don't memcpy your superblock to a kmalloced bit of memory. Instead, hold on to your buffer_head* from sb_bread, and use the b_data pointer in the struct to access the data in the on-disk superblock. See how other filesystems (fat or ext2) use sync_dirty_buffer to write this out to disk in an easy way.

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 mnt/file3 > mnt/testfile to try with a large file.

5. Handle errors

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.

Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2011-04-13 - 20:41:14 - 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