Subject: Re: EISDIR on directory read(2)
To: Soren S. Jorvang <>
From: Giles Lean <>
List: tech-kern
Date: 10/10/1999 17:41:06
On Sun, 10 Oct 1999 08:51:34 +0200  "Soren S. Jorvang" wrote:

> what is the rationale for not just returning EISDIR
> when trying to read(2) a directory?

Part history, part philosophy.  With the idea that "everything is a
file" directories are (mostly) just files, and the format was simple
enough that once upon a time applications read them directly.

With increasing complexity of the directory format (and for
portability) using standard library routines instead of reading
directories directly became popular.

Times changed some more and getdents(2) appeared, which saves libc
from having to know about every filesystem type that might be used on
a system.

For read(2) not to work on directories would require that it do the
equivalent of fstat(2) on the file descriptor on each call.  Not a
good idea for performance. :-)