Basics
- File: abstraction fo data blocks on disk
- File System: controls how data on disk are stored in retrieved
Hard Disk
- Seek Time: time required to move read/write head to wanted cylinder (~10ms)
- Rotational Delay: Average time to wait until required sector moves under the read/write heads (~4ms)
- Read / Write Time: tiem required to read/write a sector (~50 μs)
File Types
- Regular Files: stores user information
- Directories: system files, store structure of file system
- Character special files: model I/O
- Block special files: model disks
File Naming:
- each file has a file name for identification
- naming convention depend on the OS
File Structure
- byte-oriented:
- record-oriented:
- tree-structured:

Types of File Access
- Sequential Access: Bytes can be read out only in sequential order
- Random Access: out of order readout possible
File Operations
- create
- delete
- open
- close
- read
- write
- append: can only add data at the end of the file
- seek: reposition file pointer inside file
- get attributes: retrieves relevant file attributes (access rights, time)
- set attributes
- rename
Directories (Folders)
- Files are usually organised in directories
- Directories are themselves also files
- hierarchical directories: files organised in user- and theme-specific groups
Pathnames
- can be absolut or relative to working directory (= current directory)
- process can use syscall to change working directory
- working directory is process-specific
Special File Names
- .: refers to working directory
- ..: refers to working directory's parent directory
Directory Operations
- create
- delete
- opendir
- closedir
- readdir: reads next entry from an open directory file
- link: creates link from existing file to directory
- unlink: removes a directory entry | if this only references a file -> file is removed
Disk Organisation
- Disk organised into Master Boot Record (MBR) and one or more disk partitions
Master Boot Record
- located in sector 0
- used to boot up computer
- contains partition table at the end
- in PT at any time, 1 partition is marked as active
Disk Partitions
- start with boot block (No OS needed for this)
- layout depend on file system
- typically starts with superblock
- contains key parameters of fyle system
File Allocation
- management of how blocks of filesa re allocated in physical memory
- File allocation Table (FAT)
- I(ndex)-Nodes
Allocation Types:
Contiguous Allocation
- file stored as contiguous run of disk blocks
- (+) simple, efficient
- (-) external fragmentation | How to reuse free blocks?
- (-) File Max Size must be known beforehand
Linked-list Allocation
- Blocks comprising file are stored as linked list
- First word of each block holds pointer to next block
- (+) avoids external fragmentation
- (+) directory entry only needs to store disk address of first block
- (-) random access very slow
- (-) block size not powr of two
Data Structures to Implement Allocation Types
File Allocation Table
- Contains pointers to subsequent file blocks
- only pointer to first block stored
- (+) block size can be power of two
- (+) random very fast
- (-) large FAT must be stored in memory
I-Nodes
- contains file attributes and addresses of disk blocks
- (+) i-node only needs to be in memory when file is opened
- (+) requires less memory
Directory Implementation
- Directory is file containing file attributes
- link to i-nodes containing file information
Shared Files
- files can appear in multiple directories with links
- hard links: link to i-node for the target file
- symbolic links:
- special file specifying filename of target file
- can also reference file in different partition
- incurs additional overhead in filename resolution
Log-Structured File Systems (LFS)
- (+) improves efficiency for small disk writes
- small writes are problematic due too seek and rotational delays
- LFS combines small writes in buffer, writes them in one segment at end fo log
- treat disk as big circular log
- (-) seperate i-node map required to licate file i-nodes on disk
- logging approach scatters i-nods all over, instead of fixed location
- cleaner thread works through log to free disk space
- removes obsolete data
- copies valied data to memory to be written to new segment at end of log
Journaling File System
- (+) more robustness againts crashes
- system crash can leafe file system in inconssisten state
- approach:
- record operations to be completed in log
- write log to disk
- execute operations
- delete log
=> in case of crash log is still present. -> Perform operations in log
Virtial File Systems
- allows several different file systems on the same system
- defines standardised interfaces for file operations
Design Considerations
- Block-Size:
- too large: waste disk space
- too smale: files span over many blocks
- management of free blocks:
- linked list of free disk blocks
- bitmap
Disk Quotas
- limit on how many files (i-nodes) and disk blocks each user can use
- when file is extended by new disk blocks, checked againts quota record
- soft limits can be temporarily exceeded
- warning issued, too many issued -> logging denied
- hard limits can not be exceeded