Linux doesn't let you do a plain
read(dir_name, buffer, sizeof(buffer) - it always returns -1 and puts EISDIR in
errno. This is probably rational, as not all filesystems have directories as files. The commonly-used reiserfs does not, for example.
You can use the
open() system call from a C program to get a file descriptor of a directory, but things like
readdir(3) (from libc) call
getdents(2) to actually retrieve directory entries. There's probably code in each filesystem implementation to create
struct linux_dirent from whatever (a file, a database, an on-disk B-tree) that filesystem uses to store directory entries.