Re: open problem

Martin von Loewis (
Sat, 17 Jan 1998 19:28:29 +0100

> If a dir is nothing but a file with dir entries, with its own
> inode etc., why wasn't an open system call implemented for directories?

There are some Unix versions which actually do that, and it sometimes
results in a desaster. For example, 'vi /tmp' ... hmm, strange
looking characters ... type garbage keys in panic ... ahh, ZZ finally
got me out ... oops, where is the /tmp directory, and why is the system
flooding me with messages that I should fsck?

Actually, open is not the problem - read and write is.

> How exectly does the opendir libr. routine work?

Depends on the operating system and the C library. You usually start
with open(2). In old Linux versions, you continue with readdir(2).
More recent libraries on more recent kernels use getdents(2) instead,
which returns more then one file name per call.

Hope this helps,