Module 13: The OS File System Flashcards
System calls for files:
fopen(): open file for reading and writing
fwrite(): writes data to a file
fseek(): sets the position of the stream to the given offset, allowing seeking a specified part of the file
fread(): read from the file
fclose(): close the file
disk block
basic logic unit of storage on disk of a contiguous set of bytes
disk partitions
logical split of the actual disk drive; the OS views each partition as a distinct disk, and different OS may be run in each split; each partition has at least one directory, in which all the partition’s files are listed
typical internal structure of the disk parition:
- boot block: contains info on the disk layout and code for loading the OS into the kernel space
- superblock: contains basic information about the file system, including the file system size, list of free blocks, list of allocated blocks, and time of the last modification to the partition; the superblock can be read into memory at boot time
- free space data structure: tracks the free space in the disk
- i-nodes list: stores information about the individual files stored on disk
master boot record
stores information about the entire drive
partition table
specifies the beginning of each partition
disk space allocation
managing data in the disk with the aims to ensure fast sequential success, fast random access, the ability to grow a file system quickly, and to minimize fragmentation
4 methods for managing disk space allocation
- contiguous allocation
- linked-list allocation
- file allocation table (FAT)
- linked list with indexing or i-nodes
- -> i-node: a kernel structure storing information about each file in the file system; contains a pointer to the disk blocks containing the file’s data, and information such as the file permissions, ownership, modification time, and file type
directory
a file that holds the list of filenames and their i-nodes; provides information needed to find the disk data blocks of a file
hard links
to represent two different paths for a file, create a single i-node and have two directory entries that point to the same i-node; relies on the link-counter
link-counter: counts the number of ways that an i-node can be retrieved along different paths
symbolic/soft link
original file has its own i-node and for each reference or path to the file, there is a separate i-node of type LINK, for a file that just contains the path name to the original file
free space management
tracking unallocated blocks in a portion of the disk partition
- -> bitmap: maintains the entire disk partition with one encoding the fact that the block of a particular number is free and zero otherwise
- -> linked list: storing the free blocks
in-memory cache
uses a scheme to store blocks that are likely to be requested from disk, to shortcut the need for a disk search and propagate the data to the requesting process
–> LRU scheme: given the limited in-memory cache size, evicts the least recently used block from the cache when new blocks are being added in
incremental backups
every time you synchronize with your server, it will only backup files that have been changed since the last time
physical backup
physically copy block by block from one disk to another