Description
1 Overview
In this project, you will implement a read-only driver for ext2, a standard filesystem 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 file from an ext2 image and prints it to stdout.
2 Provided code
The project tarball contains a number of files. We recommend examining them in roughly the following order: • eecs343.img – An ext2 filesystem image. This is a regular file which has been formatted as if it were a real disk partition. It contains some nested directory structure with a handful of files scattered throughout. • reference.o – A binary blob implementing an ext2 driver. You want to make this file unnecessary. • ext2cat.c – The final user of your code. Immediately after extracting the project, you should be able to build ext2cat with Make and use it with the provided filesystem image by running
./ext2cat eecs343.img /README.txt
You will see a turkey. • lib/ext2 access.c – The file 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 off 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 definitions 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 file already contains.
1
After checking out all of those, you need one more thing before you can start: a specification of the ext2 data structures and disk layout. This information is available from a number of sources, but we recommend using this site: https://www.nongnu.org/ext2-doc/ext2.html
3 Your filesystem
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 filesystem: