Subject: Re: readdir ops of linux emul and nfs
To: enami tsugutomo <enami@but-b.or.jp>
From: Frank van der Linden <fvdl@netbsd.org>
List: tech-kern
Date: 10/13/2003 15:41:31
On Mon, Oct 13, 2003 at 10:20:54PM +0900, enami tsugutomo wrote:
> On the japanese local mailing lists, there was a report that some
> directory operation fails if it is linux emulation and on nfs file
> system.
> 
> For example,
> 
>     # /emul/linux/sbin/ldconfig -r /emul/linux/
>     # /emul/linux/sbin/ldconfig -r /emul/linux/ -p
> 
> gives too few entries.
> 
> This is because,
> 
> 	(1) It looks like linux binary expects d_off to fits signed
>             32bit value.  And it signal an error if the value didin't
>             back to extend to 64bit value.  Since I just read this
>             code roughly, I may be wrong though (glibc is hard to
>             read).

This is the only reason. glibc only has a 32bit value for something
that needs to be 64 bits over NFS. This is why directory offsets were
made 64 bits in userspace ages ago.

An NFS directory cookie is specified as an opaque 64 bit value for NFSv3,
and should thus *not* be interpreted by anything.

In other words, Linux (glibc, really) gets what it deserves when things
start failing because of this.

Your change may make things work in some cases, but it will make things
fail when you switch to, say, a 64bit big-endian server. The best way
to work around this issue is to use the -X option to mount_nfs, which
translates 64bit cookies to 32bit cookies to benefit broken behavior
like this.

I object to XDR-encoding the cookie, simply because the spec says that
it is opaque. And, like I said, it will make Linux binaries fail where
they worked before, if you had a big-endian NFS server.

- Frank