Subject: Emulations and cookies
To: None <tech-kern@NetBSD.ORG>
From: Greg Hudson <>
List: tech-kern
Date: 10/08/1995 16:20:54
The getdents() emulation for Linux, SVR4, ibcs2, and SunOS emulation
doesn't currently work with remote filesystems (NFS and AFS), because
they don't return all of the directory entries from the vnode readdir
operation.  The problem is most noticeable under Linux emulation,
since Linux binaries only request one directory entry at a time.

mycroft and I have developed changes to make the emulations use
cookies (so they can get the next offset to use from the last
directory entry they wind up returning), and I've added cookie support
to fdescfs, procfs, and kernfs, three of the four filesystems which
support the readdir vnops without delegating it to another filesystem.
I still need to do a little more testing on the miscfs cookie support,
but I'm fairly confident that it works.

The problem is that adding cookies to the NFS client filesystem is
hard.  I've modified nfs_readdirrpc() to fill in cookies (as well as a
few other changes), and the client works for small directories the
first time you read them.  However, apparently when a page is cached,
the NFS client code simply returns the page which was returned
previously, without going through nfs_readdirrpc().  (I think.  It
might be doing something more broken than that; the NFS client code is
really confusing.)  Thus, no cookies are returned.  I think fixing
this may require restructuring the NFS client code a bit.  I certainly
can't do that today, and I don't know if I'm really qualified to do it
at all.

The upshot is that no emulation getdents() calls work at all with NFS
filesystems with mycroft's and my modifications.  Prior to the
modifications, Linux emulation worked very poorly and other emulations
may have worked for small directories.

The branch for the 1.1 release is Monday.  Should I check in our
changes tonight anyway, after some more miscfs testing?