readdir() cookie requirements

The requirements for correctly supporting readdir() are convoluted and arcane. I can usually reason them out from first principles given a few minutes, but I’d much rather just read Ted T’so’s excellent summary, posted to the btrfs list in January:

Requirements to support readdir()

In particular, the requirement for a 32-bit cookie that is stable across reboots comes directly from NFSv2 readdir(). Otherwise, readdir()/telldir()/seekdir() only has to be stable between open() and close() on that fd. If you don’t support NFSv2 exports, then supporting readdir() on your file system becomes quite a bit easier (something we are specifying for union mounts – hey, maybe I should post about that…).