CS137 Homework 3: FAT, part 2

Overview

The purpose of this assignment is to finish the filesystem you began in Homework 2. At the end of this assignment, you should have a working filesystem that can be used to store actual files.

You may write in any language that is supported on Knuth or Wilkes and that supports Fuse, but as mentioned in class, I strongly recommend C or C++.

The Assignment

Your assignment is to finish the FAT-like filesystem that you began in Homework 2. Your finished filesystem should have the following features:

  1. The general structure of the filesystem is similar to the Microsoft FAT design (see Part 1 of this assignment).
  2. In addition to the calls supported in Homework 2 (getattr, access, readdir, and mkdir), you must support the following additional operations: close (i.e., release), create, fgetattr, mknod (only for plain files), open, read, readlink, rmdir, statfs, symlink, truncate, unlink, and write.
  3. You are not required to support chmod, chown, fsync, link, rename, or utimens. Note that many of these operations require additional filesystem design (e.g., chown requires that you track ownership).
  4. Your write operation must support full Unix semantics: it must be possible to extend a file by writing at the end, to rewrite arbitrary bytes in the middle of a file, and to extend a file by a large amount by seeking far past the end and writing a single byte.
  5. You are not required to support sparse files (FAT-like file systems don't get along well with sparse files).
  6. Directories should be variable-sized and should grow as files are created within them. However, it is not necessary to shrink directories when files are removed.
  7. The statfs operation should correctly report the amount of free space in the file system. In particular, if it says that n blocks are left, it should be possible to write n additional blocks of data to an existing file, and impossible to write n+1 blocks.
  8. Note that your path-evaluation code doesn't need to do anything special for symbolic links; FUSE will do that for you.

Testing

Many of your features can be tested using standard Unix utilities (dd—see man dd—is especially useful). However, you may wish to write special test code or scripts.

Some things that I expect to work:

The above is not an exhaustive list. Try to think of what I've (deliberately) omitted.

Important Notes

Refer back to the important notes in part 1 of this assignment to make sure you don't do anything silly. In addition:

  1. Your implementation must be efficient. It should be possible to create a 1-MB file in well under a second.
  2. You may not waste memory. It's OK to store the entire FAT in memory; that's what DOS did. But you may not store a copy of the entire disk in memory (works rather badly for terabyte disks), nor may you at any time store an entire file or directory in memory (works badly for terabyte files). The sole exception is 1-block files, which of course may be assumed to fit…

Submission

Submit your code (it should be a single file) as assignment 3 with cs137submit. If you implement any extra features, please describe them prominently in comments at the top of the file.


© 2018, Geoff Kuenning

This page is maintained by Geoff Kuenning.