Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The functions you NEED to write (i.e., the filesystem driver) In this assignment, another application (a.k.a., the unit-tests provided to you) will call your code

image text in transcribed

image text in transcribed

image text in transcribed

The functions you NEED to write (i.e., the filesystem driver) In this assignment, another application (a.k.a., the unit-tests provided to you) will call your code to evaluate your application by trying to save, read, and write files to the block storage and validate your results. Unit-testing will use your functions to do so, hence do not change function names (you will be penalized). For this assignment (HINT: but not future ones, so plan ahead), there will only ever be one file open at a time, and furthermore, each file that the user wants to write to the device will always fit within the maximum possible size of a block (HDD_MAX_BLOCK_SIZE). Thus, in this assignment, there is a one-to-one mapping of files to blocks. when your code is called, hdd open will be the first function called and will be given a filename. Your function code must return a number, also called a file handle, which will uniquely refer to that particular file across all your other functions. For instance, when the user wants to write something to a file on the device, your hdd write function will be called with the first parameter being the corresponding file handle you previously returned in hdd_open. If the user tries to call any of your functions (besides hdd open) with a file that is not open, you must return -1 (i.e. unsuccessful) and handle appropriately. You must keep track of whether or not a file is open using your own data structure. You can assume that when a user opens a file for the first time via hdd open, that there is no pre- existing data in the block storage about that file. The application will need to call hdd write in order to write anything about this file for the first time to a block. Then the application will need to call hdd read to get back any data that has been written to that file. When the application has finished using a file (i.e. read/write), it calls hdd close. For this assignment, calling hdd close will delete al the contents of the file in the block storage (HINT: future assignments will keep contents). Lastly, where the application starts reading from and writing to in a file is determined by the current seek position. The seek position is automatically placed at the end of the last read/write operation. The hdd seek function places the seek position wherever the user would like within the file (again, it is recommended to understand the standard seek C function) As a programmer, it is up to you to decide how to implement these functions. However, the functions must maintain the file contents in exactly the same way as a normal filesystem would (meaning do not re- order the bytes of data). The functions that you are to implement are declared in hdd file_io.h and should be implemented in hdd _file_io.c as follows: Function Description hdd open1]This call opens a file (i.e., sets any initially needed metadata in your data structure) and returns a UNIQUE integer file handle (to be assigned by you) [2] For this assignment, the file can be assumed to be non-existent on the device [3] You should initialize the device here (but only the first time this function is called i.e. singleton pattern) [4] The function returns -1 on failure and UNIQUE integer on success The functions you NEED to write (i.e., the filesystem driver) In this assignment, another application (a.k.a., the unit-tests provided to you) will call your code to evaluate your application by trying to save, read, and write files to the block storage and validate your results. Unit-testing will use your functions to do so, hence do not change function names (you will be penalized). For this assignment (HINT: but not future ones, so plan ahead), there will only ever be one file open at a time, and furthermore, each file that the user wants to write to the device will always fit within the maximum possible size of a block (HDD_MAX_BLOCK_SIZE). Thus, in this assignment, there is a one-to-one mapping of files to blocks. when your code is called, hdd open will be the first function called and will be given a filename. Your function code must return a number, also called a file handle, which will uniquely refer to that particular file across all your other functions. For instance, when the user wants to write something to a file on the device, your hdd write function will be called with the first parameter being the corresponding file handle you previously returned in hdd_open. If the user tries to call any of your functions (besides hdd open) with a file that is not open, you must return -1 (i.e. unsuccessful) and handle appropriately. You must keep track of whether or not a file is open using your own data structure. You can assume that when a user opens a file for the first time via hdd open, that there is no pre- existing data in the block storage about that file. The application will need to call hdd write in order to write anything about this file for the first time to a block. Then the application will need to call hdd read to get back any data that has been written to that file. When the application has finished using a file (i.e. read/write), it calls hdd close. For this assignment, calling hdd close will delete al the contents of the file in the block storage (HINT: future assignments will keep contents). Lastly, where the application starts reading from and writing to in a file is determined by the current seek position. The seek position is automatically placed at the end of the last read/write operation. The hdd seek function places the seek position wherever the user would like within the file (again, it is recommended to understand the standard seek C function) As a programmer, it is up to you to decide how to implement these functions. However, the functions must maintain the file contents in exactly the same way as a normal filesystem would (meaning do not re- order the bytes of data). The functions that you are to implement are declared in hdd file_io.h and should be implemented in hdd _file_io.c as follows: Function Description hdd open1]This call opens a file (i.e., sets any initially needed metadata in your data structure) and returns a UNIQUE integer file handle (to be assigned by you) [2] For this assignment, the file can be assumed to be non-existent on the device [3] You should initialize the device here (but only the first time this function is called i.e. singleton pattern) [4] The function returns -1 on failure and UNIQUE integer on success

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions