[squeak-dev] Strange Unix file behavior?

Tony Garnock-Jones tonyg at lshift.net
Thu Aug 7 15:59:00 UTC 2008


Randal L. Schwartz wrote:
> In the early days, read(2) on a fd opened on a directory returned
> 18-byte chunks... 2 bytes for inode, 16 bytes for NUL-padded filename.

Right. That's the kind of thing I remember MINIX doing.

> Those routines are still documented in
> my modern OpenBSD and OSX releases, and are the routines that Perl uses
> to implement Perl's readdir() and glob() routines.

Looking at the manpage for read(2) on OS X 10.5, it reckons it'll 
complain EISDIR if an attempt is made to read a directory. (Note: I 
haven't actually tried it out! :-) perhaps I should)

There is, however, getdirentries(2), which I found via dir(5), and which 
returns struct dirents.

This reinforces my prejudice that interrogating directories is something 
that ought to be done via some other protocol than the byte- or 
string-oriented stream protocols.




More information about the Squeak-dev mailing list