Unformatted text preview:

6 3ULQFLSOHV RI 2SHUDWLQJ 6 VWHPV DOO Lecture 12 File Systems Geoffrey M Voelker LOH 6 VWHPV Last time we talked about the physical characteristics of disks and their performance Today we ll talk about file systems Files Directories Sharing Protection File System Layouts File Buffer Cache Read Ahead November 12 2001 CSE 120 Lecture 12 File Systems 2 1 LOH 6 VWHPV File systems Implement an abstraction files for secondary storage Organize files logically directories Permit sharing of data between processes people and machines Protect data from unwanted access security November 12 2001 CSE 120 Lecture 12 File Systems 3 LOHV A file is data with some properties Contents size owner last read write time protection etc A file can also have a type Understood by the file system Block character device portal link etc Understood by other parts of the OS or runtime libraries Executable dll souce object text etc A file s type can be encoded in its name or contents Windows encodes type in name com exe bat dll jpg etc Unix encodes type in contents Magic numbers initial characters e g for shell scripts November 12 2001 CSE 120 Lecture 12 File Systems 4 2 DVLF LOH 2SHUDWLRQV Unix creat name open name how read fd buf len write fd buf len sync fd seek fd pos close fd unlink name NT November 12 2001 CreateFile name CREATE CreateFile name OPEN ReadFile handle WriteFile handle FlushFileBuffers handle SetFilePointer handle CloseHandle handle DeleteFile name CopyFile name MoveFile name CSE 120 Lecture 12 File Systems 5 LOH FFHVV 0HWKRGV Some file systems provide different access methods that specify different ways for accessing data in a file Sequential access read bytes one at a time in order Direct access random access given block byte number Record access file is array of fixed or variable length records read written sequentially or randomly by record Indexed access file system contains an index to a particular field of each record in a file reads specify a value for that field and the system finds the record via the index DBs What file access method does Unix NT provide Older systems provide more complicated methods November 12 2001 CSE 120 Lecture 12 File Systems 6 3 LUHFWRULHV Directories serve two purposes Most file systems support multi level directories For users they provide a structured way to organize files For the file system they provide a convenient naming interface that allows the implementation to separate logical file organization from physical file placement on the disk Naming hierarchies usr usr local Most file systems support the notion of a current directory Relative names specified with respect to current directory Absolute names start from the root of directory tree November 12 2001 CSE 120 Lecture 12 File Systems 7 LUHFWRU QWHUQDOV A directory is a list of entries names and associated metadata List is usually unordered effectively random Metadata is not the data itself but information that describes properties of the data size protection location etc Entries usually sorted by program that reads directory Directories typically stored in files Only need to manage one kind of secondary storage unit November 12 2001 CSE 120 Lecture 12 File Systems 8 4 DVLF LUHFWRU 2SHUDWLRQV Unix Directories implemented in files Use file ops to create dirs C runtime library provides a higher level abstraction for reading directories NT opendir name readdir DIR seekdir DIR closedir DIR November 12 2001 Explicit dir operations CreateDirectory name RemoveDirectory name Very different method for reading directory entries FindFirstFile pattern FindNextFile CSE 120 Lecture 12 File Systems 9 3DWK 1DPH 7UDQVODWLRQ Let s say you want to open one two three What does the file system do Open directory well known can always find Search for the entry one get location of one in dir entry Open directory one search for two get location of two Open directory two search for three get location of three Open file three Systems spend a lot of time walking directory paths This is why open is separate from read write OS will cache prefix lookups for performance a b a bb a bbb etc all share a prefix November 12 2001 CSE 120 Lecture 12 File Systems 10 5 LOH 6KDULQJ File sharing has been around since timesharing File sharing is incredibly important for getting work done Easy to do on a single machine PCs workstations and networks get us there mostly Basis for communication and synchronization Two key issues when sharing files Semantics of concurrent access What happens when one process reads while another writes What happens when two processes open a file for writing Protection November 12 2001 CSE 120 Lecture 12 File Systems 11 3URWHFWLRQ File systems implement some kind of protection system More generally Who can access a file How they can access it Objects are what subjects are who actions are how A protection system dictates whether a given action performed by a given subject on a given object should be allowed You can read and or write your files but others cannot You can read etc motd but you cannot write it November 12 2001 CSE 120 Lecture 12 File Systems 12 6 5HSUHVHQWLQJ 3URWHFWLRQ Capabilities For each subject maintain a list of objects and their permitted actions Access Control Lists ACL For each object maintain a list of subjects and their permitted actions Objects Subjects one two three Alice rw rw Bob w r Charlie w r rw Capability ACL November 12 2001 CSE 120 Lecture 12 File Systems 13 V DQG DSDELOLWLHV The approaches differ only in how the table is represented Capabilities are easier to transfer They are like keys can handoff does not depend on subject In practice ACLs are easier to manage What approach does Unix use Object centric easy to grant revoke To revoke capabilities have to keep track of all subjects that have the capability a challenging problem ACLs have a problem when objects are heavily shared The ACLs become very large Use groups e g Unix November 12 2001 CSE 120 Lecture 12 File Systems 14 7 LOH 6 VWHP D RXW How do file systems use the disk to store files File systems define a block size e g 4KB A Master Block determines location of root directory Always at a well known disk location Often replicated across disk for reliability A free map determines which blocks are free allocated Disk space is allocated in granularity of blocks Usually a bitmap one bit per block on the disk Also stored on disk cached in memory for performance Remaining disk blocks used to store files and dirs There are many


View Full Document

UCSD CSE 120 - File Systems

Documents in this Course
Threads

Threads

14 pages

Deadlocks

Deadlocks

19 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Processes

Processes

18 pages

Threads

Threads

29 pages

Security

Security

16 pages

Paging

Paging

13 pages

Processes

Processes

32 pages

Lecture 2

Lecture 2

13 pages

Paging

Paging

8 pages

Threads

Threads

14 pages

Paging

Paging

13 pages

Paging

Paging

26 pages

Paging

Paging

13 pages

Lecture

Lecture

13 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Security

Security

17 pages

Threads

Threads

15 pages

Processes

Processes

34 pages

Structure

Structure

10 pages

Lecture 3

Lecture 3

13 pages

Lecture 1

Lecture 1

28 pages

Threads

Threads

15 pages

Paging

Paging

30 pages

Load more
Loading Unlocking...
Login

Join to view File Systems 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 File Systems 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?