CS330 Phase One

Simple File Manager (SFM)

 

In this phase, you will provide a file manager named the Simple File Manager (SFM).  SFM will manipulate a file system stored on a simulated disk.  The simulated disk is a normal binary file.  For Phase One, the simulated disk consists of up to 8192 bytes (to be expanded to 131,072 bytes in later phases). 

 

Phase One implements the overall management of file systems.  SFM can install a new simulated disk, format the simulated disk to create a file system, load information about the file system into SOS (referred to “mounting the file system”), and display information about the mounted file systems and contents of particular file systems.  By default: (1) the name of the user is “root”, (2) the user id for the user is 0, and (3) no file systems are initially mounted.  At most ten file systems can be mounted simultaneously.

 

Unlike normal operating systems, SOS logs every instruction it executes in a log file named something like out1-01.txt, where “1-01” means “Phase 1, test file 01”. Output is also placed in the log file.

 

With SOS, a disk name, a file name, or a file system name is at most 15 characters long, starts with a letter, and contains only letters or digits and at most one period (.). 

 

Examples of commands that manipulate the simulated disk and the file system on it are as follows:

·         FScreate d SFFS 1 0 n1 n2 # Create a file system of type SFFS, major version 1, minor version 0 on the simulated disk named d.  The overall size of the simulated file system (which is really stored as a binary file) is n1 bytes. The number of bytes n1 is from 0 to 8192 for Phase One and must be divisible by 4.The file system has room for a maximum of n2 files.  The file system, including the file header, file index, and space for files occupies n1 bytes.  One file, named “passwords.dat”, is created in the file system with one entry for the “root” account with no password.  The entry consists of precisely 6 characters: the word “root”, a colon (:) separator, a newline (control-J, ASCII 10 decimal or 012 octal).  Fill up the rest of the simulated disk with the symbol 0 (i.e., ‘0’, which is ASCII 48 decimal or 060 octal).  Example: FScreate d1 SFFS 1 0 1024 8

·         FSmount d f # Add the file system stored in the simulated disk named d to the table of mounted file systems in SOS and name it f.  The name of the file system is at most 15 characters long, starts with a letter, and contains only letters or digits and at most one period (.)  Example: mount d1 fs1

·         FSshowmounts # display the mounted file systems and their corresponding simulated disks.

·         FSchange f # (Change file system) Use the file system named f as the current file system for subsequent file system operations (and file operations in Phase Two).  Example: FSchange fs1

·         FSdump n1 n2 # display the contents of the current file system starting at an offset of n1 bytes and continuing for a total of n2 bytes; n1 and n2 must be divisible by 4; show both signed four-byte integer and char representations of each group of four bytes. Example: FSdump 1200 52

·         FSshow # display the main properties of the current file system.

·         FSdate n # set the current date and time in the simulated OS to be n.

·         FSshowdate # show the current date-time in the simulated OS as a simple integer.

 

All commands are preceded by two numbers representing the time and the user.  For Phase One, these numbers can be ignored except for reading them in from the input file.

 

The file system is a version 1.0 Simple Format File System (SFFS 1.0).  It consists of the following:

 

Example: For the fs1 file system, the 1024 byte file is used as follows: 32 bytes for the file system header, 8 * 36 =  288 bytes for the file index, and 1024 – 32 – 288 = 704 bytes for the minifiles.

 

Name your program sos, and run it with:  sos in1-01.txt out1-01.txt

or (for Phase 1)                                       sos < in1-01.txt > out1-01.txt

 

Sample input file named in1-01.txt:

 

   0 0 FScreate d1 SFFS 1 0 1024 8

   1 0 FSmount d1 fs1

   2 0 FSshowmounts

   3 0 FSchange fs1

   4 0 FSshowmounts

   5 0 FSdump 0 56

   6 0 FSdump 316 16

   7 0 FSshow

   8 0 FSdate 80

  81 0 FSshowdate

  82 0 FScreate d2 SFFS 1 0 8096 200

  83 0 FSmount d2 fs2

  84 0 FSshowmounts

  85 0 FSshowdate

 

SOS FETCH-EXECUTE CYCLE:

 

SOS (combined with the simulated machine) opens the log file and repeatedly performs these steps:

·         update the clock (for Phase One, it should match the number in the first entry of the instruction line),

·         if necessary, run the scheduler (this step can be ignored in Phases One and Two),

·         fetch the next instruction from the input file, e.g., in1-01.txt,

·         decode the instruction by identifying the instruction name and parameters,

·         execute this instruction (decoding and executing steps can be combined if you wish.),

·         repeat the above series of steps until there are no more instructions.

When there are no more instructions, SOS should close the log file and stop.  Information is printed to the log file for each instruction telling the current (simulated) time, the current user id, the current instruction, and the results (if there are any) or an error message.

 

ERROR CHECKING:

 

SOS should handle any type of input (txt file) without failing (crashing).  For invalid input, print a suitable error message from the list given below.  Design at least two valid examples and two invalid examples of each command.  You should use the examples you designed as test cases to show that your software accepts all valid cases and rejects all invalid cases.

 

List of Error Messages:

 

      "System error",                           //  1

      "Invalid instruction",                    //  2

      "Invalid parameter",                      //  3

      "Cannot create diskfile",                 //  4

      "Unsupported filesystem type",            //  5

      "Cannot format disk",                     //  6

      "Insufficient room in filesystem",        //  7

      "Maximum files in filesystem",            //  8

      "Cannot update filesystem",               //  9

      "Cannot read filesystem",                 // 10

      "Invalid filesystem",                     // 11

      "Mount table is full",                    // 12

      "Filesystem is not mounted",              // 13

      "No filesystem has been specified",       // 14

      "Filesystem is already mounted",          // 15

 

If multiple errors exist in an input command, alternate error messages may be accepted.

 

MISCELLANEOUS:

·         If a ‘#’ character occurs in an input line, ignore it and any characters in the rest of the line.

·         The minimum file system size is 32 + 36 * (maximum number of minifiles) + 6.

·         Error messages are displayed with “*ERROR” followed by a space, an error number, a space, and an error message.

·         For an explanation of when to use particular error messages, see ErrorMessages.txt.

·         The current file system is marked with five asterisks (*****) near the right hand side in the output from the FSshowmounts command.

 

Example of a Log File, out1-01.txt

SOS started on Mon Sep 25 21:28:56 2023

 

   0 0 FScreate d1 SFFS 1 0 1024 8

   1 0 FSmount d1 fs1

   2 0 FSshowmounts

+++++++++++++++++++++++++++++++++++++++++++++++

+ FSId FS_Name         FS_Disk                +

+    0 fs1             d1                     +

+++++++++++++++++++++++++++++++++++++++++++++++

   3 0 FSchange fs1

   4 0 FSshowmounts

+++++++++++++++++++++++++++++++++++++++++++++++

+ FSId FS_Name         FS_Disk                +

+    0 fs1             d1               ***** +

+++++++++++++++++++++++++++++++++++++++++++++++

   5 0 FSdump 0 56

+++++++++++++++++++++++++++++++++++++++

+       0| 53464653|  'S' 'F' 'F' 'S' +

+       4|        1|                1 +

+       8|        0|                  +

+      12|       20|              ' ' +

+      16|      400|            4     +

+      20|        8|                8 +

+      24|      146|            1 'F' +

+      28|        1|                1 +

+      32| 70617373|  'p' 'a' 's' 's' +

+      36| 776f7264|  'w' 'o' 'r' 'd' +

+      40| 732e6461|  's' '.' 'd' 'a' +

+      44| 74000000|  't'             +

+      48|      140|            1 '@' +

+      52|        6|                6 +

+++++++++++++++++++++++++++++++++++++++

   6 0 FSdump 316 16

+++++++++++++++++++++++++++++++++++++++

+     316| 30303030|  '0' '0' '0' '0' +

+     320| 726f6f74|  'r' 'o' 'o' 't' +

+     324| 3a0a3030|  ':'  10 '0' '0' +

+     328| 30303030|  '0' '0' '0' '0' +

+++++++++++++++++++++++++++++++++++++++

   7 0 FSshow

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ Filesystem       Type     UsedF  MaxF UsedB  MaxB %Used Diskfile         +

+ fs1              SFFS 1 0     1     8   326  1024    31 d1               +

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

   8 0 FSdate 80

  81 0 FSshowdate

+++++++++++++++

+ Date:    81 +

+++++++++++++++

  82 0 FScreate d2 SFFS 1 0 8096 200

  83 0 FSmount d2 fs2

  84 0 FSshowmounts

+++++++++++++++++++++++++++++++++++++++++++++++

+ FSId FS_Name         FS_Disk                +

+    0 fs1             d1               ***** +

+    1 fs2             d2                     +

+++++++++++++++++++++++++++++++++++++++++++++++

  85 0 FSshowdate

+++++++++++++++

+ Date:    85 +

+++++++++++++++

 

SOS stopped on Mon Sep 25 21:28:56 2023

 

What to Hand In for Phase One: 

 

·      Document: Write a description of your program and testing in a text, docx, or pdf file, with the following headings:

·      Test cases:  Explain in a general way how invalid input is handled.  Give at least two examples of valid uses and two examples of invalid uses for each command.  Assign each of these examples a “test case number”.

·      Design of your software: Identify the OS platform and compiler used to create your software.  Give a pictorial overview of the organization of your software into modules/functions/objects, explain the main or novel aspects of design (typed, with machine-produced pictures).

·      Extra Feature (15% of grade for the phase): Describe an extra feature (or several extra features) that you added to your file system manager above and beyond the stated requirements.  Your extra feature should extend the design of Phase One in a reasonable way (reading the textbook may give you ideas). Your extra feature should be made optional, so that it has no effect until the optional1 command has been executed (or some similar way of turning it on).  Before being turned on, it must not invalidate SOS’s behavior on the testing data.  Explain why the feature is useful and how you tested it. Your extra feature must not be the same as a required feature for subsequent phases of the project.

·      Testing results:  Test your virtual machine thoroughly on valid and invalid input.  Design at least three of your own input files, named in1-11.txt, in1-12.txt, in1-13.txt, etc.  Make a separate run with each input file.  The test files should cover all your test cases and include at least 100 lines in total.  Draw up a table with the following columns: (1) Test case number,  (2) Expected result, (3) Log file number, (4) Lines, and (5) Worked? (YES or NO).  The Lines column identifies the relevant lines in the log file where the test case is shown.

 

Source Code for SOS: Provide neatly formatted source code for your version of SOS, in the programming language of your choice (check with the instructor if this is not C, C++, or Java).  For C++, provide .cpp and .h files rather than executable files. You are required to include:

o  boxed comments for every file of code and for every class and for every function/procedure/method more than 10 lines long,

o  functions/procedures/methods no more than one page (66 lines) long,

o  adequate white space,

o  symbolic constants (e.g., MAX_PROCESSES) rather than numbers,

o  at most 80 characters in each line,

o  indenting of contents of conditional (if) and repetition (for, while) statements; if you are following published style guidelines, cite a reference for the style guidelines.

 

Electronic submission:  you will submit all code and test files electronically to URCourses by deadline date and time.  Your program will be evaluated on a set of ten input files, five of which will be revealed to you before the deadline.  You will need to perform your own testing to supplement the five revealed test files.