CSE 451: Operating Systems Spring 2006 Module 12 CSE 451: Operating Systems Spring 2006 Module 12.5 Secondary Storage Overview John Zahorjan zahorjan@cs.washington.edu Allen Center 534 1
Interface Layers Std. Runtime Library App. Code OS Disk Device-type Dependent Commands Procedure Calls Whatever… Syscalls 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Exported Abstractions App. Code Std. Runtime Library OS Disk OS + a tiny bit of file type / structure Directories, Directory Entries, Files,… Array of Blocks Whatever / / etc root .xls root etc 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Primary Roles of the OS (file system) Hide hardware specific interface Allocate disk blocks Check permissions Understand directory file structure Maintain metadata Performance Flexibility OS Disk Why does the OS define directories? Why not leave that to the library/application layer? (Why would you want to leave it to the app/library?) / etc root 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
© 2006 Gribble, Lazowska, Levy, Zahorjan What Is A File? At this level, what we think of as a file is an “inode” An inode keeps track of where the data blocks are It also keeps track of metadata (e.g., permissions, last modification time, etc.) OS Disk / root etc 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
What Is A Directory? OS Disk Ok, so what is a “hard link”? / root etc 17 . 2 .. / 21812 passwd root etc 45709 hosts 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Obtaining Performance: Caching OS Disk read write readblock writeblock No… Block in cache? Why cache? How does it affect applications? 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Obtaining Performance: open OS Disk int fd = open(“/root/xxx”, O_RDONLY) [ read(fd,…) write(fd,…) ] readblock writeblock No… Per-process open file table inode / 1 2 3 … root etc file pointer 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Multiple File Systems readblock writeblock ext2 disk ext2 read write fat fat disk readblock writeblock Each filesystem: Decides which blocks to allocate for what (inodes, directories, file data) Decides what the format of a directory is Not really disks, but partitions. We’ll get to that later… 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Supporting Multiple File Systems: vfs ext2 disk read write ext2 vfs fat fat disk 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Extending Functionality ext2 disk read write ext2 fat vfs /dev fat disk /proc /dev: direct access to hardware blocks /proc: “virtual files” (computed, not stored, results) /proc is to the file system what cgi’s are to a web server (sort of) 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan
Are Directories Fundamental? What is the logical role of the directories? What practical role(s) do they have? Are there alternatives? 1/2/2019 © 2006 Gribble, Lazowska, Levy, Zahorjan