ls(1) on System V

Guy Harris guy at sun.uucp
Thu Apr 11 17:15:10 AEST 1985


> Well, the problem is that in the readdir() routine, the code is doing
> strlen(dentry.d_name), and d_name isn't null-terminated if it's 14
> characters long (I think strlen returns 44 or so).

This is the second S5R2 bug that is fixed "for free" if you convert
to the Berkeley "directory library".  The library provides directory
entries with null-terminated names, fixing this bug; the previous bug
was a shell problem caused, if I remember correctly, by testing whether
the result of an "open" of a directory was > 0 rather than whether it
was >= 0.

I've converted lots of S5R2 programs to use the library; it's very easy.
I'd vote for putting it into 1) the /usr/group standard, 2) the System V
Interface Definition (which currently, bless its soul, does *not* commit
to what directories look like when you open them), and therefore 3)
System V.

	Guy Harris
	sun!guy



More information about the Comp.unix.wizards mailing list