Add details to the design of a file system and implement it

Assignment Help Programming Languages
Reference no: EM13165113

add details to the design of a file system and implement it in detail. The file system uses a variant of the scheme used by UNIX in that it allows for a hierarchical file directory and uses pointers to individual blocks of data. The disk used has 100 blocks or sectors from 0-99, each contains 512 bytes of data. You don't need to worry about the placement of the blocks on the disk, so all access to the disk should be done through 2 procedures (need it written) DREAD and DWRITE. You don't have to do disk reads and writes, the entire disk can be simulated using a 50K block of memory.

The file system will be tested using a front end program that processes commands given as input data. These commands will exercise the file create, open, close, delete, read, write, and seek functions of the file system.

When the end of the input data is reached, the following information will be displayed: the directory illustrating its hierarchical structure, the length in bytes, and the number of free, directory, and user data blocks.

The file directory in this system will be hierarchically ordered, the root directory always begins in block 0 which has the following structure:

DECLARE 1 BLOCK0,

2 BACK FIXED BIN(31), /* ALWAYS ZERO IN THIS BLOCK */

2 FRWD FIXED BIN(31), /* BLOCK NUMBER OF SECOND DIRECTORY BLOCK, OR ZERO */

2 FREE FIXED BIN(31), /* BLOCK NUMBER OF FIRST UNUSED BLOCK */

2 FILLER CHARACTER(4), /* UNUSED */

2 DIR(31), /* DIRECTORY ENTRIES */

3 TYPE CHARACTER(1), /* 'F' = FREE, 'D' = DIRECTORY, 'U' = USER DATA */

3 NAME CHARACTER(9), /* FILE NAME, LEFT-JUSTIFIED, BLANK FILLED */

3 LINK FIXED BIN(31), /* BLOCK NUMBER OF FIRST BLOCK OF FILE */

3 SIZE FIXED BIN(15); /* NUMBER OF BYTES USED IN THE LAST BLOCK OF THE FILE */

 

The remaining blocks in the root file directory, if any, will be linked to blcok zero using the FRWD entry. These blocks, and blocks in the subordinate directories will have exactly the same structure as block zero, except that the FREE entry will be unused. This entry in block zero is used to point to the first unused block on the disk. The unused blocks should form a linked list which must be initially created when the file system starts execution.

 

The TYPE entry of each directory entry determines what type of file is referenced. 'F' is used to indicate that an entry in the file directory is unused. 'D' indicates that the entry points to another (subordinate) directory, while 'U' indicates that the entry points to a user data file. File names are given as strings of up to 9 alphabetic characters separated by virgules, or slashes.

 

The first file name would be located in the root directory as a user data file. The second file name would be found first in the root directory as a subordinate directory called SUB, then in the SUB directory as a user data file called SAMPLE. The third file name would involve two subordinate file directories, the first called SUB1 located in the root directory, the second called SUB2 located in the SUB1 directory, and the last called SAMPLE located in the SUB2 directory as a user data file. Each block in a data file, except the last, is considered full. The number of data bytes present in the last block of a data file is indicated by the SIZE field of the directory entry. Note that the directory blocks always have exactly 31 entries, with unused entries marked by a type field of 'F'.

 

Data files also form linked lists. The structure of a data file block is:

 

DECLARE 1 DATA_BLOCK,

2 BACK FIXED BIN(31), /* BLOCK NUMBER OF PREVIOUS BLOCK */

2 FRWD FIXED BIN(31), /* BLOCK NUMBER OF SUCCESSOR BLOCK */

2 USER_DATA CHAR(504) /* USER DATA BYTES */

 

The first and last data blocks of a file will have the BACK and FRWD fields respectively, set to zero. These will not point to block zero, since that is always the first directory block, but will rather indicate the end of the linked data block list. The maximum number of bytes in a data block is 504.

 

Each command that may be processed by the file system is matched by an input command line. The syntax of these command lines, and the processing to be performed is:

 

CREATE type name

 

"type" is either U or D, and indicates whether a User data file or a Directory file is to be created. "name" is a full file name in the form described above. Neither of these items is enclosed in quotes. The CREATE command should cause a new directory entry to be created for the type of file specified. If CREATE is given for an existing file, no error should occur, but the file should be deleted and then reCREATEd. CREATE also leaves the file in the same state as an OPEN in the output mode.

 

OPEN mode name

 

"mode" is either I, O, or U indicating the file named "name" is to be opened in the Input, Output, or Update mode. Input mode means that only READ and SEEK commands are permitted while Output mode means only WRITE commands are permitted. Update mode allows READ, WRITE, and SEEK commands. Associated with each open file is a pointer to the next byte to be read or written. Opening a file for input or update places the pointer at the first byte of the file, while opening a file for output places the pointer at the byte immediately after the last byte of the file.

 

CLOSE

 

command causes the last OPENed or CREATEd file to be closed.. No filename is given.

 

DELETE name

 

This command deletes the named file.

 

READ

 

This command may only be used between an OPEN (in input or update mode) and the corresponding CLOSE. If possible, "n" bytes of datea should be read and displayed. If fewer than "n" bytes remain before the end of the file, then those bytes should be read and displayed with a message indicating that the end of file was reached.

 

WRITE n 'data'

 

This command causes the first "n" data bytes from 'data' (actually enclosed in single quotes in the command line) to be written to the file. If fewer than "n" bytes are given, then append sufficient blanks to 'data' to make "n" bytes. If it is impossible to write "n" bytes (because the disk is full) then an appropriate message should be issued, but the command should be otherwise treated as if the largest possible value of "n" was specified. (That is, the remaining available disk space should be filled.)

 

SEEK base offset

 

"base" is either -1, 0, or +1 indicating the beginning of the file, the current position in the file, or the end of the file. "offset" is a signed integer indicating the number of bytes from the "base" that the file pointer should be moved. For example, "SEEK -1 0" is a rewind, "SEEK +1 0" is equivalent to a position to end of file, and "SEEK 0 -5" positions the file pointer backward by five bytes.

 

 

Reference no: EM13165113

Questions Cloud

Determine the best sales mix and rank the services : Determine the best sales mix and Rank the services offered in order of their profitability and what additional amount of total contribution margin would be generated if your recommendation is accepted?
Hip-hop culture similar cultural phenomenon : Explain the appeal of Harlem’s nightlife to whites, especially during Prohibition. Discuss whether you consider the cross-over appeal of Hip-Hop culture a similar cultural phenomenon today.
Java test program : Write a Java test program, all your code should be in the main method, that determines what type of organization is indicated by a web address. Your program should allow the user to enter a web address
Program that converts the temperature : Write a program that converts the temperature F in Farenheit to C in Celsius using C = (F-32)*5/9. For ease of programming you can display the result in fractions
Add details to the design of a file system and implement it : add details to the design of a file system and implement it in detail. The file system uses a variant of the scheme used by UNIX in that it allows for a hierarchical file directory and uses pointers to individual blocks of data. The disk used has 100..
State the most common error students make during a titration : The most common error students make during a titration is that they add extra NaOH past the endpoint causing the solution to change a dark pink color.
Calculate the loses frequency of that can ionize : an energy of 353 kJ/mol is required to cause a Mg atom on a metal surface to lose an electron. calculate the loses frequency of that can ionize a Mg atom.
Beneficial elements to harmful technologies : In your opinion, what recent technology has produced the greatest benefit? Which has produced the greatest harm? Are there harmful elements to beneficial technologies? Beneficial elements to harmful technologies?
Estimate the molar mass of the element : the specific heat of an unknown metal is found to be 0.233 j kg. The law of dulong and petit predicts a molar heat capacity of J/K mol. Use this law to estimate the molar mass of the element.

Reviews

Write a Review

Programming Languages Questions & Answers

  Explaining class with no constructors

How many constructors can a class have? Can you have a class with no constructors? If a class has more than one constructor, which of them gets called?

  Program has function named presentvalue for calculations

Write a program that has a function named presentValue that performs this calculation. The function should accept the future value, annual interest rate, and number of years as arguments.

  Design main driver class to instantiate-compute sum-objects

Design a main driver class to instantiate and calculate sum of several MonetaryCoin objects. Demonstrate that monetary coin inherits its parent's ability to be flipped.

  Create math sorting game using visual basic studio

using visual basic studio 2010, Create math sorting game. Random number between 1 and 99 will be generated and displayed to the user.

  Write the program which processes test data

Write the program which processes test data. Output must be student's ID, followed by answers, followed by test score, followed by test grade. Suppose the following grade scale.

  Explaining variable in an arrays of ints

Assume that variable A is an arrays of ints. Consider the following code segment.

  Implement shape hierarchy-compute area of two-dimensional

Implement Shape hierarchy. Each TwoDimensionalShape must contain function getArea to compute the area of two-dimensional shape. Each ThreeDimensionalShape must have member functions.

  Write program which reads in weight in pounds and ounces

Write the program which reads in the weight in pounds and ounces and putputs equivalent weight in kilograms and grams. Utilize at least three functions.

  Design program to ecode message using caesar cypher

Design a program which decodes messages. Messages will be encoded using Caesar cypher, with each letter being decoded by replacing it with previous letter in alphabet.

  Give value of mytop and contents of the array

Assume that stack is the class described in this section with stacktype set to int and stack_capacity or mycapacity set to 5. Give the value of mytop and the contents of the array.

  Program to use next character to create and return operator

Convert the string of digits into an integer. Otherwise, use the next character to create and return an operator.

  Write program which translates letter grade into grade

Write a C++ program which translates the letter grade into a number grade. Letter grades are A B C D F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1, and 0.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd