CMSC-341 Spring 2007

Project 2

Assigned Wednesday, Feb 28, 2007
Due Tuesday, March 13, 2007


Background

Lists are one of the fundamental abstract data types. This project will give you experience in using List, modifying List code and using List iteratators in the context of a dynamic disk file allocation system.


Description

On of the fundamental tasks of every operating system is the management of the disk blocks used to store data in files. In this project you will implement a very rudimentary disk file manager.

In our operating system, the disk is divided disk blocks. Each block is divided into bytes. The file manager is responsible for keeping track of unused (free) disk blocks and all necessary information about every file. The file manager handles requests to create new files, extend existing files, truncate existing files, and delete existing files. It is also possible to print all information within the file manager.

You will implement classes to model the file manager and files within the file manager. You will use the author's Linked List class as well as a modified version of that code to support sorted linked lists.

The number of disk blocks in our system and the number of bytes per disk block will be command line parameters.

Here are your tasks. Operations such as construction, destruction, accessors, and mutators (as necessary) are assumed and not listed for classes.

  1. Obtain the author's linked list files from Mr. Frey's public directory for this project /afs/umbc.edu/users/f/r/frey/pub/CMSC341/Proj2/
  2. Use the author's code to implement a sorted linked list class.
  3. Implement main( ) in Proj2.cpp to read and process the command file
  4. Implement the File class. The file class contains all pertinent information about a file within the file manager. The information maintained by the File class are
    1. The file name
    2. The actual size of the file
    3. The allocated size of the file
    4. The number of blocks allocated to the file
    5. A list of disk blocks allocated to the file
    The operations of the File class are
    1. Print all information about a File
    2. Necessary comparison operator(s)
  5. Implement the FileManager (FM) class.
    The FM class maintains the following information
    1. A list of free disk blocks, sorted by disk block number
    2. A list of Files, sorted by file name
    The FM class supports the following operations
    1. Create a new file with the specified name and size in bytes.
    2. Extend an existing file by the specified number of bytes
    3. Truncate an existing file by the specified number of bytes
    4. Delete the specified file
    5. Print the contents of the File Manager
    Disk block numbers are integers (starting at zero). Note in the sample output that disk blocks must be printed as ranges.

    FM Errors

    All FM errors must be handled with an appropriate exception.

    The file manager must detect the following errors:

    1. Insufficient disk space when an request to allocate disk blocks cannot be fulfilled because there are not enough free blocks.
    2. No such file whenever an attempt is made to extend, truncate, or delete a non-existing file.
    3. Duplicate file whenever an attempt is made to create a file that already exists.
    4. File Underflow whenever an attempt is made to truncate a file by more bytes than are in the file. In this case, the file should remain unchanged.

  6. Answer the questions posed in 341-Spring07-proj2_questions.txt. Copy the file /afs/umbc.edu/users/f/r/frey/pub/CMSC341/Proj2/341-Spring07-p1_questions.txt to your own directory and edit it to provide your answers to the questions. Don't forget to submit the edited file; it's 10% of this project's grade.
  7. Implement a makefile for your project. Note that your executable MUST be named Proj2 so that the grading scripts will find and execute your code.

Other Project Requirements

  1. All "lists" in this project must be implemented as Linked-Lists using the author's code as a base. Vectors are not permitted in any class.
  2. Only the FileManager class can be instantiated in main( ). The File class is only used by the FileManager. Your design and implementation must prohibit the use of File by any other class or program.
  3. FileManager errors must be implemented using appropriate exceptions

The Command Line

Project 2 will be invoked with a command line that consists of three arguments. The first argument specifies the number of disk blocks in our system. The second argument specifies the number of bytes in each disk block. The third argument will be the name of a file that contains a set of operations that must be performed to exercise our FileManager. The format of this file is described in the command file section below.

Note that you must check command line arguments to ensure that they are valid, e.g. that the command file can be opened, and print an appropriate message if an error is found.


The Command File

Commands in the file specify operations to be performed on the FileManager. Each line in the file represents one command. Blank lines may appear anywhere in the file and should be ignored. Lines in which the first character is '#' are comments and should also be ignored. Otherwise, you can assume that any line containing a command is syntactically well-formed. We make this assumption so you don't have to spend lots of time making the command file parser bullet proof.

The command file format follows:


Sample Output

Sample output is available for your study at /afs/umbc.edu/users/f/r/frey/pub/CMSC341/Proj2/p2-sample_output.txt

A sample command file is also available. Use this command file with a block size of 1024. /afs/umbc.edu/users/f/r/frey/pub/CMSC341/Proj2/p2-commands.txt
The sample command file is not a thorough test of the project, but just that -- a sample. Be sure to create you own command files for thoroughly testing of your code.


Files To Be Submitted

You should submit only the files you have written, a makefile, and the file containing your answers to the questions. The files to be submitted are:

Submit Tools

There are a number of tools available to you to check on your submittal. It is your responsibility to ensure that the submittal is correct and will result in a successful
compilation of your project. Do not wait till the last minute to submit your files. Give yourself enough time to check that your submittal is correct.

If you don't submit a project correctly, you will not get credit for it. Why throw away all that hard work you did to write the project?
Check your submittals. Make sure they work. Do this before the due date.

Documentation for the submit program is on the web at http://www.gl.umbc.edu/submit/. One of the tools provided by the submit program is
submitls. It lists the names of the files you have submitted.

Additionally, there are two programs for use only by CMSC-341 students (not part of the UCS submit program). They are in the directory /afs/umbc.edu/users/f/r/frey/pub/CMSC341/ and are named submitmake and submitrun. You can use these programs to make or run your submitted projects.

The syntax is similar to that for submit:

submitmake <class> <project>

Example:  submitmake cs341 Proj2

This "makes" the project, and shows you the report from the make utility. It cleans up the directory after making the project (removes .o files), but leaves the executable in place.

submitrun <class> <project> [command-line args]

Example:   submitrun cs341Proj2 checkers checkfile.dat

This runs the project, assuming there is an executable (i.e. submitmake was run successfully). Any data files used by your project must be in your local directory.


Grading and Academic Integrity

Your project will be tested using a variety of command files which will test various conditions which your code should handle.

Project grading is described in the Project Policy handout.

Your answers to 341-Spring07-proj2_questions.txt are worth 10% of your project grade.

Cheating in any form will not be tolerated. Please re-read the Project Policy handout for further details on honesty in doing projects for this course.

Remember, the due date is firm. Submittals made after midnight of the due date will not be accepted. Do not submit any files after that time.