Apparently it doesn't like that I try to fsync() a read-only
directory file descriptor. I would argue that NetBSD is correct in this.
Posix says:
The fsync() function shall request that all data for the open file
descriptor named by fildes is to be transferred to the storage
device associated with the file described by fildes.
I read this a being about the file descriptor, not the file. Which
would imply that fsync()ing an O_RDONLY descriptor doesn't make sense.
However, the wording for fdatasync() is slightly different and not as
clear, whether intentional or not. But fdatasync() seems to be
conceptually about regular files anyway.
From an admittedly non-Linux perspective, I'm unsure why one would
need to perform a flush on a directory in the first place.