Quoth Uri Guttman <>:
> >>>>> "MD" == Michele Dondi <> writes:
>
> MD> PS: re your last claim, I seem to remember having read in Tanenbaum's
> MD> that in the first versions of UNIX there was only one call for opening
> MD> files and directories and one for closing. For technical reasons
> MD> dedicated calls for directories were introduced after an improvement
> MD> of the fs. Hopefully someone more knowledgeable than I am may
> MD> clarify...
>
> you can always open a dir with just open and read the contents.
At least on Linux, you can open a directory with open(2) (which is what
opendir(3) uses), but cannot read it with read(2) (read fails with
EISDIR). To read the entries the call getdents(2) (from SVr4,
apparently) must be used. Closing is with close(2).
opendir(3), closedir(3) are equivalent to fopen(3), fclose(3), and must
be matched for the same reason (but you knew that already

).
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.