Re: diff -r fails on some NFS partitions under Linux 2.0.36pre6

Paul Eggert (eggert@twinsun.com)
Thu, 27 Aug 1998 23:45:59 -0700 (PDT)


Date: Thu, 27 Aug 1998 21:52:42 -0500
From: Chris Siebenmann <cks@hawkwind.utcs.toronto.edu>

Environment: diffutils 2.7 on a RedHat 5.1 (glibc 2.0.7-based) Linux
machine running kernel 2.0.36pre6....

lseek(3, 0, SEEK_CUR) = 0
getdents(3, /* 35 entries */, 7865) = 704
lseek(3, 0, SEEK_CUR) = -1 EINVAL (Invalid argument)

My guess is that your IRIX NFS server is returning a 32-bit cookie
with the top bit set; but the Linux kernel or C library incorrectly
reports an error if the cookie is ``negative'', because it incorrectly
thinks the NFS cookie is a file offset (it isn't; it's just a cookie).

possibly glibc should be fixing errno to be 0 as it returns from
readdir() in this situation;

This could be part of your problem, though it's hard to tell from your
description. A bug like this occurred in Solaris 2.6 (bug#4089406).
Solaris 2.6 lseek() is allowed to seek to a negative location for
remote file descriptors, but the Solaris C library incorrectly assumed
that negative lseeks are never allowed. This bug was fixed in Sun
patch 105210-02 (sparc) or later. The C library implementation of
readdir()/telldir() was modified to accept all 32-bit cookies, not
just those <= LONG_MAX.

Perhaps the kernel should be making the lseek() work;

That appears to be part of your problem. A bug similar to this
occurred in Solaris 2.6 (bug#4113636). The xdr_getrddirres() NFSv2
client code incorrectly discarded entries with negative cookies.
This bug was fixed in Sun patch 105720-03 (sparc) or later.

possibly diff is being overzealous in checking errno

No, diff is correct here. readdir is allowed to return errno values
other than EBADF; e.g. the Solaris 2.6 readdir is documented to return
EOVERFLOW and ENOENT as well as EBADF. diff should report an error
whenever readdir returns a null pointer and sets errno to a nonzero
value.

You don't mention whether your IRIX server has enabled NFSv3, which
has 64-bit cookies. (I believe that Linux doesn't support 64-bit
yet.) You also don't mention whether your IRIX server was running
with the -32bitclients option. These details might be helpful to the
Linux NFS client or C library hackers who have to fix this bug.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html