In this project, you will implement a read-only driver for ext2, a standard ﬁlesystem supported by the Linux kernel. Starting from a reference implementation provided in binary form, you will reimplement the driver one piece at a time until you do not link against the original code at all. The reference blob and your code will both be used by ext2cat, a simple program included with the project that retrieves the content of a ﬁle from an ext2 image and prints it to stdout.
2 Provided code
The project tarball contains a number of ﬁles. We recommend examining them in roughly the following order: • eecs343.img – An ext2 ﬁlesystem image. This is a regular ﬁle which has been formatted as if it were a real disk partition. It contains some nested directory structure with a handful of ﬁles scattered throughout. • reference.o – A binary blob implementing an ext2 driver. You want to make this ﬁle unnecessary. • ext2cat.c – The ﬁnal user of your code. Immediately after extracting the project, you should be able to build ext2cat with Make and use it with the provided ﬁlesystem image by running
./ext2cat eecs343.img /README.txt
You will see a turkey. • lib/ext2 access.c – The ﬁle where you should put all of your work. You will notice that almost all of the functions inside are simple wrappers around reference versions (e.g., get inode() does nothing more than hand oﬀ to ref get inode()). Your task is to reimplement these functions so that they do not invoke any of the ref code. • include/ext2fs.h – A header taken from the Linux implementation of ext2. Contains a plethora of useful struct deﬁnitions and macros. It’s long, but you would be well-advised to give the entire thing a once-over before you start. You shouldn’t waste time writing anything this ﬁle already contains.
After checking out all of those, you need one more thing before you can start: a speciﬁcation of the ext2 data structures and disk layout. This information is available from a number of sources, but we recommend using this site: http://www.nongnu.org/ext2-doc/ext2.html
3 Your ﬁlesystem
As you will not be able to mount eecs343.img, you need to know what you’re looking for. These are the contents of the ﬁlesystem: