Inode allocation #
- Where on disk for inodes?
- Contiguous array at outer edge: lots of seeks
- Many arrays, spaced over disk
- FS tries to allocate data for an inode near the inode itself
- Index in array: i-number, unique identifier for a file
Directories #
- Map from name to i-number
- Previously: one directory per disk, then per user
- Today: hierarchical directories
- Stored like regular files
- inode has special bit indicating it’s a directory
- Root directory has i-number 2
Procedure for looking up file #
File: /a/b/c
- root inode
/
directory file (a
)- inode for
/a
- first block of
/a
(findb
) - inode for
/a/b
- first block of
/a/b
(findc
) - inode for
/a/b/c
- first block of
/a/b/c
Working directories #
- OS stores i-number in process control block
- This represents current working directory
- Lookup: leading slash: inumber 2, else cwd
Links #
Hard links #
- Multiple directory entries for an inode
- Reference count in inode
- No circularities because can’t hard link to directories
Symbolic (soft) links #
- Symbolic link: special file
- Contents: path name
- During lookup: symbolic link? prepend link to path
ln -s /e/f /a/b
- Better for directories