File Systems File Systems File Blocks Organization Hybrid Multi-Level

File Systems File Systems File Blocks Organization Hybrid Multi-Level

File Systems n Implementing file system abstraction on top of raw disks n Issues: File Systems n How to find the blocks of data corresponding to a given file? n How to organize files? n How to enforce protection? Arvind Krishnamurthy n Performance issues: need to minimize the number of “non- Spring 2004 local” disk accesses n Try to keep related information together on the disk File Blocks Organization Hybrid Multi-level Indexing Scheme n Approaches: n Used in Unix 4.1 n Contiguous allocation n 13 Pointers in a header data n A file is stored on a contiguous set of blocks n 10 direct pointers n Prevents incremental growth and complicates allocation n 11: 1-level indirect n Linked list allocation data n 12: 2-level indirect 1 n A file header points to the first block of the file 2 . n 13: 3-level indirect . n Each block of the file points to the next block 11 . n 12 . data n If blocks are dispersed across disk è horrible performance for Pros & Cons 13 . both sequential access and random access n In favor of small files n Random access can be made faster by separating the next block n Can grow . data pointers from the data and storing it at a centralized place (FAT) n Limit is 16G (assuming 1K n Indexed files blocks) . n File header stores pointers to file blocks . data n Multi-level indexing required for large files Unix file header (I-node) Disk Layout Boot Super File descriptors File data blocks block block (i-node in Unix) n File headers (I-nodes) are identified by a number (I-number) n Can translate the I-number to a location on the disk n Headers are either located together as one group or spread across the disk in predetermined fashion n Superblock defines a file system n size of the file system n size of the file descriptor area n free list pointer, or pointer to bitmap n location of the file descriptor of the root directory n other meta-data such as permission and various times 1 Naming and directories Directory structure n Options n Approach 1: have a single directory for entire system. n Use index (ask users specify inode number). Easier for system, not n put directory at known location on disk as easy for users. n directory contains <name, index> pairs n Text name (need to map to index) n if one user uses a name, no one else can n Icon (need to map to index; or map to name then to index) n many older personal computers work this way. n Directories n Directory map name to file index (where to find file header) n Approach 2: have a single directory for each user n Directory is just a table of file name, file index pairs. n still clumsy. And ls on 10,000 files is a real pain n Each directory is stored as a file, containing a (name, index) pair. n Approach 3: hierarchical name spaces n Only OS permitted to modify directory n allow directory to map names to files or other dirs n file system forms a tree (or graph, if links allowed) n large name spaces tend to be hierarchical (ip addresses, domain names, scoping in programming languages, etc.) Hierarchical Unix / Naming afs bin cdrom dev sbin tmp n Used since CTSS (1960s) n Bootstrapping: Where do you start looking? n Unix picked up and used really nicely. awk chmod chown n Root directory n Directories stored on disk just like regular files n inode #2 on the system n n inode contains special flag bit set 0 and 1 used for other purposes n users can read just like any other file n Special names: <name, inode#> n only special programs can write n Root directory: “/” (bootstrap name system for users) <afs, 1021> n Current directory: “.” <tmp, 1020> n n file pointed to by the index may be Parent directory: “..” another directory <bin, 1022> <cdrom, 4123> n makes FS into hierarchical tree (what is needed to make a DAG?) <dev, 1001> <sbin, 1011> n Simple. Plus speeding up file ops = speeding up dir ops! Unix example: /a/b/c.c Announcements n Paper reviews due on Wednesday for: “.” Name space Physical organization n Fast File Systems a disk n Log structured file systems “..” 2 n Next assignment will be online by tomorrow b 3 Inode table “.” 4 5 ... <a,3> What inode holds file for c.c a? b? c.c? <c.c, 14> How many disk I/O’s to <b,5> access first byte of c.c? 2 Outline Creating synonyms: hard and soft links n Topics covered so far in file systems: n More than one dir entry can refer to a given file n Data blocks n Unix stores count of pointers (“hard links”) to inode n File headers n Directories foo bar n to make: “ln foo bar” creates a n File system superblocks synonym (‘bar’) for ‘foo’ ref = 2 n Soft links: ... n Remaining topics: n also point to a file (or dir), but object can be deleted from underneath n Hard and soft links it (or never even exist). n Permissions n normal file holds pointer to name, with special “sym link” bit set “baz” /bar n When the file system encounters a symbolic link it automatically translates it (if possible). Protection Access control n Goals: n Domain structure n Prevent accidental and maliciously destructive behavior n Access/usage rights associated with particular domain n Ensure fair resource usage n Example: user/kernel mode è two domains n Unix: each user is a domain; super-user domain; groups of users (and groups) n A key distinction to make: policy vs. mechanism n Type of access rights n Policy: what is to be done n For files: read/write/execute n Mechanism: how something is to be done n For directories: list/modify/delete n For access rights themselves n Owner (I have the right to change the access rights for some resource) n Copy (I have the right to give someone else a copy of an access right I have) n Control (I have the right to revoke someone else’s access rights) Access control matrix Access control lists vs. capability lists n Conceptually, we can think of the system enforcing access n Access control lists (ACL): keep lists of access for each controls based on a giant table that encodes all access domain with each object: rights held by each domain in the system File3: User A: rwx Group B: rw Example: ………… File1 File2 File3 Dir1 Dir2 … UserA rw r rwx lmd l … n Capability lists (CAP): keep lists of access rights for each GroupB r rw lm … object with each domain … … … … … … … User A: File1: rw File2: r ………… The access control matrix is the “policy” we want to enforce; Mechanisms: (1) access control lists n Which is better? (2) capability lists n ACLs allow easy changing of an object’s permissions n Capability lists allow easy changing of a domain’s permissions 3 A combined approach Data structures for a typical file system n Objects have ACLs Process Open file n Users have CAPs, called “groups” or “roles” control table File headers block (systemwide) (Metadata) File system info n ACLs can refer to users or groups File headers n Change permissions on an object by modifying its ACL Open Directories file . pointer . n Change broad user permissions via changes in group . array membership File data Appendix: Open a file Read a block n File name lookup and authenticate read( fd, userBuf, size ) n Copy the file descriptors into fd = open( FileName, access) PCB the in-memory data structure, Find open file if it is not in yet descriptor n Create an entry in the open Open PCB Allocate & link up read( fileDesc, userBuf, size ) file table (system wide) if data structures file there isn’t one table Logical ® phyiscal n Create an entry in PCB Open File name lookup n Link up the data structures file Metadata & authenticate read( device, phyBlock, size ) n Return a pointer to user table Get physical block to sysBuf Buffer copy to userBuf cache Metadata File system on disk Disk device driver Example: the open-read-close cycle Example: open-read-close (cont’d) 1. The process calls open (“DATA.test”, RD_ONLY) 1. The process calls open (“DATA.test”, RD_ONLY) 2. The kernel: 2. The kernel: n Get the current working directory of the process: n Get the current working directory of the process: Let’s say “/c/cs422/as/as3 n Call “namei” and get the inode for DATA.test; n Find an empty slot “fd” in the file descriptor table for the process; n Call “namei”: Get the inode for the root directory “/” n Put the pointer to the inode in the slot “fd”; n Set the initial file pointer value in the slot “fd” to 0; For (each component in the path) { n Return “fd”. can we open and read the directory file ? 3. The process calls read(fd, buffer, length); if no, open request failed, return error; if yes, read the blocks in the directory file; 4. The kernel: Based on the information from the I-node, read through the n From “fd” find the file pointer directory file n Based on the file system block size (let’s say 1 KB), find the blocks to find the inode for the next component; where the bytes (file_pointer, file_pointer+length) lies; } n Read the inode At the end of the loop, we have the inode for the file DATA.test 4 Example: open-read-close (cont’d) Example: the create-write-close cycle 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us