Today
- FS API
- FS Implementation
FS API
File
- byte array
- has low-level name (number)
Directory
- Map human-readable names -> low-level names
e.g. file “main.c”
- low-level #: 1000
- directory: “main.c” -> 1000
Access
- open, read, close
Grow
- open, write, close
Write to arbitrary point in the file:
- lseek
Delete
- unlink
FS: tracks info about each file
- “Meta data”
- What info is there per file?
Directory
- Just a special type of file
- metadata: inode
- data: contents of directory
- Map:
- “main.c” -> inode #1000
- “main” -> inode #1001
- … etc.
- all directories also store:
- “.” (dot) -> inode # of current directory
- “..” (dot dot) -> inode # of parent directory
File System Hierarchy
/ (root directory)
/ | \
dir file.c dir2
| \
dir3 file2.c
- Absolute pathname:
- starts at root, and includes the entire path to file or dir
- Relative pathname:
- current working directory (CWD)
cd=> move shell to “location” in hierarchy- cd /dir2 CWD: dir2
- “file2.c”
- “./file2.c”
- “../file2.c”
- “../dir2/file2.c”
- current working directory (CWD)
- Path traversal:
open("/a/b/c/d/main.c", O_RDONLY)- read root dir /
- look for “a” => a’s inode #
- read “a”
- look for “b” => b’s inode #
- …
- read “d”
- look for “man.c” => main.c’s inode #
- Link (Hard Link)
- program:
ln directory inode # "foo" 8388622 "foo2" 8388622 "foo3" 8388622rm: unlink inode from file name- “last” unlink: removes contents from disk, etc.
- program:
File System Implementation
- On-disk structures
static - Access methods
operation - Disk: [blocks] => 4KB

- Inode Bitmap
- tracks which inodes free/not
- Data Bitmap
- track which block free/not
- Super Block:
- metadata: information about entire file system
- e.g. => size, where data region is, etc.
- magic #, type