User File System


For this assignment, you are expected to implement a unix-style mini file system. The whole structure of the file system will exist within the single file. You'll be storing and removing other files within this file system, which is just a file itself.

The structure of this file is as followings:

SuperBlock
Bit Map
Root Directory
Inodes
DATA Blocks

The SuperBlock is the first block in the disk that contains global information about the file system. You can store in the superblock things like starting location of the first block of the bit map, the root directory, the total number of free blocks, the overall size of the file system and any other thing you consider useful for making the file system persistent.

The root directory maintains the mapping between file names and inode numbers (or pointers). And the inodes has information about the data blocks in the file.

For simplicity, you can assume:

  1. Your file system need not support multi-level directories. There is only a single directory in your file system. And this directory contains at most 100 files.
  2. Each file contains at most 100 data blocks. Thus, The size of each file is less than (block size) * 100. You can define the size of data blocks yourself.
  3. Inodes in your system contain only (at most 100) direct pointers that points to data blocks. No indirect pointers are required.

Program usage

Note: The number and size of files is also limited by the number of inodes and the number of free blocks.

Here are the steps for the assignment.

Download the skeleton code userfs.tar and work upon it to export the following functions. First, you should create a file under the current directory. This file simulates the virtual disk based on which you will build your file system.

Your system should support persistence and crash recovery.

Persistence means that all data written to the disk will never disappear unless you call explicitly u_del() to remove them.

Files should remain there after you quit the file system and restart it. You file system may be terminated illegally, e.g. ctrl-c is pressed. This may leave the system in an inconsistent state. You should be able to detect such inconsistent states and recover from them when the file system restarts. While writing the u_import() and u_export() functions you should take care of the order of operations to maintain consistency in the file system.

Individual or Teamwork:

You may do this project individually or in groups of two. To accomplish this project, you have the following options: If you work alone, you should implement the program to run in Linux.


What to submit:

A single gzipped tar file containing one directory with the following files:

  1. README
    README file should contain names/netIds , teammate, and a guide to the rest of the files. Also please mention which option you have chosen.
  2. Writeup
    You writeup should describe how you implemented u_export(), u_import(), u_del() and u_fschk(). What all things you considered while exporting this functions in your file system. Particularly, you should explain how you take care of the order of operations to maintain consistency in the file system in case of crashes.
  3. Here is some optional food for thought:
    What is the largest file you can create in your file system?
    What is the largest number of files?
    What is the largest number of directory it can support?
    How many subdirectory it can support?
    If we reduce the block size, we also reduce the size of the bit map and the root directory
    How do the answers to the above questions change with a block size of 1024? 8192?
    Some simple things we could do to elleviate this problem is use each bit in the bit map rather than using an entire unsigned long ( 4 bytes) to represent a "bit" and make the root level directory be variable sized (i.e. give it its own inode).

  4. Makefile and (Visual Studio project files if applicable) for compiling
  5. Source files (userfs.c & userfs.h, etc.)

Where to submit:

    Submit to moodle

Useful resources

Man pages: stat (2), fstat, lseek, read (2), write (2)