A nfsd patch

H.J. Lu (hjl@lucon.org)
Thu, 6 Aug 1998 21:30:11 -0700 (PDT)


>
> H.J. Lu wrote:
>
> > I think there is a bug in the NFS client code. When I compile it
> > and run it on a nfs dir, I get
> >
> > # gcc x.c
> > # df /net/ocean/linux
> > Filesystem 1024-blocks Used Available Capacity Mounted on
> > ocean:/home/work/linux
> > 2020332 1504283 511953 75% /net/ocean/linux
> > # a.out /net/ocean/linux
> > lseek: Operation not permitted
> > lseek is ok
> > # a.out /
> > lseek is ok
> > lseek is ok
>
> I'm seeing different results:
>
> [eastep@hozomeen eastep]$ df /mnt/apexroot
> Filesystem 1024-blocks Used Available Capacity Mounted on
> apex:/ 81944 39350 38362 51% /mnt/apexroot
> [eastep@hozomeen eastep]$ gcc x.c
> [eastep@hozomeen eastep]$ a.out /mnt/apexroot
> lseek is ok
> lseek is ok
> [eastep@hozomeen eastep]$ a.out /
> lseek is ok
> lseek is ok
> [eastep@hozomeen eastep]$
>
> hozomeen is running 2.1.115Pre4 -- apex is running 2.0.34.
>

Ok. The bug is in the NFS kernel daemon. It returns -1 as the file
offset at EOF. That is wrong. Linus, here is a patch.

Thanks.

H.J.

---
--- /home/work/linux/src/kernel/linux/fs/nfsd/vfs.c	Wed Jul 29 12:32:50 1998
+++ fs/nfsd/vfs.c	Thu Aug  6 21:21:12 1998
@@ -1159,8 +1159,12 @@ nfsd_readdir(struct svc_rqst *rqstp, str
 
 	/* Hewlett Packard ignores the eof flag on READDIR. Some
 	 * fs-specific readdir implementations seem to reset f_pos to 0
-	 * at EOF however, causing an endless loop. */
-	if (cd.offset && !eof)
+	 * at EOF however, causing an endless loop.
+	 *
+	 * We should always return the current offset in the directory
+	 * even if we are at EOF. Return -1 is wrong.
+	 */
+	if (cd.offset)
 		*cd.offset = htonl(file.f_pos);
 
 	p = cd.buffer;

- 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