cmpsc 311 introduction to systems programming module
play

CMPSC 311- Introduction to Systems Programming Module: Assignment - PowerPoint PPT Presentation

CMPSC 311- Introduction to Systems Programming Module: Assignment #4 Professor Patrick McDaniel Fall 2014 CMPSC 311 - Introduction to Systems Programming Assignment #4 You will do two things: Create a file allocation table for your file


  1. CMPSC 311- Introduction to Systems Programming Module: Assignment #4 Professor Patrick McDaniel Fall 2014 CMPSC 311 - Introduction to Systems Programming

  2. Assignment #4 • You will do two things: ‣ Create a file allocation table for your file system (which supports multiple open files) ‣ Add new file systems functions to format , mount , and unmount (this will add persistence between runs) Note : You must modify the code that you submitted for assignment #3 (no exceptions!). CMPSC 311 - Introduction to Systems Programming Page

  3. File System Behavior • There are several operations that you will implement for your crud file system: ‣ Format – configures the device to empty state (no files) ‣ Mount – prepares the device for opening and closing files. Operating systems do this when booting. ‣ Unmount – releases the resources associated with the device, so that no further operations are available. • You will implement these for the crud file system. CMPSC 311 - Introduction to Systems Programming Page

  4. File allocation table • A file allocation table is a data structure that holds all of the information associated with files saved on your device. For us, that this is the table that contains all of our information about open and closed files: [in crud_file_io.h] // This is the basic file handle structure (note: index into file table is fh) typedef struct { char filename[CRUD_MAX_PATH_LENGTH]; // The filename of the data to be manipulated CrudOID object_id; // The handle of the object uint32_t position; // This is the position of the file uint32_t length; // This is the length of the file uint8_t open; // Flag indicating the file is currently open } CrudFileAllocationType; [in crud_file_io.c] CrudFileAllocationType crud_file_table[CRUD_MAX_TOTAL_FILES]; // The file handle table CMPSC 311 - Introduction to Systems Programming Page

  5. File allocation table • A file allocation table is a data structure that holds all of the information associated with files saved on your device. For us, that this is the table that contains all of our information about open and closed files: [in crud_file_io.h] // This is the basic file handle structure (note: index into file table is fh) typedef struct { char filename[CRUD_MAX_PATH_LENGTH]; // The filename of the data to be manipulated CrudOID object_id; // The handle of the object FH FN OID POS LEN Opn uint32_t position; // This is the position of the file uint32_t length; // This is the length of the file [0] x 21 0 56 0 uint8_t open; // Flag indicating the file is currently open } CrudFileAllocationType; [1] y 22 14 201 1 [in crud_file_io.c] CrudFileAllocationType crud_file_table[CRUD_MAX_TOTAL_FILES]; // The file handle table [2] z 97 110 45 1 [3] a 89 0 766 0 CMPSC 311 - Introduction to Systems Programming Page

  6. Priority object • A new feature of the crud device is the addition of a it priority object: ‣ which can be retrieved by calling a READ with a OID of 0 and setting the flags to CRUD_PRIORITY_OBJECT ‣ The key is that you don't need to know the OID to find it; the crud device remembers which object is the priority block and gives it back to you when the flag is set appropriately. • This is true of updates and deletes as well. • There is only one priority object in the crud device. CMPSC 311 - Introduction to Systems Programming Page

  7. File allocation table (cont.) • The key to this assignment is CRUD DEVICE to use the file allocation table Priority Object FH FN OID POS LEN Opn in the three functions [0] x 21 0 56 0 [1] y 22 14 201 1 [2] z 97 110 45 1 ‣ Format : CRUD_INIT, zero the [3] a 89 0 766 0 table, CREATE a priority block Obj 4096 Obj 4458 … with the empty table contents ‣ Mount : search for the priority Obj 4987 Obj 4987 block, READ its contents into the file ‣ Unmount: UPDATE the priority block with the contents of the file allocation table, the CRUD_CLOSE CMPSC 311 - Introduction to Systems Programming Page

  8. Crud Persistence • The crud library now handles persistence for you. ‣ When you call CRUD_CLOSE, a file is saved to the local directory containing all of the objects in the crud storage device. (i.e., in the “ crud_content.crd ”) ‣ When CRUD_INIT is called, the persistence file is read and objects are loaded into the virtual device. If there is no file, then the device remains empty. • NOTE: this is provided for you, you don’t have to do anything for it to work. CMPSC 311 - Introduction to Systems Programming Page

  9. Schedule/notes • I plan to have a out of class meeting late next weeks (details to be announced later) • Due date: Nov 17 th , 11:59:50pm CMPSC 311 - Introduction to Systems Programming Page

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend