D-Term 2006                                           CS 4513                                         Prof. D. Finkel


Assignment 3 – Version 2.0


Due Date: Monday, May 1 at 9:50 AM (corrected)


Goal: The overall goal of this assignment is to add support for subdirectories to your file system.  To do the C or B levels of this assignment, you need a B-level version of Assignment 1.  To do the A-level, you will need an A-level version of Assignment 2.  If you do not have the required version of the previous assignment, please let me know right away and I will provide one to you.


To implement subdirectories, you will have to modify your i-node structure to allow some i-nodes to represent directories instead of normal files.  In a real Unix i-node, there is a bit set to indicate that an i-node represents a directory; you may use any data type you like to indicate that an i-node is for a directory.


In a real Unix file system, the disk blocks named in the i-node for a directory contain the directory information.  In your file system, store the directory information in an array of 10 entries, with each entry with room for 96 bytes for the file name, and four bytes for the i-node number.  This array of 10 entries represents a disk block; call it a blockarray.  Reserve the first of the 10 entries to store the block number that was allocated for this blockarray; the first entry will not use the file name field.


The blockarray for a directory should look like this























This blockarray represents disk block 17, and lists 4 files and their i-node numbers.


When you create a directory, you will first need to allocate an i-node for the directory.  You will then need to allocate a block for the directory, and then create a blockarray as above, with this block number in the first row. 


To create a file in this directory, allocate an i-node for the file, allocate the required number of blocks for the file, record the file name and the i-node number in the directory’s blockarray, and record the file’s block numbers in the file’s i-node.


If the blockarray for this directory is full (i.e., the directory already has 9 files in it), you will need to allocate another block number for the directory, create another blockarray, and record the new file information in this blockarray.


Note that normal files (non-directories) do not have a blockarray; only directories have blockarrays.


You will have to create some data structure to hold the blockarrays. 


The size limits for the data structures in your file system should be as follows:


  max blocks in the entire file system = 256 (change from previous assignments)


  max i-nodes in the entire file system = 40 (change from previous assignments)


  max blocks per i-node = 10 (no change)


  max directory entries per blockarray = 9


As in Assignment 2, remote files will have pathname beginning with /remote/; any path name that does not start with /remote/ is stored on local.  (This comment does not apply to the extra credit level.)  When your program begins, it should automatically create a root directory on local and a root directory on remote (if your program will have both local and remote file systems.)  You will need to allocate an i-node for the root directory, a block number, and a blockarray.


All file commands will name the full path name, so there’s no notion of a current directory and no need to cd to a new directory.


In addition to the commands from the previous assignments, you will need to implement the following two new commands:


 T – creaTe a directory:  example: T /users/dfinkel/Letters.  This commands requires that the directory /users/dfinkel already exists, and creates the subdirectory Letters in it.  This command should fail if the directory /users/dfinkel does not exist.


L – directory Listing: example : L  /remote/users/dfinkel.  List all the files and subdirectories in the named directory.  This command should fail if the named directory does not exist.


The following file commands will need to be modified to support pathnames to describe the files:


C – Create


E – Extend


D – Delete


Grading levels:


C-level Assignment.  To receive a “C” on this assignment, you need to just implement a single directory, the root directory, or either local or remote.  (It is not required to have a remote file structure.)   The root directory must have the structure described above, but it does not need to support subdirectories.


B-level Assignment.  To receive a “B” on this assignment, you need to implement a root directory and subdirectories (of arbitrary depth) on either local or remote.  (It is not required to have a remote file structure.)


A-level Assignment.  To receive an “A” on this assignment, you need to implement subdirectories (of arbitrary depth) on both local and remote.  Any file with pathname starting with /remote/ will be on remote; any file whose pathname does not start with /remote/ will be on local.


Extra Credit.  To receive extra credit for this assignment, modify your program to support mounting.  In this level of the assignment, you will need  a new command to mount the root directory of remote over an arbitrary directory on local.  You will need to modify the data structures described above to support mounting.  In this level of the assignment, the /remote/ prefix to a pathname will not indicate that a file is on remote.  Instead, there will be only a single directory tree.  A file whose pathname crosses the mount point will be on remote; otherwise it will be on local.  For example, if the root directory of remote is mounted on /users/dfinkel, then the file /users/dfinkel/Letters/mom.txt will be on remote, and the file /users/claypool/Papers/123.tex will be on local.


Submitting your program:  Use the turnin program to submit your assignment.  Turn in your program files, but do not turn in any executable files.  Include a file named build.sh to compile your program.  If you have a makefile, build.sh could simply call make.


Include a README file explaining what level of the assignment you have completed, and a list of all the implemented features, and explain how to run your program.  Be sure to include the documentation files as specified in the CS Department Documentation Standard, located at http://www.cs.wpi.edu/Help/documentation-standard.html   You do not need to include a program listing or sample runs in your documentation.


The turnin assignment id for Assignment 3 is "project3":


/cs/bin/turnin submit cs4513 project3 myproject.zip