Docsity

CS 3100 Lab #5: File System Simulation (Low-Level Operations) Assignment - Prof. Delroy Br, Lab Reports of Operating Systems

Toggle sidebar
bg1
CS 3100 Lab #5
File System Simulation (Low-Level Operations)
Assignment
Complete the following seven low-level functions:
1. readBlock
2. loadFAT
3. allocate
4. getByName
5. writeBlock
6. saveFAT
7. unlink
Provided Files
A zip file (lab5.zip) is included on the class web site with this assignment. The zip file contains
eight files:
1. FileSystem.h class declaring constants, functions, and data - public features will
be made private in subsequent labs, new functions will be added
2. FileSsytem.cpp constructor and destructor; stubs for the lab 5 functions
3. mkfs.cpp makes the file system (shouldn’t be needed in this lab)
4. filesystem a ready-made simulated file system used for development and
testing - 1 MB is size but compresses nicely in the zip file; this file
is binary and compatibility with other systems is not guarantied
5. test1.cpp tests functions 1 - 4; does not modify filesystem
6. test2.cpp test functions 5 - 7; modifies the FAT in filesystem
7. test1.txt the output generated by test1
8. test2.txt the output generated by test1 AFTER test2 is executed
Methodology
Test your functions with the provided test1.cpp and test2.cpp files; test1 does not modify the
simulated file system but test2 does (you may wish to maintain a backup copy of filesystem).
Both readBlock and loadFAT must be written before testing may begin and both must be correct
before testing other functions. Remove the comments from main in test1 to test allocate and
getByName.
When test1 is complete and correct, then begin implementing functions 5 - 7. The unlink
function (called in test2) will remove a file from the FAT (however, the entry will remain in the
root directory for now). The file system destructor will save the FAT when test2 ends, which
will call saveFAT, which calls wriateBlock - testing all three functions. View the results of test2
by re-running test1.
pf2

Partial preview of the text

Download CS 3100 Lab #5: File System Simulation (Low-Level Operations) Assignment - Prof. Delroy Br and more Lab Reports Operating Systems in PDF only on Docsity!

CS 3100 Lab

File System Simulation (Low-Level Operations)

Assignment

Complete the following seven low-level functions:

  1. readBlock
  2. loadFAT
  3. allocate
  4. getByName
  5. writeBlock
  6. saveFAT
  7. unlink

Provided Files

A zip file (lab5.zip) is included on the class web site with this assignment. The zip file contains eight files:

  1. FileSystem.h class declaring constants, functions, and data - public features will be made private in subsequent labs, new functions will be added
  2. FileSsytem.cpp constructor and destructor; stubs for the lab 5 functions
  3. mkfs.cpp makes the file system (shouldn’t be needed in this lab)
  4. filesystem a ready-made simulated file system used for development and testing - 1 MB is size but compresses nicely in the zip file; this file is binary and compatibility with other systems is not guarantied
  5. test1.cpp tests functions 1 - 4; does not modify filesystem
  6. test2.cpp test functions 5 - 7; modifies the FAT in filesystem
  7. test1.txt the output generated by test
  8. test2.txt the output generated by test1 AFTER test2 is executed

Methodology

Test your functions with the provided test1.cpp and test2.cpp files; test1 does not modify the simulated file system but test2 does (you may wish to maintain a backup copy of filesystem). Both readBlock and loadFAT must be written before testing may begin and both must be correct before testing other functions. Remove the comments from main in test1 to test allocate and getByName.

When test1 is complete and correct, then begin implementing functions 5 - 7. The unlink function (called in test2) will remove a file from the FAT (however, the entry will remain in the root directory for now). The file system destructor will save the FAT when test2 ends, which will call saveFAT, which calls wriateBlock - testing all three functions. View the results of test by re-running test1.

Hints

The two most difficult functions in this assignment are loadFAT and saveFAT. The FAT is 4K in size: int FAT[BLOCKSZ]; (BLOCKSZ is 1K, so why is the FAT 4K?). The simulated file system reads and writes blocks 1K in size, implying that it takes four reads or writes to load or save the FAT. The challenge is calculating the parameters to readBlock and writeBlock.

The parameters are the same for both functions:

readBlock(int block, void* buffer) writeBlock(int block, void* buffer) “block” is the LBA of the disk block being read or written; “buffer” is the memory address of the transfer buffer (data is either coming from or going to this address). loadFAT calls readBlock four times and saveFAT calls writeBlock four times. The challenge is calculating the correct LBA (relatively easy) and the correct memory address (done with address arithmetic and a little more difficult until you’ve done it once).

The calculations use two symbolic constants defined in FileSystem.h: FATBLK the LBA of the beginning of the FAT on the simulated hard drive QBLK one-quarter of a BLOCKSZ

So, the LBA of any part of the FAT is: FATBLK + i; 0 # i < 4 The buffer address is calculated as an offset from the FAT (a variable defined in the FileSystem class) using address arithmetic: FAT + i * QBLK; 0 # i < 4

Grading

Upload your completed FileSystem.cpp to WSU Online for grading.