The layout of your 128 KB disk is as follows
char name[8]; //file name int size; // file size (in number of blocks) int blockPointers[8]; // direct block pointers int used; // 0 => inode is free; 1 => in use
Note that each inode is 48 bytes in size, since a char has size 1 and an int has size 4. Together, all 16 inodes take up 768 bytes. Combining this with the free block list gives us a total size of 896 bytes for the super block. The super block may not fill the 1 KB, but start writing file blocks after 1KB into the disk.
You need to implement the following operations for your file system.
create_fs disk0
This will create a file with the name
disk0in your current directory. The program also "formats" your file system---this is done by initializing all blocks in the super block to be free and marking all 16 inodes to be free. The file create_fs.c in the starter code allows you to create an empty file system.
The starter code on moodle also includes a file FileSystem.cpp that includes the template code for your file system. We have provided copious comments for each method so that you know how to implement each function.
Your program should take input from a input file and perform actions specified in the file, while printing out the result of each action. The format of the input file is as follows.
diskName // name of the file that emulates the disk C fileName Size //create a file of this size D fileNAme // delete this file L // list all files on disk and their sizes R fileName blockNum // read this block from this file W fileName blockNum // write to this block in the file (use a dummy 1KB buffer)An sample input file looks like this:
disk0 C file1 3 W file1 0 W file1 1 C lab.java 7 L C file2 4 R file1 1 D lab.java LA sample input file is also provided in the starter code. Be sure to print out what your program does after reading each line from this file. It'd also be helpful if you printed out the disk addresses of any block that you allocate, deallocate, read or write.
Like in the previous assignment, the test directory contains some simple tests for your filesystem implementation. You should write your own tests for each function you implement: read, write, create, ls, delete. The tests can use the GTest framework but they don't need to. You can use specific input files to test your code (for example, trying to create an existing file should give you an error, or trying to delete a non-existent file should be an error, or listing files after deleting a file should no longer list the file etc). Your readme file should contain details of how you tested each function of the file system using valid and invalid inputs. You should also provide a brief description of how you debugged your code - either with a debugger of through other means.
Once you have written your version of the file system code, write a design document that documents your design choices. The design doc should be written in plain text in a file called README.txt.
The README file should also document observations from running your code with various inputs and your experience with testing / debugging and the test case you wrote.
We will use the gradescope autograder system to submit and grade your assignment.
It is important that you keep the directory structure the same as what we have given to you in the starter code. You may not be able to receive a grade otherwise.To submit your code to gradescope, you need to create a zip file and upload it through your gradescope account. Your should zip your src and test folders directly into a zip file (do not zip the parent directory). You can use the following command: zip -r mycode.zip src test to create the zip file, or use any GUI based method or zip program to create the zip file. For example, on a Mac, select the src and test directory using the command key and then right click to select "Compress two items".
Once you upload to gradescope, it will run some tests and let you know how many tests passed or if your code failed to complile or failed to terminate. While we will not reveal the test cases, we will give you brief indication of the type of tests that failed on your code to help you understand what may be going wrong. You can submit as many times as you wish to gradescope until the deadline or until your code passes all tests.
You should be very careful about using code snippets you find on the Internet. In general your code should be your own. It is OK to read tutorials on the web and use these concepts in your assignment. Blind use of code from web is strictly disallowed. Feel free to check with us if you have questions on this policy. And be sure to document any Internet sources/ tutorials you have used to complete the assignment in your README file.
(max 100) Total Grade