cmpsc 311- introduction to systems programming module...
TRANSCRIPT
CMPSC 311 - Introduction to Systems Programming
CMPSC 311- Introduction to Systems Programming
Module: Assignment #3���CRUD Device Driver
Professor Patrick McDaniel Fall 2014
CMPSC 311 - Introduction to Systems Programming Page
Midterm
• Average 64.5 (68 not counting no-shows), median 67 • High 100, low 17
0
5
10
15
20
25
30
35
40
<50 50-59 60-69 70-79 80-89 90-100
CMPSC 311 - Introduction to Systems Programming Page
Homework #3 • Idea you are to maintain the correct file contents in an
object stored on the CRUD device. • 3 things to know ‣ How file I/O works
‣ How the object works
‣ How to make the object stuff look like files
CMPSC 311 - Introduction to Systems Programming Page
The CRUD Device Driver Simulated Application
(PROVIDED)
Filesystem Driver(YOUR CODE)
CRUD Interface (PROVIDED)
(filesystem commands, e.g., open, read ..)
Object Store(PROVIDED)
(CRUD commands, e.g., CRUD_CREATE, CRUD_READ ..)
CMPSC 311 - Introduction to Systems Programming Page
Assignment Basics • You are to write the file operation functions defined in
the crud_file_io.c ‣ Translate then file operations into CRUD bus operations
‣ Maintain, in the storage device, the file contents • You must insert data, read data, and maintain a file pointer
‣ For this assignment • No file will become larger that the maximum object size (CRUD
MAX OBJECT SIZE).
• Your program will never have more than one file open at a time.
• A test function is provided for you that will exercise all
of the functionality of your code.
CMPSC 311 - Introduction to Systems Programming Page
CRUD file IO commands • You are to implement the following functions:
• Key to assignment: how do you convert each of these functions into the corresponding object calls and buffer manipulation?
CMPSC 311 - Introduction to Systems Programming Page
Maintaining file contents • Open prepares an empty file for
reading (zero length) • Write writes bytes into the file
• Seek seeks to a particular position in the file (end if pos > length)
• Read copies up to length number of bytes from the file
• Close deletes the contents
len=0, pos=0
open(“file.txt”)
X X X X X
len=5, pos=5
write(“XXXXX”, 5)
X X X X X
len=5, pos=2
seek(2)
X X X X X
len=5, pos=5
read(4)
CMPSC 311 - Introduction to Systems Programming Page
The CRUD Interface CrudResponse crud bus request(CrudRequest request, void *buf); !
CMPSC 311 - Introduction to Systems Programming Page
The CRUD Interface CrudResponse crud bus request(CrudRequest request, void *buf); !
OID (32) Req (4) RFl. (3)Length (24)
64 bits
Most significant
bitLeast
significant bit
CMPSC 311 - Introduction to Systems Programming Page
Testing your program • 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 simple calls the function crudIOUnitTest. To test the program, you execute the simulator using the -u and -v options, as:
• If you have implemented everything correctly, the log should display the following message as its last entry:
./crud_sim –u -v!
CRUD unit tests completed successfully. !
CMPSC 311 - Introduction to Systems Programming Page
Getting started … • Get the file from the web:
• Change into your development directory and unpack the file:
• Note: you may have to install libgcrypt-dev via apt-get.
wget http://www.cse.psu.edu/~mcdaniel/cmpsc311-f14/docs/assign3-starter.tgz!
% cd ~/cmpsc311!% cp assign3-starter.tgz cmpsc311!% cd cmpsc311!% tar xvfz assign3-starter.tgz!% cd assign3!% make!
CMPSC 311 - Introduction to Systems Programming Page
Hints • Use the logMessage interface to log information about
how your program is running. • Carefully read and understand the error messages that
are being written to the log. • Review the unit test function to see how the interfaces
in the program should operate.
CMPSC 311 - Introduction to Systems Programming Page
First functions … • The first functions you should write should create a
request structure and extract a request structure:
CrudRequest create_crudrequest(…?) {!!???!
}!!??? extract_crud_response(CrudResponse resp, …) {!!???!
}!
Hint: use the bit operations to build up structure ….