Fix an NFS server issue where it was not correctly setting the eof flag when a

READ had hit the end of the file. Also, clean up some cruft in the code.

Approved by:    re (kib)
Reviewed by:    rmacklem
MFC after:      2 weeks
This commit is contained in:
Zack Kirsch 2011-08-03 18:50:19 +00:00
parent 844537c1e0
commit 06521fbb49

View File

@ -620,7 +620,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram,
vnode_t vp, NFSPROC_T *p, struct nfsexstuff *exp)
{
u_int32_t *tl;
int error = 0, cnt, len, getret = 1, reqlen, eof = 0;
int error = 0, cnt, getret = 1, reqlen, eof = 0;
mbuf_t m2, m3;
struct nfsvattr nva;
off_t off = 0x0;
@ -714,11 +714,11 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram,
eof = 1;
} else if (reqlen == 0)
cnt = 0;
else if ((off + reqlen) > nva.na_size)
else if ((off + reqlen) >= nva.na_size) {
cnt = nva.na_size - off;
else
eof = 1;
} else
cnt = reqlen;
len = NFSM_RNDUP(cnt);
m3 = NULL;
if (cnt > 0) {
nd->nd_repstat = nfsvno_read(vp, off, cnt, nd->nd_cred, p,
@ -748,7 +748,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram,
*tl++ = txdr_unsigned(cnt);
} else
NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
if (len < reqlen || eof)
if (eof)
*tl++ = newnfs_true;
else
*tl++ = newnfs_false;