Assigned: 11/3/06 Due: 11/17/06
The goal of this lab is to write a simple UNIX-like file system. The file system you will write make the following simplifying assumptions:
The layout of your 128 KB disk is as follows
char name[8]; //file name int size; // file size (in number of blocks) int blockPointers[8]; // direct block pointers int used; // 0 => inode is free; 1 => in use
Note that each inode is 48 bytes in size; Since you have 16 of these, the total space occupied by the inodes is 768 bytes. The free/used block information (mentioned above) is 128 byes, for a total of 896 bytes used in the 1024-byte superblock. The remaining bytes are unused.

dd if=/dev/zero of=/tmp/file.dat bs=1k count=128 # create a 128KB file losetup /dev/loop0 /tmp/file.dat # attach it to /dev/loop0 mount -t myfs /dev/loop0 /mnt # mount it umount /mnt # unmount it losetup -d /dev/loop0 # disconnect it
Note that there is no need for a mkfs program, as a superblock of all zeros corresponds to an empty filesystem. (i.e. all blocks free, all inodes free)
You will need to implement the following:
register_filesystem
fill_super method - read the superblock, invoked at mount time
struct super_operations, containing the methods alloc_inode, destroy_inode, read_inode, write_inode, delete_inode, put_super, write_super, statfs.
struct inode_operations for directory inodes, with methods create, lookup, link, unlink, rename. (note that file inodes are assigned a struct inode_operations as well, but it can be completely empty)
struct file_operations for directory inodes, with methods read, readdir, and fsync
struct file_operations for file inodes, with methods llseek, read, write, mmap, and sendfile. (these should point to the corresponding generic_* operations)
struct address_space_operations, containing readpage, writepage, sync_page, prepare_write, commit_write, bmap.
head -c13016 /dev/random > /tmp/file1) Copy these files to the filesystem, and then recopy them several times. Checksum the originals and copies to verify integrity. Unmount the filesystem, remount it, and verify that the files remain unchanged.
ls -l agrees with that from wc. Copy a small executable (e.g. /bin/dmesg) to the filesystem and verify that it can be executed.
cat /dev/zero > /mnt/bigfile. Try to create a file with a name longer than 8 characters. Change the permissions of a file. Verify reasonable - or at least non-crashing - behavior.
Please submit via email the source code for the filesystem module, a test log (e.g. use script to capture the terminal session while testing manually, or put the commands in a script file and run it with sh -x), and a short (1 page is OK) writeup of your design.