Unformatted text preview:

COT 4600 Operating Systems Fall 2009Lecture 9Unix File SystemAPI for the Unix File SystemAPI for the Unix File System (cont’d)Layers7. Block layerDisk layout6. File layer5. Inode number layer4. File name layerFile name lookup3. Path name layerLinks2. Absolute path name layer 1. Symbolic link layerPractical design of naming schemesSingle context  ambiguity WORD_PROCESSOR  (INITIALIZE,SPELL_CHECK) SPELL_CHECH (INITIALIZE) (but a different version of iTwo distinct contexts  how does the interpreter choose the context? It needs a basis for the contexts.Add a context reference to each module telling the interpreter which context to use for that module? Not feasible to tinker wiHave separate contexts but establish a link between them; the link points to the new context for the shared objectAn elegant solutionMetadata and name overloadingNames and overloadingAddresses Changing addressesUnique namesHierarchical naming schemesApplication, Transport, Network, and Data Link Layer ProtocolsDynamic IP address assignment -DHCPCOT 4600 Operating Systems Fall 2009Dan C. MarinescuOffice: HEC 439 BOffice hours: Tu-Th 3:00-4:00 PM222Lecture 9 Last time:  Case study: the Unix file system Today: Modular sharing Metadata and Name Overloading Addresses Next Time: User-friendly names Lifetime of names Case study: URL3Unix File System Unix file system – hierarchical data organization: blocks Æ files Æ directories Æ file systems the objects:  files – linear arrays of blocks of data; each file has a cursorgiving the current position directories – collections of files; tree structure  metadata - useful information about the file, not contained in the file (e.g., owner, access modes, last modified date, length, etc.) supports: creation, deletion, renaming of files and directories  reading data from and writing data to a file reading and writing metadata describing a file4API for the Unix File SystemOPEN(name, flags, model) Æ connect to a fileOpen an existing file called name, or Create a new file with permissions set to modeif flags is set. Set the file pointer (cursor) to 0. Return the file descriptor (fd).CLOSE(fd) Æ disconnect from a fileDelete file descriptor fd.READ(fd, buf,n) Æ read from fileRead n bytes from file fd into buf; start at the current cursor position and update the file cursor (cursor = cursor + n).WRITE(fd, buf,n) Æ write to fileWrite n bytes to the file fd from buf; start at the current cursor position and update the file cursor (cursor = cursor + n). SEEK(fd, offset,whence) Æ move cursor of fileSet the cursor position of file fd to offset from the position specified by whence(beginning, end, current position)5API for the Unix File System (cont’d)FSYNC(fd) Æ make all changes to file fd durable.STAT(name) Æread metadata CHMOD, CHOWN Æ change access mode/ownershipRENAME(from_name,to_name) Æ change file nameLINK(name, link_name) Æcreate a hard linkUNLINK(name) Æremove namefrom directorySYMLINK(name, link_name) Æcreate a symbolic linkMKDIR(name) Æcreate directory nameRMDIR(name) Ædelete directory nameCHDIR(name) Æ change current directory to nameCHROOT Æ Change the default root directory nameMOUNT(name,device) Æ mount the file system nameonto deviceUNMOUNT(name) Æ unmount file system name6Layers Unix file system uses a number of layers to hide the implementation of the storage abstraction from the users. User-oriented names 1. Symbolic link layer Æintegrates multiple file systems with symbolic names 2. Absolute path name layer Æprovides a root for the naming hierarchies 3. Path name layer Æ organizes files into naming hierarchies Machine-user interface 4. File name layer Æ Supplies human-oriented names for files Machine-oriented names 5. Inode number layer Æ provides machine-oriented names for files 6. File layer Æ organizes blocks into files 7. Block layer Æ Provides the physical address of data blocks77. Block layer The storage device (disk) Æ a linear array of cells/blocks Block Æ fixed-size allocation unit (e.g., 512 bytes, 2,048 bytes); occupies several disk sectors. Block name Æ integer from a compact set, the offset from the beginning of the device Boot block Æ usually contains a boot program; Has a well-known name, 0. Super block Æ provides a description of the layout of the file system on the disk. Has a well-known name,1. Bitmap to keep track of free blocks and of defective blocks.8Figure 2.20Disk layout9Figure 2.22106. File layer A file consists of multiple blocks.  inode (index node)Æ container for the metadata about the file; context for naming the blocks of the filestructure inodeinteger block_number[N] // the number of the block in the fileinteger size // file size in bytesName mapping algorithm:procedure INDEX_TO_BLOCK_NUMBER (inode instance i, integer index) returns integerreturn i_block_numbers[index] Indirect blocks Æ blocks that contain block numbers rather than data Æ to accommodate large file.  Doubly indirect blocks Æ blocks that contain block numbers of indirect blocks Example: UNIX V6 the first N entries in i_block_numbers are indirect blocks and the N+1 is a doubly indirect block the block size is 512 bytes;  an index consists of 2 bytes Æ an indirect block may contain 256 block numbers the maximum file size is: (N-1) x 256 + 256 x 256 blocks115. Inode number layer inodes are named and passed around by name (inode number) inode numbers are a compact set inode_table Æ maps inode names to the starting block of the inode stored at a known-location (e.g., at the beginning of the storage device) Inode manipulation functions: allocate, dealocate, add to list of free inodes, remove from list of free inodes Name mapping algorithm Æ procedure that returns the block that contains the byte at offset in a file identified by inode_number:procedure INODE_NUMBER_TO_BLOCK(integer offset, integer inode _number) returns block inode instance i ÅINODE_NUMBER_TO_INODE [inode,number]offset_in_block Åoffset/blocksizeb_number ÅINDEX_TO_BLOCK_NUMBER(i, offset_in_block)return BLOCK_NUMBER_TO_BLOCK [b_number ]124. File name layer Maps human-oriented names to machine-oriented names. Hides the metadata required by file management from the user. Directory Æ durable object providing the context for binding between a file name and an inode number


View Full Document

UCF COT 4600 - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?