File Systems Basics
Overview
- storage stack
- file system
- abstraction on top of disk blocks
- organize persistent data into files and directories
- provide names and permissions to persistent data
- provide simple APIs to modify persistent data
- read, write, create, delete
- hide data placement (where data is stored on disk) details from users
- main abstractions
- file
- a container of persistent data
- consists of metadata and data
- metadata: size, owner, permission, type, where data locates on disk
- metadata for file is also known as inode, file header, file record
- directory
- a way to group and organize files
- if we implement directory as a file, what would its metadata & data track?
- metadata: track same set of information as file metadata
- data: track files within the directory
- any benefit to treating directory as a file?
- directory data format
- consists of an array of directory entries
- each directory entry contains 1. file name 2. file's metadata location
- each directory has two default directory entries:
.
(current dir) and ..
(parent dir)
- path
- namespace convention
/
separated path consists of all directories leading to the file
- all files can be found starting at root direcotry
/
- to read
/home/tom/foo.txt
- read in root's metadata, locate the data blocks for root
- read in root's data block, search for directory entry for "home"
- read in home's metadata, locate the data blocks for home
- read in home's data block, search for directory entry for "tom"
- read in tom's metadata, locate the data blocks for tom
- read in tom's data block, search for directory entry for "foo.txt"
- read in foo.txt's metadata, locate the data blocks for foo.txt
- read foo.txt's data block(s)!
- how do we know where to find root directory's metadata?