diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2007-12-27 00:08:34 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2007-12-27 00:08:34 +0000 |
commit | 1213217fa85c10000d3c0a5b5d3a196ffdeb85f4 (patch) | |
tree | 63cfc2ba0fa12bd93dd2610c32eae2153d66788b /sys/nfs/nfs_serv.c | |
parent | ab9fcfa5fff17ceff5f0a5eb863625150f59639c (diff) |
Fix for PR5365.
Use the va_blocksize, that is the blocksize of the underlying exported
file system instead of the DIRBLKSIZ constant to size the chunks.
Diff from Enache Adrian <3n4ch3@gmail.com>
Tested by myself and a few others.
Diffstat (limited to 'sys/nfs/nfs_serv.c')
-rw-r--r-- | sys/nfs/nfs_serv.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 028a8292f50..043ff691c63 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.46 2007/11/08 19:20:09 blambert Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.47 2007/12/27 00:08:33 thib Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -2416,15 +2416,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); } - off = toff; - cnt = fxdr_unsigned(int, *tl); - siz = ((cnt + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); - xfer = NFS_SRVMAXDATA(nfsd); - if (siz > xfer) - siz = xfer; - if (cnt > xfer) - cnt = xfer; - fullsiz = siz; + error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); if (error) { @@ -2432,16 +2424,8 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(getret, &at); return (0); } - if (v3) { - error = getret = VOP_GETATTR(vp, &at, cred, procp); -#ifdef NFS3_STRICTVERF - /* - * XXX This check is too strict for Solaris 2.5 clients. - */ - if (!error && toff && verf != at.va_filerev) - error = NFSERR_BAD_COOKIE; -#endif - } + + error = getret = VOP_GETATTR(vp, &at, cred, procp); if (!error) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); if (error) { @@ -2450,6 +2434,16 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(getret, &at); return (0); } + + off = toff; + cnt = fxdr_unsigned(int, *tl); + siz = ((cnt + at.va_blocksize - 1) & ~(at.va_blocksize - 1)); + xfer = NFS_SRVMAXDATA(nfsd); + if (siz > xfer) + siz = xfer; + if (cnt > xfer) + cnt = xfer; + fullsiz = siz; VOP_UNLOCK(vp, 0, procp); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: @@ -2675,16 +2669,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) tl += 2; verf = fxdr_hyper(tl); tl += 2; - siz = fxdr_unsigned(int, *tl++); - cnt = fxdr_unsigned(int, *tl); - off = toff; - siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); - xfer = NFS_SRVMAXDATA(nfsd); - if (siz > xfer) - siz = xfer; - if (cnt > xfer) - cnt = xfer; - fullsiz = siz; + error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); if (error) { @@ -2692,25 +2677,28 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(getret, &at); return (0); } + error = getret = VOP_GETATTR(vp, &at, cred, procp); -#ifdef NFS3_STRICTVERF - /* - * XXX This check is too strict for Solaris 2.5 clients. - */ - if (!error && toff && verf != at.va_filerev) - error = NFSERR_BAD_COOKIE; -#endif - if (!error) { + if (!error) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); - } if (error) { vput(vp); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); } - VOP_UNLOCK(vp, 0, procp); + siz = fxdr_unsigned(int, *tl++); + cnt = fxdr_unsigned(int, *tl); + off = toff; + siz = ((siz + at.va_blocksize - 1) & ~(at.va_blocksize - 1)); + xfer = NFS_SRVMAXDATA(nfsd); + if (siz > xfer) + siz = xfer; + if (cnt > xfer) + cnt = xfer; + fullsiz = siz; + VOP_UNLOCK(vp, 0, procp); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; |