OSTEP Chapter 40

ECE 3600, Fall 2022


Table of Contents


1. File System Implementation

Example with 64 blocks, block size 4 KB:

One block each for superblock, inode bitmap, data bitmap.

5 blocks for inode table (256 bytes per inode, 16 inodes per block), 56 blocks for file data:

Reading an inode: address = 12KB + 256 * inumber; block = address / 4KB; offset = address % 4KB


2. Inode Contents

stat() shows subset of the inode contents; also see inode(7)

mode includes file type

Multi-level indexing for larger files: indirect block pointers, double indirect, triple indirect


3. Directories

Directories are just files with a special structure.


4. Open and Read Access Paths

open("/foo/bar", O_RDONLY)


5. Create and Write Access Paths


6. Exercises

Exercises from the book using vsfs.py:
$ python ./vsfs.py -n 4

Initial state

inode bitmap  10000000
inodes        [d a:0 r:2] [] [] [] [] [] [] []
data bitmap   10000000
data          [(.,0) (..,0)] [] [] [] [] [] [] []

Which operation took place?

inode bitmap  11000000
inodes        [d a:0 r:3] [d a:1 r:2] [] [] [] [] [] []
data bitmap   11000000
data          [(.,0) (..,0) (g,1)] [(.,1) (..,0)] [] [] [] [] [] []

Which operation took place?

inode bitmap  11100000
inodes        [d a:0 r:3] [d a:1 r:2] [f a:-1 r:1] [] [] [] [] []
data bitmap   11000000
data          [(.,0) (..,0) (g,1) (q,2)] [(.,1) (..,0)] [] [] [] [] [] []

Which operation took place?

inode bitmap  11110000
inodes        [d a:0 r:3] [d a:1 r:2] [f a:-1 r:1] [f a:-1 r:1] [] [] [] []
data bitmap   11000000
data          [(.,0) (..,0) (g,1) (q,2) (u,3)] [(.,1) (..,0)] [] [] [] [] [] []

Which operation took place?

inode bitmap  11110000
inodes        [d a:0 r:3] [d a:1 r:2] [f a:-1 r:1] [f a:-1 r:2] [] [] [] []
data bitmap   11000000
data          [(.,0) (..,0) (g,1) (q,2) (u,3) (x,3)] [(.,1) (..,0)] [] [] [] [] [] []

$ python ./vsfs.py -n 4 -r

Initial state

inode bitmap  10000000
inodes        [d a:0 r:2] [] [] [] [] [] [] []
data bitmap   10000000
data          [(.,0) (..,0)] [] [] [] [] [] [] []

mkdir("/g");  State of file system (inode bitmap, inodes, data bitmap, data)?

creat("/q");

creat("/u");

link("/u", "/x");