ugh.book

(singke) #1
UFS: The Root of All Evil 269

Good luck.

We spoke with the current system administrator at the MIT AI Lab about
this problem. He told us:


Date: Mon, 4 Oct 93 07:27:33 EDT
From: [email protected] (Bruce Walton)
Subject: UNIX-HATERS
To: [email protected] (Simson L. Garfinkel)

Hi Simson,

I recall the episode well; I was a lab neophyte at the time. In fact it
did happen more than once. (I would rather forget!:-) ) Life would
barf file system errors and panic, and upon reboot the mail partition
was hopelessly scrambled. We did write some scripts to grovel the
To: addresses and try to assign uids to the files. It was pretty ugly,
though, because nobody could trust that they were getting all their
mail. The problem vanished when we purchased some more reliable
disk hardware...

No File Types


To UFS and all Unix-derived file systems, files are nothing more than long
sequences of bytes. (A bag’o’bytes, as the mythology goes, even though
they are technically not bags, but streams). Programs are free to interpret
those bytes however they wish. To make this easier, Unix doesn’t store
type information with each file. Instead, Unix forces the user to encode this
information in the file’s name! Files ending with a “.c” are C source files,
files ending with a “.o” are object files, and so forth. This makes it easy to
burn your fingers when renaming files.


To resolve this problem, some Unix files have “magic numbers” that are
contained in the file’s first few bytes. Only some files—shell scripts, “.o”
files and executable programs—have magic numbers. What happens when
a file’s “type” (as indicated by its extension) and its magic number don’t
agree? That depends on the particular program you happen to be running.
The loader will just complain and exit. The exec() family of kernel func-
tions, on the other hand, might try starting up a copy of /bin/sh and giving
your file to that shell as input.


The lack of file types has become so enshrined in Unix mythology and aca-
demic computer science in general that few people can imagine why they

Free download pdf