Spring 2021
This lab is an extesion of Lab 3a, and it shares the same learning objectives and logistics.
After completing this lab (parts A and B), you will:
In Lab 3b, you will:
Your finished filesystem should implement the following functionality:
getattr()
,access()
,readdir()
, andmkdir()
rmdir()
,chmod()
(this is most easily implemented by adding a mode_t mode
field to your inode),close()
(i.e., release()
),create()
(can likely call a do_mknod()
helper function),fgetattr()
(can likely call a do_getattr()
helper function),mknod()
(only for plain files; you can assume that the argument mode
will always be S_IFREG
, and you can completely ignore dev
),open()
,read()
,truncate()
,unlink()
, andwrite()
.Descriptions of each method can be found in the HMC documentation, and suggestions/clarifications will be provided below as they come up.
Note that you are not required to support:
readlink()
,symlink()
,chown()
,fsync()
,link()
,statfs()
,rename()
, orutimens()
.Many of these optional operations would require additional filesystem design (e.g., chown()
requires that you track ownership).
write()
operation should support full Unix semantics. Specifically, it should be possible to:
You are not required to support sparse files (a sparse file is a large file that does not explicitly represent all of the “holes”; instead it creates “0”s on demand).
Your implementation need not prioritize speed, but it should still be reasonably efficient (no unnecessary work or obviously wasteful big-O time or space). It should be possible to create a 1-MiB file in well under a second.
You should not waste memory. It’s OK to store the bitmaps and the entire inode table in memory. But you may not store a copy of the entire disk in memory, nor may you store entire files or directories in memory. An obvious exception is 1-block files, which of course may be assumed to fit… This just means you should bring blocks into memory on demand, and free memory when you are no longer using it.
Note that if you do decide to implement symbolic links, your path-evaluation code doesn’t need to do anything special for symbolic links; FUSE will do that for you.
Note that if you do decide to implement the statfs()
operation, it should correctly report the amount of free space in the data region of the file system. In other words, if it reports 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. (You may wish to add a counter somewhere rather than manually count your bitmap’s bits each time statfs()
is called.)
Many of your features can be tested using standard Unix utilities inside scripts like we did for Lab 1. The dd
utility is especially useful (see man dd
, or “Google” dd
for example usage; looking up how to use this tool for testing is not considered an honor code violation.).
Unlike the Part A, I recommend that you write test code/scripts. I provide some test recommendations below, but I also encourage you to share any tests ideas or strategies that you have with the group on Slack.
A good strategy is, as soon as you add functionality, create a small test. Then run all of your existing tests to verify your new “feature” didn’t break anything!
Here are some things that I expect to work, so you are strongly encouraged to create tests for (at least) these features:
ls -la
, including for files of various sizes, and including .
and ..
echo xxx >> foo
)truncate
to extend files by adding zerosdd
with the conv=notrunc
switch is one way to do this, as is our write_test.c
from Hello Fuse)Submit your code (it should be inside a single file named refs.c
) to your git repository. If you implement any additional features, be sure to mention them (prominently?) in your README.md
file so that I see them.
When you have completed your Lab 3b, please do two things:
This lab borrows from an assignment created by Geoff Kuenning.