Filesystem
The part of OS that helps programs create, manage, and delete files on disk (sec. storage)
- Logical Level: exposes file and dir. abstractions, offers API calls for file handling
- Physical Level: works w// disk dirmware and moves bytes to/from disk to DRAM
Dozens exist
- differ on how they layer file/dir abstractions as bytes
- differ on how data integrity/reliability is assured
- some can work w/ multiple OS
Virtualization of File on a Disk
OS abstracts a file on disk as a virtual object for processes
- File Descriptor: An OS-assigned integer identifier/reference for a
file’s virtual object that a process can use 0/1/2 reserved for STDIN/STDOUT/STDERR
- File Handle: A PL’s abstraction on top of a file descr. (fd)
System Call API for File Handling:
open(): Create a file; assign fd; optionally overwrite
read(): Copy file’s bytes on disk to in-mem. buffer; sized
write(): Copy bytes from in-mem. buffer to file on disk
fsync(): “Flush” (force write) “dirty” data to disk
close(): Free up the fd and other OS state info on it
lseek(): Position offset in file’s fd (for random R/W later)
Dozens more (rename, mkdir, chmod, etc.)
Files Vs Databases: Data Model
- Database: An organized collection of interrelated data
- Data Model: An abstract model to define organization of data in a formal (mathematically precise) way
- E.g., Relations, XML, Matrices, DataFrames