TippingPoint Digital Vaccine Laboratories
DID YOU KNOW... DVLabs and our Zero Day Initiative were credited with discovering 17 Microsoft vulnerabilities in 2006 alone.

A Bit of History

To say that this post is only tangentially related to security would be stretching the meaning of the word "tangentially" almost to the point of structural failure, but this is just too awesome to pass up. I promise that, this week, I will write a much more interesting and relevant blog post.

I've been doing a lot of work lately on TippingPoint's Custom Shield Writer tool, which we conveniently (and lovingly) refer to as "CSW". CSW allows a customer to write their own custom filters to apply to a TippingPoint IPS. The initials "CSW", however, reminded me of a story:

The other day I was, for reasons known only to myself, reading the manuals that came with First Edition Unix. This wasn't the first time I'd read them, but I noticed something new this time.

There was a manual page for a command known as 'dsw'. Obviously, this was the command used to interactively remove files (the equivalent, in modern parlance, of 'rm -i').

What struck me, however, was this little tidbit from the notes section:

The name dsw is a carryover from the ancient past. Its 
etymology is amusing but the name is nonetheless ill— 

Well, obviously, that's a mystery in need of solving. I'll admit that not all Unix commands are clearly named, but this one was obscure even by those standards.

I spent some of my time this past weekend looking up the answer. (Hey, what can I say? I know how to party!) The answer came from an old page on Bell Labs' website discussing Unix history.

It turns out, the name is a loose abbreviation of "delete from switches". Of course!

But, what are these switches, you ask?

Well, this edition of Unix ran on a machine from DEC called the PDP-11 (with 24KW of memory and no memory protection). The PDP-11, like most machines of that vintage, had a collection of switches on the front of its chassis. These switches were known by various names: "console switches", "front-panel switches", and so on.

These switches were used for a variety of purposes. One main use was to deposit values in memory before the operating system was loaded. It was by this laborious method bootloaders were placed into memory that would then read the rest of the operating system from tape or disk.

(The legendary Seymour Cray was famed for being able to switch in a bootloader from memory.)

On machines with a bootloader in ROM, these switches had less of a purpose, usually just for debugging or configuration purposes. The PDP-11 used by the original Unix developers had such a bootloader, and therefore, these switches were woefully underutilized.

The original version of 'dsw' didn't have much of a user interface. Modern interactive file deletion commands do something like the following:

* Get a list of files in the directory.
* For each file, print out its name.
* Wait for the user to confirm deletion of the file.
* Repeat until there are no more files in the list.

'dsw' eschewed this obviously over-complicated interface by using the aforementioned woefully underutilized console switches.

To interactively delete files in the current directory, the user would decide how many files appeared in the directory listing before the doomed file. They would then set the console switches to that number (in octal, of course), and run 'dsw'. The program would then read that number of filenames from the directory, store the name of the last file it encountered in its own process memory, print out that name, and then crash.

The crash would produce a core dump (a raw representation of the contents of memory when the program crashed).

To confirm the deletion the named file, the user could then run the core file. That is, rather than running 'dsw' again, they would read the contents of the core dump directly back into memory and jump back to that code.

This would cause the 'dsw' instance stored in the core file to read from memory the name of the last file it had encountered and delete it.

In this manner, you could be sure that you would not delete a file unless you really meant to.
This, my friends, is how a real programmer writes an interactive file removal program.
Tags: historical,humorous
Published On: 2008-03-18 14:49:04

Comments post a comment

  1. Israel commented on 2009-08-05 @ 22:22

    Excelent post, thanks!