CS330 Phase Two
Simple File Manager (SFM)
In Phase One, the Simple File Manager (SFM) was designed to make new file systems, mount file systems, and display information concerning file systems. In Phase Two, commands are added to: import a file into a file system (and create a minifile with the same name and contents in the file system), copy and rename minifiles inside a file system, list the properties of the minifiles in a file system, manipulate the properties of the minifiles in a file system, and export a minifile from a file system. For all operations, the name of a minifile is restricted to being at most 15 characters long, starts with a letter, and contains only letters or digits and at most one period.
· FSimport f1 # import a file named f1 from the real file system (Windows or Unix) into the current file system to form a minifile with the same name and contents. The name of the imported file is at most 15 characters long, starts with a letter, and contains only letters or digits and at most one period.
· FScopy f1 f2 # copy a minifile named f1 in the current file system to produce another identical minifile called f2.
· FSrename f1 f2 # change the name of a minifile called f1 in the current file system to be f2.
· FSdir # list information about minifiles in the current file system; the information includes the name, size in bytes, owner, and permissions for every minifile.
· FSowner f1 u1 # changes the owner of a minifile named f1 in the current file system to be u1, where u1 is a nonnegative integer.
· FSpermission f1 p1 # changes the permissions of a minifile named f1 in the current file system as specified in p1, as described below.
· FSexport f1 # export a minifile called f1 from the current file system to form a file in the real file system (Windows or Unix) with the same name and contents.
As described in Phase One, status and protection information (a 32 bit integer) is associated with every minifile. This information is encoded in three of the four bytes in the integer, as shown below.
unused |
owner |
group |
everyone else |
||||||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
d |
r |
w |
x |
|
|
|
|
d |
r |
w |
x |
|
|
|
|
d |
r |
w |
x |
Numbering bits from the right from zero, the owner section is bits 19, 18, 17, and 16, the group section is bits 11, 10, 9, and 8, everyone else section is bits 3, 2, 1, and 0.
When the FSimport and FScopy commands create new minifiles, the permissions for these minifiles should be set to allow the owner to delete, read, write, and execute and not give any permissions to anyone else, i.e., dwrx--------. This permission corresponds to 0x000f0000 (hex) or 3840 decimal. The FSrename and FSowner commands do not affect permissions.
The FSpermission command is used to update the permissions of a minifile. The permission string for this command is expressed as a string of triples. The first member of the triple is one of {‘o’, ‘g’, ‘e’} representing the owner, the group members, and everyone else. The second member of the triple is either ‘+’ for adding a permission or ‘-’ for removing a permission. The third member of the triple is one of {‘d’, ‘r’, ‘w’, ‘x’} representing delete, read, write, and execute permissions for a minifile. For example “g+wg+dg+rg+x” grants permission to the group members to write (‘w’), delete (‘d’), read (‘r’), and execute (‘x’) the minifile. Also, “o+re-dg-xo+x” grants permission to the owner to execute and read a minifile and forbids group members from executing the minifile and everyone else from deleting the minifile. The triples may be given in any order. If two or more triples contradict each other, the last one takes precedence. For example, “o+ro-r” forbids the owner from reading the minifile.
One change from Phase 1: expand the maximum size of a simulated disk to 131,072 bytes.
Example for Phase Two:
0 0 FScreate breadbox SFFS 1 0 1248 10
1 0 FSmount breadbox fs1
2 0 FSshowmounts
3 0 FSchange fs1
4 0 FSdir
5 0 FSimport Bread.txt
6 0 FSdir
7 0 FScopy Bread.txt Butter.txt
8 0 FSrename Butter.txt Cheese.txt
9 0 FSowner Cheese.txt 9999
10 0 FSpermission Cheese.txt o-wo-xg+we+x
11 0 FSdir
12 0 FSshow
13 0 FSdump 104 36
14 0 FSdump 544 160
15 0 FSexport Cheese.txt
White bread
Whole wheat bread
French bread
Rye bread
Raisin bread
Wonderbread
Fresh bread
Home-made bread
Sliced bread
Our daily bread
SOS started on Fri Sep 29 11:06:27 2023
0 0 FScreate breadbox SFFS 1 0 1248 10
1 0 FSmount breadbox fs1
2 0 FSshowmounts
+++++++++++++++++++++++++++++++++++++++++++++++
+ FSId FS_Name FS_Disk +
+ 0 fs1 breadbox +
+++++++++++++++++++++++++++++++++++++++++++++++
3 0 FSchange fs1
4 0 FSdir
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Filename Size Owner Properties Time +
+ passwords.dat 6 0 |drwx| | | 0 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 0 FSimport Bread.txt
6 0 FSdir
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Filename Size Owner Properties Time +
+ passwords.dat 6 0 |drwx| | | 0 +
+ Bread.txt 135 0 |drwx| | | 5 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 0 FScopy Bread.txt Butter.txt
8 0 FSrename Butter.txt Cheese.txt
9 0 FSowner Cheese.txt 9999
10 0 FSpermission Cheese.txt o-wo-xg+we+x
*ERROR 22: Insufficient permission to perform operation on minifile
11 0 FSdir
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Filename Size Owner Properties Time +
+ passwords.dat 6 0 |drwx| | | 0 +
+ Bread.txt 135 0 |drwx| | | 5 +
+ Cheese.txt 135 9999 |drwx| | | 7 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 0 FSshow
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Filesystem Type UsedF MaxF UsedB MaxB %Used Diskfile +
+ fs1 SFFS 1 0 3 10 668 1248 53 breadbox +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 0 FSdump 104 36
+++++++++++++++++++++++++++++++++++++++
+ 104| 43686565| 'C' 'h' 'e' 'e' +
+ 108| 73652e74| 's' 'e' '.' 't' +
+ 112| 78740000| 'x' 't' +
+ 116| 0| +
+ 120| 215| 2 21 +
+ 124| 87| 135 +
+ 128| 270f| ''' 15 +
+ 132| 7| 7 +
+ 136| f0000| 15 +
+++++++++++++++++++++++++++++++++++++++
14 0 FSdump 544 160
+++++++++++++++++++++++++++++++++++++++
+ 544| a57686f| 10 'W' 'h' 'o' +
+ 548| 6c652077| 'l' 'e' ' ' 'w' +
+ 552| 68656174| 'h' 'e' 'a' 't' +
+ 556| 20627265| ' ' 'b' 'r' 'e' +
+ 560| 61640a46| 'a' 'd' 10 'F' +
+ 564| 72656e63| 'r' 'e' 'n' 'c' +
+ 568| 68206272| 'h' ' ' 'b' 'r' +
+ 572| 6561640a| 'e' 'a' 'd' 10 +
+ 576| 52796520| 'R' 'y' 'e' ' ' +
+ 580| 62726561| 'b' 'r' 'e' 'a' +
+ 584| 640a5261| 'd' 10 'R' 'a' +
+ 588| 6973696e| 'i' 's' 'i' 'n' +
+ 592| 20627265| ' ' 'b' 'r' 'e' +
+ 596| 61640a57| 'a' 'd' 10 'W' +
+ 600| 6f6e6465| 'o' 'n' 'd' 'e' +
+ 604| 72627265| 'r' 'b' 'r' 'e' +
+ 608| 61640a46| 'a' 'd' 10 'F' +
+ 612| 72657368| 'r' 'e' 's' 'h' +
+ 616| 20627265| ' ' 'b' 'r' 'e' +
+ 620| 61640a48| 'a' 'd' 10 'H' +
+ 624| 6f6d652d| 'o' 'm' 'e' '-' +
+ 628| 6d616465| 'm' 'a' 'd' 'e' +
+ 632| 20627265| ' ' 'b' 'r' 'e' +
+ 636| 61640a53| 'a' 'd' 10 'S' +
+ 640| 6c696365| 'l' 'i' 'c' 'e' +
+ 644| 64206272| 'd' ' ' 'b' 'r' +
+ 648| 6561640a| 'e' 'a' 'd' 10 +
+ 652| 4f757220| 'O' 'u' 'r' ' ' +
+ 656| 6461696c| 'd' 'a' 'i' 'l' +
+ 660| 79206272| 'y' ' ' 'b' 'r' +
+ 664| 6561640a| 'e' 'a' 'd' 10 +
+ 668| 30303030| '0' '0' '0' '0' +
+ 672| 30303030| '0' '0' '0' '0' +
+ 676| 30303030| '0' '0' '0' '0' +
+ 680| 30303030| '0' '0' '0' '0' +
+ 684| 30303030| '0' '0' '0' '0' +
+ 688| 30303030| '0' '0' '0' '0' +
+ 692| 30303030| '0' '0' '0' '0' +
+ 696| 30303030| '0' '0' '0' '0' +
+ 700| 30303030| '0' '0' '0' '0' +
+++++++++++++++++++++++++++++++++++++++
15 0 FSexport Cheese.txt
*ERROR 22: Insufficient permission to perform operation on minifile
SOS stopped on Fri Sep 29 11:06:27 2023
What to Submit for Phase Two:
· Document file: Write information about your software in a file, such as a text file, docx file, or pdf file.
· 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 Two in a reasonable way (reading the textbook may give you ideas). Your extra feature should be made optional, such that it does 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, called in2-11.txt, in2-12.txt, in2-13.txt, etc. Make a separate run with each input file. The test files should cover all your test cases and include at least 60 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 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). 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 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. Your own testing is needed to supplement the revealed test files.