Computer Science 111 Lecture 12 - File System Implemenatation

Authors: Omar Issa Attar and Shahid Chohan


File Systems


Links

Symbolic Links

ln -s a b
ln -s b a // a points to be abd b points to a
ln -s x x //self loop
What can go wrong
  1. Text editors other than Emacs can change /etc/passwd. Because they won't create the symbolic link, Emacs can't use it to detemrine if other editrs are editing the file. Emacs solves this by calling stat('/etc/passwd') to determine its modification time. If the file is modified after Emacs opened it, this means that another editor is editing the file as well and so Emacs will warn you before rewriting the buffer.

  2. Emacs can crash causing it to not delete the symlink. Emacs solves this by checking the pid.

  3. Emacs can go into an inifnite loop with teh lock, so the process still exists but Emacs will never delete the symlink.

  4. Another application can remove the lock file or change what it poitns to.

  5. The filename after that last slash is at least 254 characters and so Emacs can't prepend the '.#'.

Hard Links

Arguments Against Hard Links

Link Counts and Problems


How to Implement '.' and '..'

  1. Each directory contains at least two entries: . and .. (this is simpler)

  2. Omit . and .. from disk since namei "knows: about them (this is more efficient)


Cycle Problems

$ln / /usr/bin/oops //This creates a cycle

How to Prohibit Cycles


How to Waste Less Space With Symlinks

  1. Store short symbols in inode itself

  2. Two block size (short blocks 1/4 of size)


BSD File System


Layers of Unix File System

Sectors

Blocks

Partitions

Inodes

File Name Components

File Names

Symlinks


Shred

$shred file

Why random data rather than zeroes?

Does shred work?

FIPS Standard on Deleting Data

  1. Melt the device

  2. Physically shred the device

  3. Degauss the device

  4. Overwrite with random data