Which was the last Unix release/flavor where you could still read(2) a directory? All manpages that I've found say that you get EISDIR if you try it.
FreeBSD’s man page says (https://www.freebsd.org/cgi/man.cgi?sektion=2&query=read):
[EISDIR] The file descriptor is associated with a directory
residing on a file system that does not allow
regular read operations on directories (e.g. NFS)
NetBSD says something similar, adding ”The readdir() function should be used instead.”I also am not convinced that, for example, the Linux man page (http://man7.org/linux/man-pages/man2/read.2.html) guarantees you get EISDIR when reading from a directory. It says that if you get EISDIR, fd refers to a directory, but isn’t explicit about the converse.
https://github.com/torvalds/linux/blob/2a56bb596b2c1fb612f99...
https://github.com/torvalds/linux/search?p=1&q=generic_read_...