Fragments of old code

This list is very out of date, but some of it might possibly still be useful.
Most of the software below is released under the GNU General Public License. Look at the individual programs for details.

Bootloader support for Xen (and other multiboot kernels)

GRUB patches

This patch against GNU GRUB 0.97 adds a new command "findconfig". It's a merge of the existing "find" and "configfile" commands, and allows you to search for a configuration file on all partitions and load the first match automatically. It was written for a test CD which needs to reboot several times to find new kernels, without having a statically configured place on disk to store what to do next. N.B. I recommend you apply this patch as well, which fixes a bug in partition handling code for CDs that tends to be triggered by findconfig.


Xenoboot is an (x86) linux-based boot CD designed to fetch boot instructions from a server and pseudo-reboot (by magic kernel trickery) into another operating system. Think of it as DHCP on steroids. It was written for controlling the test machines in our research group. The download page for xenoboot is here. N.B. Xenoboot has nothing to do with the Xen virtual machine monitor. The names are only similar because they both come out of the Xenoservers research project.


The many-featured xterm(1) program has magic strings to allow you to set and to read the title-bar and icon-label. xtitle is a small C program to issue these runes, allowing you to easily read and set xterm titles. I wrote this so that my shell could set the xterm title to reflect the machine I'm logged into, and put it back to what it was when I log out, e.g.

[ "$TERM" = "xterm" ] && OLD_XTITLE=`xtitle -r $HOSTNAME`

in .bash_profile, and

[ -n "$OLD_XTITLE" ] && xtitle $OLD_XTITLE

in .bash_logout.

Title reporting has been deliberately disabled in the xterms that ship with many systems because malicious text printed on the xterm can set the title to include some arbitrary command and then issue the get-title runes to insert it at the command-line. (See CAN-2003-0063. This is a pretty crude response to a very particular attack -- there are other bad things an attacker can do if you let him print arbitrary characters to the terminal, and the proper defence is always to use a pager to view text from untrusted sources, such as log files.) If you want to be sure that both title and icon-label reporting are disabled, on XFree86 xterms since 4.3.0, you can set the 'XTerm*allowWindowOps' resource to false (it defaults to true). If title reporting is disabled, it's still possible to find out the title from the X server if we know the xterm's window id, e.g.

xprop -id $WINDOWID | sed -n 's/^WM_NAME(STRING) = "\(.*\)"$/\1/p'

Unfortunately, $WINDOWID is not exported by ssh to the remote host.


After exposure to the horrors of SysV /bin/true, I felt the need to make a smaller, neater, more efficient version. The minimal /bin/true, on many systems (Solaris, Linux, FreeBSD, probably others) is a 0-byte executable. /bin/false, however, is slightly more of a challenge. Here is what I came up with. The smallest I could do for x86 ELF is 84 bytes long, the size of the ELF file header and program header. (In fact it's possible to make a smaller executable by leaving out parts of the ELF header that the loader doesn't actually look at, but I like standards compliance.) On Linux, the a.out version is smaller - only 39 bytes. On FreeBSD, which only supports demand-paged a.out, the a.out executable is 4K (1 page). SUSv3 compliant!

Text generation

A long, long time ago, I wrote a program in BBC BASIC that implemented a version of the Mark V. Shaney algorithm for generating semi-plausible text using a simple model based on a Markov chain. It was a good program, sensibly written, bug-free, and clearly commented, and I am proud of it. This is not that program. This is the same algorithm implemented as a single line of perl.

RFC 1339 things

RFC 1339 ("Remote Mail Checking Protocol", a.k.a remailck/re-mail-ck) is a simple UDP protocol for checking if you have mail on a server, much more lightweight than opening a TCP connection for finger or POP3/IMAP. Unfortunately, despite being a Good Thing, it is not widely supported.

mpg123/StrongARM patches

The NetBSD/arm32 package of mpg123 was patched to do its calculations in 32-bit integers, as the ARM has no FPU. Unfortunately this caused mpg123 to glitch nastily on quiet music, and I like listening to classical music on my Shark, so I wrote this further patch to do 64-bit integer arithmetic on ARMv4 (SA110) and later.

June 2002: This patch has now been integrated into the standard NetBSD patches.

Linux capability hacks

The Linux kernel has a system of capabilities built into it. By default (in v2.4), the system is nobbled to make it behave in the old way: if your uid is 0, you have all the power. This is done by resetting capabilities in the execve() system call. I have written a version of sucap which works around the execve() hack, so that root can execute programs as unprivileged users, with extra capabilities set.

To use it, you'll need to frob the kernel so that root is given the CAP_SETPCAP capability: Here's a script that uses kpoke to frob the relevant kernel variable (the sysctl is also nobbled). N.B. There are security concerns here: CAP_SETPCAP is missing from cap_bset for a good reason, and this is not a very smart way around this one for most purposes.

November 2003: My sucaps code is being used by these guys in their linux-based commercial VST plugin player.

ytalk -E

YTalk sometimes pops up questions on the screen (when a new person arrives in the session, for example). Those of us who still fall into the habit of looking at the keyboard as we type sometimes find that the question has been answered by an inadvertent "n" or "y" in whatever we were typing at the time. This is a patch against v3.1.1 which adds the option of making ytalk wait until you press Escape before accepting an answer to such a question.

February 2005: This option is in mainstream ytalk since v3.2.0 (via FreeBSD).

Other minor hacks

Acenic development tools

In 1999, working in the University of Cambridge Computer Lab, I did some work on user-space network devices, using the Alteon ACEnic gigabit ethernet card. Writing firmware for them involves cross-compiling MIPS code to run on the internal processor cores. Here are some tools that Austin Donnelly and I wrote for compiling and debugging Acenic firmware.