Imagine byte-level access to a directory. You'd have to have some library in userspace that would correctly be able to manipulate that directory's metadata. Now imagine doing that for various filesystems.
Plan 9's namespaces and file-servers were pretty awesome and flexible. It really opened my eyes to the generality of the file abstraction.
I mean, as far as I see it, the directory is still a file, of a specific format.
How is that any different than an image file, say, of a particular format? You still need specialized programs in order to manipulate them in a meaningful way. But they're just bytes. Just like the directory is just bytes.
The difference, of course, is that allowing the user to arbitrarily manipulate a directory entry at the byte-level could lead to filesystem corruption.
I'm aware I may be missing something really obvious here. Heck, even contradicting myself :)
Educate me :)
On Linux? You `open()` a directory, and `getdents()` takes that file descriptor as input.
“These are not the interfaces you are interested in. Look at readdir(3) for the POSIX-conforming C library interface.” — getdents manpage
There are a few (redundant/duplicated with minor feature differences in triplicate, 'cause it's Linux) file-ish abstractions over parts of those concepts, but those abstractions are neither the only, recommended, or most widely used means of accessing those functionalities.