[Gllug] Is this funny

Nix nix at esperi.demon.co.uk
Tue Jan 1 19:52:35 UTC 2002


On Mon, 31 Dec 2001, kieran at esperi.demon.co.uk spake:
> On Mon, 31 Dec 2001, Gordon Joly wrote:
> 
>> At 14:40 +0000 2001-12-31, Kieran wrote:
>> As I recall, Version 6 had directories and file equivalence...
>>
> I don't think I fully understand what this means.  Care to elaborate?

[I expect you know this, but for the benefit of any interested
bystanders...]

There was no getdents() syscall, nor opendir()/readdir()/closedir(), nor
anything like them; the functions existed, but there were several
competing variants, and they were all in userspace.

Directories were just files with a different type; read(2) and write(2)
worked on them, and the kernel understood their format. If you didn't
stick to the foramt and dumped random gunk in the directory, bad things
happened to system stability.

mkdir(1) was a shell script that created an empty directory and
link(2)ed in . and .. entries in it.

This whole house of cards fell completely to pieces when other
filesystems started to be supported, because the knowledge of the format
of a directory was wired into lots of userspace programs :( many Unixes
(such as Linux) even ban read(2)ing from a directory, on the basis that
even if write(2)ing to a directory is banned, if you're allowed to
read(2) from it someone will find a way to rely on that :(


(Aside: because so many userspace programs had to manipulate directory
entries, a special function was added to the libc to help. Filenames in
V6 directory entries were 14 chars long, null-terminated except if the
name was 14 chars long, in which case the null-terminator was
omitted... recognize the semantics? that's right: strncpy(). IMHO, any
use of strncpy() other than manipulating a V6-format directory is wrong;
its semantics are too bizarre to be of use elsewhere.

-- 
`Perhaps you should have asked Santa for your program as a Christmas
present.' --- Terran Melconian

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list