Wandering Thoughts archives

2023-01-01

Research Unix V2 already had a lot of what we think of as 'Unix'

When I looked into how far back Unix's special way of marking login shells goes, I wound up looking at the V2 source of login.s, which is a .s file instead of a .c file because C (the language) was barely starting to be a thing in mid-1972. One of the things that struck me when I looked at the V2 login.s was how much of what we consider standard Unix features were already there in some form in V2.

In no particular order, the default shell is /bin/sh, there is an /etc/motd, /etc/passwd seems to have the idea that your shell might not be /bin/sh but instead something else, and there's both utmp and wtmp (although both are in /tmp, not their later locations). There is even some sort of mail system, using a 'mailbox' file located in people's home directories.

(There is also /dev/tty<X>, but everything being in the filesystem is a big Unix feature and so it doesn't surprise me that it was there very early.)

Another interesting thing is that there are some familiar sounding standard library subroutine names in use, such as 'fopen' and 'getc'. The V2 library source we have reveals some other familiar names, like a 'printf' (implemented in both C and assembly). While we don't have the V2 library source for these functions that I could spot, we do have the V1 manuals, which reveal that fopen did apparently use buffering, unlike the direct system calls.

Other source code we have reveals more familiar things. Init.s says there was a /dev/tty and an /etc/getty, for example. And getty.s says V2's login was in /bin, as you'd expect. Acct.s reveals a 'qsort' function already present in the standard library.

Because I was curious, I looked at the V2 ls.s, and I think the flags it supports are -l, -t, -a, -s, and -d. Based on A Brief History of the 'ls' command, this is the same set of flags that V1 Unix had.

At one level this isn't surprising. I'm pretty certain that we've known from the early writings about Unix that a lot of the core ideas of Unix were there from the start. At another level, it's interesting to me how much was there how early, in a lot like its later form. I wouldn't necessarily have guessed that utmp and wtmp were in V2, for example.

unix/UnixV2HadALot written at 22:44:57; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.