Outline
- inodes and superblock
- opening files
Minix Buffer Cache Summary
- blocks are in LRU queue and also hash table
- blocks in buffer cache are not in use, may be reused soon
- blocks in buffer cache may be dirty, in which case they
should be written back before they may be used
- free blocks are taken from the head of the queue
- newly freed blocks are put at the end of the LRU queue,
except in special cases
- newly freed dirty inode blocks are written back immediately
Minix Inode and Superblock Implementation
- inodes have a link count and an in-memory reference count:
- if the reference count becomes zero, the file should be closed
- if the link count becomes zero, the file should be removed
- duplicating an inode (as in dup or dup2) simply
requires incrementing the reference count
- when creating a new inode, the block containing the inode
must be read into memory, since the other inodes on the block
might already exist (as an optimization, the bitmap could be
checked to avoid the read if all other inodes in the block are free...
but minix doesn't do this)
- inode blocks are written back immediately
- to avoid calling the clock unnecessarily, the times are only
updated at most once when the inode is written back (p. 944)
- superblock management includes allocating and freeing bits
in the two bit maps. Allocating starts from the last position searched
or freed
Minix Opening and Closing
- common_open (p. 966)
- may create a new file, by calling
new_node (p. 968), which allocats an inode then
adds the name and the inode to the directory entry
- allocates an in-memory inode and filp and initializes
them
- checks protections
- does type-specific operations for regular files, directories,
block- and character-special files, and pipes
- e.g. for regular files, truncates them (by returning all the
blocks and clearing the inode) if the open requested truncation
- mknod and mkdir (p. 970) do what is
needed, e.g. mkdir creates the "." and ".." links
- search_dir (p. 997) edits or serches the directory
- last_dir (p. 994) returns the inode of the last
directory in the path
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.