Messages in this thread Patch in this message |  | | | Date | Sun, 25 Jan 1998 11:26:02 -0500 | | From | Bill Hawes <> | | Subject | patch for 2.1.81 knfsd |
| |
This patch corrects a couple of problems in the nfsd readdir code pointed out by Olaf Kirch. In nfsd_proc_readdir, the test to limit the count to the user buffer size was comparing a count in words with a size in bytes. This would have passed too large a value, but a compensating error in nfsd_readdir divided the word count by 4 again.
The patch fixes the size calculation in both places so that the correct buffer size gets passed to the filldir function.
Regards, Bill--- linux-2.1.81/fs/nfsd/vfs.c.old Tue Jan 13 10:38:30 1998 +++ linux-2.1.81/fs/nfsd/vfs.c Sat Jan 24 12:33:33 1998 @@ -1041,7 +1041,7 @@ memset(&cd, 0, sizeof(cd)); cd.rqstp = rqstp; cd.buffer = buffer; - cd.buflen = *countp >> 2; + cd.buflen = *countp; /* count of words */ /* * Read the directory entries. This silly loop is necessary because --- linux-2.1.81/fs/nfsd/nfsproc.c.old Tue Jan 13 10:38:30 1998 +++ linux-2.1.81/fs/nfsd/nfsproc.c Sat Jan 24 12:33:33 1998 @@ -27,12 +27,6 @@ #define NFSDDBG_FACILITY NFSDDBG_PROC -#define sleep(msec) \ - { printk(KERN_NOTICE "nfsd: sleeping %d msecs\n", msec); \ - current->state = TASK_INTERRUPTIBLE; \ - current->timeout = jiffies + msec / 10; \ - schedule(); \ - } #define RETURN(st) return st static void @@ -298,11 +292,6 @@ * size, so that creat() behaves exactly like * open(..., O_CREAT|O_TRUNC|O_WRONLY). */ -#if 0 - /* N.B. What is this doing? ignores size?? */ - if ((attr->ia_valid &= ~(ATTR_SIZE)) != 0) - nfserr = nfsd_setattr(rqstp, newfhp, attr); -#endif attr->ia_valid &= ATTR_SIZE; if (attr->ia_valid) nfserr = nfsd_setattr(rqstp, newfhp, attr); @@ -435,22 +424,25 @@ u32 * buffer; int nfserr, count; - dprintk("nfsd: READDIR %p %d bytes at %d\n", - SVCFH_DENTRY(&argp->fh), + dprintk("nfsd: READDIR %d/%ld %d bytes at %d\n", + SVCFH_DEV(&argp->fh), SVCFH_INO(&argp->fh), argp->count, argp->cookie); /* Reserve buffer space for status */ svcbuf_reserve(&rqstp->rq_resbuf, &buffer, &count, 1); - /* Make sure we've room for the NULL ptr & eof flag, and shrink to - * client read size */ - if ((count -= 8) > argp->count) - count = argp->count; + /* Shrink to the client read size */ + if (count > (argp->count >> 2)) + count = argp->count >> 2; + + /* Make sure we've room for the NULL ptr & eof flag */ + count -= 2; + if (count < 0) + count = 0; /* Read directory and encode entries on the fly */ nfserr = nfsd_readdir(rqstp, &argp->fh, (loff_t) argp->cookie, - nfssvc_encode_entry, - buffer, &count); + nfssvc_encode_entry, buffer, &count); resp->count = count; fh_put(&argp->fh); --- linux-2.1.81/fs/nfsd/nfssvc.c.old Sat Jan 24 10:13:16 1998 +++ linux-2.1.81/fs/nfsd/nfssvc.c Sat Jan 24 12:33:32 1998 @@ -97,8 +97,8 @@ oldumask = current->fs->umask; /* Set umask to 0. */ current->fs->umask = 0; - nfssvc_boot = xtime; /* record boot time */ - nfsd_active++; + if (!nfsd_active++) + nfssvc_boot = xtime; /* record boot time */ lockd_up(); /* start lockd */ /* |  |