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

cmpsc 311 introduction to systems programming module
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CMPSC 311 - Introduction to Systems Programming

CMPSC 311- Introduction to Systems Programming Module: Assignment #4

Professor Patrick McDaniel Fall 2014

slide-2
SLIDE 2

CMPSC 311 - Introduction to Systems Programming Page

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!).

slide-3
SLIDE 3

CMPSC 311 - Introduction to Systems Programming Page

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.
slide-4
SLIDE 4

CMPSC 311 - Introduction to Systems Programming Page

File allocation table

  • A file allocation table is a data structure that holds all
  • f the information associated with files saved on your
  • device. For us, that this is the table that contains all of
  • ur 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

  • bject_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

  • pen;

// 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

slide-5
SLIDE 5

CMPSC 311 - Introduction to Systems Programming Page

File allocation table

  • A file allocation table is a data structure that holds all
  • f the information associated with files saved on your
  • device. For us, that this is the table that contains all of
  • ur 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

  • bject_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

  • pen;

// 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

OID POS LEN FN x 21 56 y 22 14 201 z 97 110 45 a 89 766 Opn 1 1 FH [0] [1] [2] [3]

slide-6
SLIDE 6

CMPSC 311 - Introduction to Systems Programming Page

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.
slide-7
SLIDE 7

CMPSC 311 - Introduction to Systems Programming Page

File allocation table (cont.)

  • The key to this assignment is

to use the file allocation table in the three functions

  • Format : CRUD_INIT, zero the

table, CREATE a priority block with the empty table contents

  • Mount : search for the priority

block, READ its contents into the file

  • Unmount: UPDATE the priority

block with the contents of the file allocation table, the CRUD_CLOSE

CRUD DEVICE Priority Object OID POS LEN FN x 21 56 y 22 14 201 z 97 110 45 a 89 766 Opn 1 1 Obj 4096 Obj 4458 Obj 4987 Obj 4987

FH [0] [1] [2] [3]

slide-8
SLIDE 8

CMPSC 311 - Introduction to Systems Programming Page

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
  • bjects 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.

slide-9
SLIDE 9

CMPSC 311 - Introduction to Systems Programming Page

Schedule/notes

  • I plan to have a out of class meeting late next weeks

(details to be announced later)

  • Due date: Nov 17th, 11:59:50pm