CSC369 A3: File Systems

Assignment 3: File Systems

Due: Midnight on Monday, December 1

Introduction

In this assignment, you will explore the implementation of a particular file system, ext2, and will write tools to modify ext2-format virtual disks. To do this work, you will need to be comfortable working with binary data and will need to learn about the ext2 filesystem.

Requirements

Your task is to write four programs that add or remove files from an ext2 formatted virtual disk. They can be written in any language you choose (I recommend C or Python), but they must be named ext2_cp, ext2_mkdir, ext2_ln, and ext2_rm and must take the specified arguments.

All of these programs should be minimalist. Don't implement what isn't specified: only provide the required functionality and specified errors. (For example, don't implement wildcards. Also, can't delete directories? Too bad!)

You will find it very useful for these programs to share code. You will want a function that performs a path walk, for example. You will also want a function that opens a specific directory entry and writes to it.

Learning about the Filesystem

Here are six sample virtual disk images:

These disks were each created and formatted in the same way:

% dd if=/dev/zero of=~/DISKNAME.img bs=1024 count=128
% mke2fs DISKNAME.img
% sudo mount -o loop ~/DISKNAME.img /home/petersen/mntpoint
% cd /home/petersen/mntpoint
% ...... normal linux commands to add/remove files/directories/links .....
% cd ~
% umount /home/petersen/mntpoint

Since we are creating images with mke2fs, the disks are formatted with the ext2 file system. You may wish to read about this system before doing some exploration. The wikipedia page for ext2 provides a good overview, but Dave Poirer's Second Extended File System article provides more detail on how the system places data onto a disk. It's a good reference to keep on hand as you explore.

However, you will probably also want to explore the disk images to get an intuitive sense of how they are structured.

There are two good ways to interface with these images. The first way is to interact with it like a user. Use mount to mount the disk into your file system and to peruse its contents. Note: this requires sudo, so you will need to do this on a machine that you administer or on a virtual machine (details below). The second way is to interact with the disk as if it is a flat binary file. Use xxd to create hex dumps, diff to look for differences between the dumps, and your favorite text editor to view the diffs. For example (YMMV):

% diff <(xxd emptydisk.img) <(xxd onefile.img) > empty-onefile.diff
% vimdiff empty-onefile.diff

You should be able to use a combination of these techniques to understand how files are placed on disk and how they are removed. For example, you can create a new disk image, use mount to place files of various sizes on it, unmount it, and then use xxd and diff to see how the image differs from the other images you have.

Getting Root on a Virtual Machine

We will be using one of the small virtual machines that you used in CSC347. We don't need anything special: just a machine that allows you to create images and mount them. If you already have such a machine available, feel free to use it. Otherwise, use the Ubuntu804Server located on dh2020pcXX.utm.utoronto.ca:/virtual/a2.

Virtual machines are large, so don't use your home directory to store it. Instead, you have access to the /virtual shared space. /virtual is unique to the machine, so once you set up your VM on one PC, please continue to use it. Remember, also, to clean up after yourself. To set up your VM:

% mkdir /virtual/$USER
% cd /virtual/$USER
% unzip /virtual/a2/Ubuntu804Server.zip
% vmplayer

The credentials to log in are arnold/bp2thisisvulnerable2014a

Submission

The assignment should be submitted to an a3 directory in your svn repository. Don't forget to add and commit all of the code for the required programs. Please also provide a Makefile that will create all of the programs if make is invoked without arguments. We will pull the last commit before the deadline for marking.

If you are unable to complete all aspects of this assignment, please add a README file (text or pdf format only) to your a3 folder that explains what is not implemented and describes what features you have completed. You can receive partial credit for functionality that is implemented but that does not complete one of the four required programs.