The d_off field has been added to the dirent structure recently. Currently filesystems don't support this feature. Support has been added and tested for zfs, ufs, ext2fs, fdescfs, msdosfs and unionfs. A stub implementation is available for cd9660, nandfs, udf and pseudofs but hasn't been tested.
Motivation for this feature: our usecase is for a userspace nfs server (nfs-ganesha) with zfs. At the moment we cache direntry offsets by calling lseek once per entry, with this patch we can get the offset directly from getdirentries calls which provides a significant speedup.
Any specific reason to write the or statement as two separate if clauses?
I believe in other parts we do it ((true & x & y & z) | (false & a & b &c )) - as multiline checks;
I don't like them both get executed "always", so at the very least, an "else" just before the 2nd if would be good.
The logic looks ok to me.