Develop code for the file-oriented input or output driver

Assignment Help C/C++ Programming
Reference no: EM131418771

Assignment- CRUD Device Driver (Ver 1.0)- Introduction to Systems Programming

All remaining assignments for this class are based on the creation and extension of a user-space device driver for a filesystem built on top of a object storage device. At the highest level, you will translate file system commands into storage array commands. These file system commands include open, read, write, and close for files that are written to your file system driver. These operations perform the same as the normal UNIX I/O operations, with the caveat that they direct file contents to the object storage device instead of the host filesystem. The arrangement of software is as follows:

2400_Arrangement of Software.jpg

Object Store/CRUD Interface

An object store is a virtual device that stores variable sized blocks of data called objects. Software that uses the store create and manipulate objects on the device in a way very similar to normal disk drives (see the CRUD interface commands below), except that they manipulate objects instead of disk blocks. Each object is referenced by a uniquely identified by an integer value assigned by the object store called an object identifier.

The object store you are building on top of exports a CRUD interface; it supports creating objects, reading objects, updating objects, and deleting objects. Note that this code for this interface is provided to you in library form. Also, objects have immutable size; once allocated, the contents can be changed repeatedly, but the size can never change. Thus, any operation which would require a change to the object size must be performed by deleting an old and creating a new one.

You are to use the CRUD interface to make requests to the object store, as defined in the file crud driver.h,. This interface contains a single function call that accepts two arguments, a 64-bit CRUD bus request value (with type CrudReuqest) and a pointer to a variable-sized buffer;
CrudResponse crud bus request(CrudRequest request, void *buf);

The CRUD commands are as follows:

• CRUD INIT - This command initializes the object store and readies it for use in file operations. This request MUST be called before any others.

• CRUD CREATE - This command creates an object whose length is defined in a buffer request value defined below. The buffer passed to the function should contain data of that length. Note that the CRUD interface copies the passed data into an internal structure, so you are responsible for managing any buffers passed to it. If successful, the operation will return the new object ID in the response object value.

• CRUD READ - This command reads an object (in its entirety) from the object store and copies its contents in passed buffer. The length field should be set to the length of the passed buffer (because you don't know how big the object is going to be, you should always pass in a buffer of size CRUD MAX OBJECT SIZE). The returned response value indicates the length of the objectread.

• CRUD UPDATE - This command will update the contents of an object. Note that the object size CAN NEVER change. Thus, the call will fail unless the buffer sent is the same size as the original object created.

• CRUD DELETE - This command deletes the object, making it unavailable for later access. Note that the object ID of a object may be reused later.

The CrudRequest value passed to the bus function is a 64-bit value that defines a request and its parameters, as follows (by convention bit zero is the most significant bit):

2176_Bus Function.jpg

Note that the 64-bit response value (CrudResponse) returned from a call to the CRUD interface has the same fields, with slightly different meaning as described below. The fields of the value are:

• OID - This is the object identifier of the object you are executing a command on. For object creates, the returned object identifier is the new object ID.

• Req - This is the request type of the command you are trying to execute. The value can be CRUD INIT, CRUD CREATE, CRUD READ, CRUD UPDATE, or CRUD DELETE.

• Length - This is the length of the object. On updates and creates, the request value should include the size of the object you are attempting to create or update. On reads, the length should be the size of the buffer you are handing to the device (the maximum size of the object you can read). For all calls, the returned size is the size of the object read, written, or updated.

• Flags - These are unused for this assignment.

• R - Result code. Only used in the response, this is success status of the command execution, where 0 (zero) signifies success, and 1 signifies failure. You must check the success value for each bus operation.

The Filesystem Driver

The bulk of this assignment is to develop code for the file-oriented input/output driver that uses the object store. Conceptually, you are to translate each of the below file I/O function calls into calls to the previously described CRUD interface. 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. The functions that you are to implement are defined in crud file io.h and crud file io.c and should perform as follows:

Function               Description

crud open: This call opens a file and returns an integer file handle (to be assigned by you). For this assignment, the file is always assumed to be empty (zero length) when opened.

crud close: This call closes the file referenced by the file handle. For this assignment, you are to delete all of the contents associated with the file when it is closed.

crud read: This call reads a count number of bytes from the current position in the file and places them into the buffer buf. The function returns -1 if failure, or the number of bytes read if successful. If there are not enough bytes fulfill the read request, it should only read as many as are available and return the number of bytesread.

crud write: This call writes a count number of bytes at the current position in the file associated with the file handle fd from the buffer buf. The function returns -1 if failure, or the number of written read if successful. When number of bytes to written extends beyond the end of the file, the size of the file is increased.

crud seek: This call resets the current position of the file associated with the file handle fd to the position loc.

The central constraint to be enforced on your code is that it can only maintain meta-information about an open file. Put more directly, your code can not maintain any file content or length information in local structures-all such data must be maintained by the object store. Also note that for the purposes of this assignment, you can make the following assumptions:

• No file will become larger than the maximim object size (CRUD MAX OBJECT SIZE).
• Your program will never have more than one file open at a time.

Instructions

You are to build the initial version of the user-space device driver. To do this, you should perform the following steps in completing the assignment:

1. From your virtual machine, download the starter source code provided for this assignment. To do this, download the file from canvse to a jump drive. Then from your VM select VM/Removeable device/your jump drive. Copy the file to your home directory

https://www.cse.psu.edu/˜mcdaniel/cmpsc311-f14/docs/assign3-starter.tgz

2. Change to your assignments a directory for your assignments and copy the file into it.

% cd /cmpsc311
% cp assign3-starter.tgz cmpsc311
% cd cmpsc311
% tar xvfz assign3-starter.tgz

3. Complete the code for the file I/O functions defined in crud file io.c as described above. You should be able to use the Makefile provided to build the program without modification.

4. Add comments to all of your files stating what the code is doing. Augment the comment function header for each function you are defining in the code.

5. The testing of the program is performed by using the unit test function for the crud file io interface. The main function provided to you simply calls the function crudIOUnitTest. If you have implemented your interface correctly, it should run to completion successfully. To test the program, you execute the simulated filesystem using the -u and -v options, as:

./crud sim -u -v

If the program completes successfully, the following should be displayed as the last log entry:

CRUD unit tests completed successfully.

To turn in:

1. Create a tarball file containing the assign3 directory, source code and build files. Email the program to [email protected] and the section TA by the assignment deadline (11:59pm of the day of the assignment). The tarball should be named LASTNAME-PSUEMAILID-assign3.tgz, where LAST- NAME is your last name in all capital letters and PSUEMAILID is your PSU email address with- out the "@psu.edu". For example, the professor was submitting a homework, he would call the file REGGIO-ajr117- assign3.tgz. Any file that is incorrectly named, has the incorrect directory struc- ture, or has misnamed files, will be assessed a one day late penalty.

2. Before sending the tarball, test it using the following commands (in a temporary directory - NOT the directory you used to develop the code):

% tar xvzf LASTNAME-PSUEMAILID-assign3.tgz
% cd assign3
% make
... (TEST THE PROGRAM)

Note: Like all assignments in this class you are prohibited from copying any content from the Internet or discussing, sharing ideas, code, configuration, text or anything else or getting help from anyone in or outside of the class. Consulting online sources is acceptable, but under no circumstances should anything be copied. Failure to abide by this requirement will result dismissal from the class as described in our course syllabus.

Attachment:- Assignment-Starter.tgz

Reference no: EM131418771

Questions Cloud

Describe concurrent engineering : Define TQM. What is meant by SPC? Describe quality engineering. How does it relate to system engineering?
Describe what aspect of contract law : Joan had a heart attack while walking to work and she fell down on the sidewalk in an unconscious state. Several people came rushing to her aid and someone called 911. While no actual contract was formed between Joan and the hospital, describe what a..
What hypothesis test would be used to analyze given data : How many variables are there in this study? What are the levels of any variables you identified?- What hypothesis test would be used to analyze these data? Justify your answer.
History of us labor legislation : Employers have a long history of using their power to abuse employees. Past employer practices have led to bloody conflicts. Over time, the development of Federal regulations has helped ease the tense employee/employer relationship.
Develop code for the file-oriented input or output driver : CMPSC311- The bulk of this assignment is to develop code for the file-oriented input/output driver that uses the object store. Conceptually, you are to translate each of the below file I/O function calls into calls to the previously described CRUD..
How much external financing does ottawa need : Enter a formula for external funding required in the first green box. How much external financing does Ottawa need in 2014. At what rate does the actual sales growth rate equal the sustainable growth rate? How much external financing is required at ..
What is meant by total productive maintenance : What is meant by disposability engineering and environmental engineering? How do they relate to each other? How do they differ?
Responsibilities of human resource management profession : During the past 50+ years, the responsibilities of the human resource management profession have changed.  Based on the provided resources (and others you might wish to use), share your thoughts about:
Aligned business framework : Review and read Case 2-3: Ford Motor Company: Aligned Business Framework. Based on your review and reading of Chapter 2: Supply Strategies will the proposed "Aligned Business Framework (ABF)" help to mitigate the reputational risk presently being exp..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Lab11

ltbrgt

  Write a research paper on flow of control

Write a two page research paper (excluding title and reference pages) on Flow of Control.

  Write a program the recursive algorithm for towers of hanoi

Write a program the recursive algorithm for towers of Hanoi. Write a program the iterative algorithm of Towers of Hanoi.

  Maximal depth of decision tree derived

(1) How many scans of the database does your algorithm take if the maximal depth of decision tree derived is 5? (2) What is the maximum memory space your algorithm will use in your tree induction?

  Why is exception handling important to software development

Please respond to all of the following prompts: Why is exception handling important to software development? Can there be such a thing as too much exception handling? How does exception handling affect performance of code execution?

  Show the items by zone or location within the store

There is other information. Some people shop on a budget so they need the price and the sale price. Use an array or vector to hold the list of items. The display should show the items by zone or location within the store. (Display the output by loc..

  Prepare a program to print the permutation

write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself.

  Use a loop in main to efficiently handle all three persons

Plan and finish writing the main program, and all the functions, including a constructor. Use a loop in main to efficiently handle all three persons' data.

  Write a modular program in three files

Acts as a cafeteria kiosk, continually prompting the user for a number (1-10) indicating the quality of food at the cafeteria. Input of -1 will stop the polling function, and initiate the reporting functionality which displays a histogram to the u..

  Write a program to find the middle element in a linked list

1. Write a program to check if there is a loop in a linked list. Create a loop in a linked list and use your method 'isLoop' to identify that the loop exists. The method isLoop should return a Boolean type.2.

  Class to act as a generic array

Create a class to act as a generic array (i.e. the user will be able to choose the data type to be stored by passing the appropriate template argument.

  People from their own community

In social networks ,each person prefers to meet with people from their own community and are reluctant to switch affiliations. If they switch, they pay a penalty for switching csw and if they visit a meeting of a community different from their own..

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