12/4/2018 CSC 452 – File Systems Files Jonathan Misurda jmisurda@cs.arizona.edu File Naming File Extensions • Case Sensitive – Linux/UNIX • Case Insensitive – DOS • Case Insensitive, Case Preserving – Windows – Mac Metadata File Structure • Data that describes data 1 record – Type of file 1 byte – Creator 11 12A 101 1 – Structure of the data • Is an extension a good place to record sab wm cm avg ejw sab elm br metadata? Sequence of bytes Sequence of records S02 F01 W02 Tree 1
12/4/2018 File Types File Attributes File Operations Using System Calls • Create • Append • Delete • Seek • Open • Get attributes • Close • Set attributes • Read • Rename • Write Using System Calls (2) Memory-mapped Files Program Program text text abc Data Data xyz Before mapping After mapping 2
12/4/2018 Single Level Directory Root Directories directory A A B C foo bar baz blah Two-Level Directory Hierarchical File System Root directory Root directory A B C A B C B B C C C A A A foo Papers bar foo blah Papers foo Photos A A B B C C C foo bar foo baz bar foo blah A A A B B os.tex sunset Family foo.tex foo.ps A A A sunset kids Mom UNIX Directory Structure Directory Operations • Create • Readdir • Delete • Rename • Opendir • Link • Closedir • Unlink 3
12/4/2018 Disk Layout Entire Disk File System Implementation Partition table Master Partition 1 Partition 2 Partition 3 Partition 4 boot record Boot Super Free space Index Files & directories block block management nodes Contiguous Allocation Contiguous Allocation A B C D E F 0 1 2 3 4 5 6 7 8 9 10 11 Deletions A Free C Free E F Start=5 Length=2902 Linked Allocation File Allocation Table (FAT) 0 2 1 -1 0 1 2 3 4 5 6 7 8 9 10 11 2 -2 3 -2 2 x 6 x 0 4 -1 5 -1 6 3 B Start=9 7 -1 Start=3 End=2 8 -1 End=6 Length=2902 Length=1500 9 0 A 10 -1 11 -1 12 -1 13 -1 14 -1 15 -1 4
12/4/2018 Index Nodes (i-nodes) Directories and Attributes 6 9 attributes 7 games attributes games 0 attributes mail attributes mail 8 news attributes news attributes research attributes research 0 1 2 3 4 5 6 7 8 9 10 11 attributes Storing all information Using pointers to in the directory index nodes grades 4 4802 Name index size Long Filenames Sharing Files Root directory A B C B B C C C A A A foo Photos bar foo blah Papers foo Photos A A A B os.tex sunset Family lake A A ? sunset kids ??? Links Disk Space Management 100 A A B B b.tex b.tex a.tex a.tex Owner: A Owner: A Owner: A Count: 1 Count: 2 Count: 1 Block size 5
12/4/2018 Free Block Tracking Disk Quotas 0 1 2 3 4 5 6 7 8 9 10 11 2 x 6 x 0 Start=3 Start=9 End=6 End=2 Length=1500 Length=2902 11 0100 4 3 8 1101 7 1 1011 5 10 Linked List Bitmap Backing Up Bitmap From Dump File that has not changed Consistency Checking File Block Cache Consistent Missing (“lost”) block Duplicate block in free list Duplicate block in two files 6
12/4/2018 Grouping On-Disk Data Log Structured File Systems UNIX Fast File System FFS Directory data protection mode Directory data owner & group . . . inode number timestamps data record length size block count name length data • link count . . . • • name Direct pointers data . . . • • data inode number • single indirect . . • . • record length double indirect • • data • name length triple indirect • • • • • name data inode • • . . . • • • • • data CDFS FAT Directory 7
12/4/2018 MS FAT FAT32 Directory and Filename Block size FAT-12 FAT-16 FAT-32 Bytes 0.5 KB 2 MB 1 KB 4 MB 2 KB 8 MB 128 MB 4 KB 16 MB 256 MB 1 TB 8 KB 512 MB 2 TB 16 KB 1024 MB 2 TB Checksum 32 KB 2048 MB 2 TB Long Filename in FAT32 Flash File Systems Wear Leveling Count total writes per flash sector and attempt to balance across the whole disk 8
Recommend
More recommend