Chapter 10: File Systems and Storage PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document discusses file systems and storage, covering file concepts, attributes, operations, types, access methods, and allocation methods. It explains various directory structures and disk organization. The document is suitable for undergraduate-level computer science courses.
Full Transcript
# Chapter 10: File Systems and Storage ## File Concept - Contiguous logical address space - Types: - Data - numeric - character - binary - Program ## File Attributes - Name - only information kept in human-readable form - Identifier - unique tag (number) identifies...
# Chapter 10: File Systems and Storage ## File Concept - Contiguous logical address space - Types: - Data - numeric - character - binary - Program ## File Attributes - Name - only information kept in human-readable form - Identifier - unique tag (number) identifies file within file system - Type - needed for systems that support different types - Location - pointer to file location on device - Size - current file size - Protection - controls who can do reading, writing, executing - Time, date, and user identification - data for protection, security, and usage monitoring - Information about files are kept in the directory structure, which is maintained on the disk ## File Operations - File is an abstract data type - Create - Write - Read - Reposition within file - Delete ## File Types - Name, Extension | File Type | Usual Extension | Function | |---|---|---| | Executable | exe, com, bin or none | Ready-to-run machine-language program | | Object | obj, o | Compiled, machine language, not linked | | Source Code | c, cc, java, pas, asm, a | Source code in various languages | | Batch | bat, sh | Commands to the command interpreter | | Text | txt, doc | Textual data, documents | | Word Processor | wp, tex, rtf, doc | Various word processor formats | | Library | lib, a, so, dil | Libraries of routines for programmers | | Print or View | ps, pdf, jpg | ASCII or binary file in a format for printing or viewing | | Archive | arc, zip, tar | Related files grouped into one file, sometimes compressed, for archiving or storage | | Multimedia | mpeg, mov, rm, mp3, avi | Binary file containing audio or A/V information | ## Access Methods - Sequential Access - read next - write next - reset - Direct Access - read _n_ - write _n_ _n_ = relative block number ## Sequential-access File A horizontal bar with current position, beginning, and end labels. An arrow pointing left labeled "rewind" with another arrow labeled "read or write" going right. ## Example of Index and Relative Files - A table with a column labeled "last name" and another labeled "logical record number." - Names in the table: Adams, Arthur, Asher, Smith - A blue rectangle labeled "Smith, John social-security age" with an arrow pointing to the right. The table is labeled "index file" and the rectangle is labeled "relative file." ## Directory Structure - A collection of nodes containing information about all files - A cloud shape labeled "Directory" with four circles inside and lines drawn down from the cloud to four squares labeled "Files" : F1, F2, F3, Fn _Both the directory structure and the files reside on disk_ ## Disk Structure - Disk can be subdivided into partitions - Disks or partitions can be RAID protected against failure. - Disk or partition can be used raw - without a file system, or formatted with a file system. - Partitions also known as minidisks, slices - Entity containing file system known as a volume - Each volume containing file system also tracks that file system's info in device directory or volume table of contents. - As well as general-purpose file systems there are many special-purpose file systems, frequently all within the same operating system or computer. ## A Typical File-system Organization - A vertical rectangle divided into three sections. The top and bottom sections have "directory" and "files" labels with "partition A" and "partition B" labels outside the rectangle. - A blue rectangle to the right of the first rectangle divided into two sections with "partition C" and "files" labels. An arrow connecting the rectangles labeled "disk 1." - A second blue rectangle is to the right of the first, labeled "disk 2." - A third blue rectangle is to the right of the second, labeled "disk 3." ## Operations Performed on Directory - Search for a file - Create a file - Delete a file - List a directory - Rename a file - Traverse the file system ## Single-Level Directory - A single directory for all users - A rectangle labeled "directory" with lines drawn down to circles labeled: cat, bo, a, test, data, mail, cont, hex, records - The circles are labeled "files." - The text: "Naming problem" and "Grouping problem" are below the circles. ## Two-Level Directory - Separate directory for each user - A rectangle labeled "master file directory" with lines drawn down to 4 rectangles labeled: "user 1," "user 2," "user 3," "user 4." - Lines drawn down from these rectangles to circles labeled: cat, bo, a, test, a, data, a, test, X, data, a - The circles are labeled "files" - Text is below the circles: "Path name," "Can have the same file name for different user," "Efficient searching," "No grouping capability" ## Tree-Structured Directories - A tree structure with "root" at the top. - Branches and leaves labeled: spell, bin, programs, stat, mail, dist, find, count, hex, reorder, P, e, mail, prog, copy, prt, exp, reorder, list, find hex, count. - Circles at the end of all the branches. - Leaves at the bottom: list, obj, spell, all, last, first. ## Tree–Structured Directories (Cont) - Efficient searching - Grouping Capability - Current directory (working directory) - _cd /spell/mail/prog_ - _type list_ ## Tree–Structured Directories (Cont) - Absolute or relative path name - Creating a new file is done in current directory - Delete a file - _rm <file-name>_ - Creating a new subdirectory is done in current directory - _mkdir <dir-name>_ - Example: if in current directory _/mail_ - _mkdir count_ - A tree structure with labels: mail, prog, copy, prt, exp, count. - "Deleting "mail" ≈ deleting the entire subtree rooted by "mail." ## Access Lists and Groups - Mode of access : read, write, execute - Three classes of users: - a) owner access 7 → RWX 111 - b) group access 6 → RWX 110 - c) public access 1 → RWX 001 - Ask manager to create a group (unique name), say G, and add some users to the group. - For a particular file (say game) or subdirectory, define an appropriate access. - A table with labels: owner, group, public. Beneath the table is: "chmod 761 game" then "Attach a group to a file" then "chgrp G game" ## Windows XP Access-control List Management - A screen shot of the Windows XP Access-control List Management. ## A Sample UNIX Directory Listing | | | | | | | |---|---|---|---|---|---| | -rw-rw-r-- | 1 pbg staff | 31200 | Sep 3 08:30 | intro.ps | | | drwx------ | 5 pbg staff | 512 | Jul 8 09:33 | private/ | | | drwxrwxr-x | 2 pbg staff | 512 | Jul 8 09:35 | doc/ | | | drwxrwx--- | 2 pbg student | 512 | Aug 3 14:13 | student-proj/ | | | -rw-r--r-- | 1 pbg staff | 9423 | Feb 24 2003 | program.c | | | -rwxr-xr-x | 1 pbg staff | 20471 | Feb 24 2003 | program | | | drwx--x--x | 4 pbg faculty | 512 | Jul 31 10:31 | lib/ | | | drwx------ | 3 pbg staff | 1024 | Aug 29 06:52 | mail/ | | | drwxrwxrwx | 3 pbg staff | 512 | Jul 8 09:35 | test/ | | ## File-System Implementation - Boot control block contains info needed by system to boot OS from that volume - Volume control block contains volume details - Directory structure organizes the files - Per-file File Control Block (FCB) contains many details about the file ## A Typical File Control Block - A table with the labels: file permissions, file dates (create, access, write), file owner, group, ACL, file size, file data blocks or pointers to file data blocks. ## Allocation Methods - An allocation method refers to how disk blocks are allocated for files - Contiguous allocation - Linked allocation - Indexed allocation ## Contiguous Allocation - Each file occupies a set of contiguous blocks on the disk. - Simple - only starting location (block #) and length (number of blocks) are required. - Random access - Wasteful of space (dynamic storage-allocation problem) - Files cannot grow ## Contiguous Allocation of Disk Space - A cylinder with blocks numbered 0 to 31, with a side table labeled directory: - file: count, start: 0, length: 2 - file: f, start: 14, length: 3 - file: tr, start: 19, length: 6 - file: list, start: 28, length: 4 - file: f, start: 6, length: 2 - The blocks 0-3 are labeled together "count," blocks 14-16 are labeled together "f," blocks 19-24 are labeled together "tr," blocks 28-31 are labeled together "list." ## Linked Allocation - Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. - A rectangle with "block' and "pointer" labels. The rectangle is divided into an upper section and a lower section. ## Linked Allocation - A cylinder with blocks numbered 0 to 31 labeled with numbers. An arrow from block 26 to block 25. An arrow from block 24 to block 27 and another arrow from block 12 to block 15. - A side table labeled "directory:" - file: jeep, start: 9, end: 25 ## File-Allocation Table - A rectangle labeled "directory entry" with "test" outside the rectangle and "name" and "start block" labels inside. The start block is labeled "217." - A cylinder with numbered blocks. From block 217 is an arrow pointed to a block labeled "618." Another arrow is labeled "339" going to the left and to the right. Finally there is an arrow from block 618 to the right labeled "339." - A rectangle labeled "FAT" with its upper section labeled "no. of disk blocks" and its lower section labeled "-1." ## Indexed Allocation - Brings all pointers together into the index block - Logical view - A set of rectangles with an arrow pointing right from each to a circle. Those rectangles below are labeled "index table." ## Example of Indexed Allocation - A cylinder with blocks numbered 0-31. An arrow from the blocks 9, 1, 10, and 25 outside of the cylinder pointing to a labeled "index block" labeled "19." - A rectangle labeled "directory" with the following table: - file: jeep - index block: 19 - A circle with these numbers inside: 9, 1, 10, 25, -1, -1. ## End of Chapter 10