Filesystems provide an abstraction from dealing with disk and memory blocks ➡️ ➡️ ➡️
Header contains metadata like:
.c or .java etc.// read man pages for filesystem API spec
fd1 = open(filepath, mode) // access file in mode r, w, x
fd2 = creat(filename, mode)
close(fd2)
error = read(fd1, buffer, num_bytes)
error = write(fd1, buffer, num_bytes)
pos = lseek(fd1, offest, whence) // whence -> absolute or relative offset from current fd pointer
status = link(old_link, new_link) // this is a hard link
status = unlink(old_link) // decrements ref count
status = stat(filename, buffer) // get file header

💡 Hard Link vs. Soft link
| • A hard link is like creating another "name" for the same file. • Both the original file and the hard link point to the same data on the disk. • If you delete the original file, the hard link still works because the actual data isn't deleted until all hard links to it are removed. • Hard links can only exist on the same file system as the original file. | • A soft link is like a shortcut or pointer to the original file. • It is a separate file that points to the path of the original file. • If you delete the original file, the soft link breaks because it has no data of its own. • Soft links can cross file systems and point to directories. | | --- | --- |
DFS should be transparent (conceal server details from client), handle concurrent clients, and replicate for fault-tolerance
| One-copy Update | When a file is replicated, its contents when fetched by a client are no different than when fetched if only one replica existed |
|---|---|
| At-most Once | Operations that should not be repeated - like link() and create() |
| At-least Once | Operations that need to be executed at least once (usually idempotent) - like stat() read() with abs offset lseek() with abs offset |
| Idempotent | Operations that have no side effects if run multiple times |
| Authentication | “Is the user who they claim they are?” |
| Authorization | “After authentication, is this user allowed to access the file they’re requesting?” |
| → Access Control Lists (ACLs) is a per-file list of allowed users | |
→ Capability Lists is a per-user list of files they can access and the type of access (r w x ) |
Flat File Service API
read() and write() in the most simple version
create() and delete()get_header() and set_header()Directory Service API
lookup(dir, filename) to find a filecopy_file() and delete_file()get_file_in_dir()Interact with Client using Unix API

NFS client is integrated into kernel and makes RPCs to server
t usually 3-30 for files and 30-60 for directoriesTc (time entry was last validated) and Tm (time block was last modified by server)(Tnow-Tc) < t or Tm_client = Tm_server
NFS server plays the role of dir + flat file service
mount("usr/twitter", "usr/x") points all files in /twitter to /x (not a copy)Virtual File System Module
v-node of local file → points to → local disk i-nodev-node of remote file → points to → address of remote NFS server