diff options
Diffstat (limited to 'sys/nfsserver')
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 56 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsock.c | 46 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 14 | ||||
-rw-r--r-- | sys/nfsserver/nfsm_subs.h | 6 |
4 files changed, 72 insertions, 50 deletions
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 7068050..c930c43 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 - * $Id: nfs_serv.c,v 1.76 1999/05/06 18:13:04 peter Exp $ + * $Id: nfs_serv.c,v 1.77 1999/05/11 19:54:45 phk Exp $ */ /* @@ -620,7 +620,7 @@ nfsrv_read(nfsd, slp, procp, mrq) nfsm_srvmtofh(fhp); if (v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - fxdr_hyper(tl, &off); + off = fxdr_hyper(tl); } else { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *tl); @@ -656,7 +656,7 @@ nfsrv_read(nfsd, slp, procp, mrq) if (off >= vap->va_size) cnt = 0; else if ((off + reqlen) > vap->va_size) - cnt = nfsm_rndup(vap->va_size - off); + cnt = vap->va_size - off; else cnt = reqlen; nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); @@ -670,7 +670,7 @@ nfsrv_read(nfsd, slp, procp, mrq) fp = (struct nfs_fattr *)tl; tl += (NFSX_V2FATTR / sizeof (u_int32_t)); } - len = left = cnt; + len = left = nfsm_rndup(cnt); if (cnt > 0) { /* * Generate the mbuf list with the uio_iov ref. to it. @@ -695,7 +695,7 @@ nfsrv_read(nfsd, slp, procp, mrq) M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; m = mb; - left = cnt; + left = len; i = 0; while (left > 0) { if (m == NULL) @@ -713,7 +713,7 @@ nfsrv_read(nfsd, slp, procp, mrq) } uiop->uio_iovcnt = i; uiop->uio_offset = off; - uiop->uio_resid = cnt; + uiop->uio_resid = len; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); @@ -732,18 +732,19 @@ nfsrv_read(nfsd, slp, procp, mrq) uiop->uio_resid = 0; vput(vp); nfsm_srvfillattr(vap, fp); - len -= uiop->uio_resid; - tlen = nfsm_rndup(len); - if (cnt != tlen || tlen != len) - nfsm_adj(mb, cnt - tlen, tlen - len); + tlen = len - uiop->uio_resid; + cnt = cnt < tlen ? cnt : tlen; + tlen = nfsm_rndup(cnt); + if (len != tlen || tlen != cnt) + nfsm_adj(mb, len - tlen, tlen - cnt); if (v3) { - *tl++ = txdr_unsigned(len); + *tl++ = txdr_unsigned(cnt); if (len < reqlen) *tl++ = nfs_true; else *tl++ = nfs_false; } - *tl = txdr_unsigned(len); + *tl = txdr_unsigned(cnt); nfsm_srvdone; } @@ -792,7 +793,7 @@ nfsrv_write(nfsd, slp, procp, mrq) nfsm_srvmtofh(fhp); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); - fxdr_hyper(tl, &off); + off = fxdr_hyper(tl); tl += 3; stable = fxdr_unsigned(int, *tl++); } else { @@ -997,7 +998,7 @@ nfsrv_writegather(ndp, slp, procp, mrq) nfsm_srvmtofh(&nfsd->nd_fh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); - fxdr_hyper(tl, &nfsd->nd_off); + nfsd->nd_off = fxdr_hyper(tl); tl += 3; nfsd->nd_stable = fxdr_unsigned(int, *tl++); } else { @@ -2530,13 +2531,14 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nfsm_srvmtofh(fhp); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); - fxdr_hyper(tl, &toff); + toff = fxdr_hyper(tl); tl += 2; - fxdr_hyper(tl, &verf); + verf = fxdr_hyper(tl); tl += 2; } else { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); + verf = 0; /* shut up gcc */ } off = toff; cnt = fxdr_unsigned(int, *tl); @@ -2624,7 +2626,7 @@ again: if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); - txdr_hyper(&at.va_filerev, tl); + txdr_hyper(at.va_filerev, tl); tl += 2; } else nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); @@ -2670,7 +2672,7 @@ again: if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - txdr_hyper(&at.va_filerev, tl); + txdr_hyper(at.va_filerev, tl); } mp = mp2 = mb; bp = bpos; @@ -2797,9 +2799,9 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); - fxdr_hyper(tl, &toff); + toff = fxdr_hyper(tl); tl += 2; - fxdr_hyper(tl, &verf); + verf = fxdr_hyper(tl); tl += 2; siz = fxdr_unsigned(int, *tl++); cnt = fxdr_unsigned(int, *tl); @@ -2884,7 +2886,7 @@ again: 2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); - txdr_hyper(&at.va_filerev, tl); + txdr_hyper(at.va_filerev, tl); tl += 2; *tl++ = nfs_false; *tl = nfs_true; @@ -2942,7 +2944,7 @@ again: nfsm_reply(cnt); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - txdr_hyper(&at.va_filerev, tl); + txdr_hyper(at.va_filerev, tl); mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); @@ -3111,7 +3113,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) * XXX At this time VOP_FSYNC() does not accept offset and byte * count parameters, so these arguments are useless (someday maybe). */ - fxdr_hyper(tl, &off); + off = fxdr_hyper(tl); tl += 2; cnt = fxdr_unsigned(int, *tl); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, @@ -3195,13 +3197,13 @@ nfsrv_statfs(nfsd, slp, procp, mrq) if (v3) { tval = (u_quad_t)sf->f_blocks; tval *= (u_quad_t)sf->f_bsize; - txdr_hyper(&tval, &sfp->sf_tbytes); + txdr_hyper(tval, &sfp->sf_tbytes); tval = (u_quad_t)sf->f_bfree; tval *= (u_quad_t)sf->f_bsize; - txdr_hyper(&tval, &sfp->sf_fbytes); + txdr_hyper(tval, &sfp->sf_fbytes); tval = (u_quad_t)sf->f_bavail; tval *= (u_quad_t)sf->f_bsize; - txdr_hyper(&tval, &sfp->sf_abytes); + txdr_hyper(tval, &sfp->sf_abytes); sfp->sf_tfiles.nfsuquad[0] = 0; sfp->sf_tfiles.nfsuquad[1] = txdr_unsigned(sf->f_files); sfp->sf_ffiles.nfsuquad[0] = 0; @@ -3286,7 +3288,7 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq) sip->fs_wtpref = txdr_unsigned(pref); sip->fs_wtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_dtpref = txdr_unsigned(pref); - txdr_hyper(&maxfsize, &sip->fs_maxfilesize); + txdr_hyper(maxfsize, &sip->fs_maxfilesize); sip->fs_timedelta.nfsv3_sec = 0; sip->fs_timedelta.nfsv3_nsec = txdr_unsigned(1); sip->fs_properties = txdr_unsigned(NFSV3FSINFO_LINK | diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c index 2267629..8949d7a 100644 --- a/sys/nfsserver/nfs_srvsock.c +++ b/sys/nfsserver/nfs_srvsock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_socket.c,v 1.51 1999/04/24 11:29:48 dt Exp $ + * $Id: nfs_socket.c,v 1.52 1999/05/02 23:56:25 alc Exp $ */ /* @@ -201,7 +201,6 @@ nfs_connect(nmp, rep) int s, error, rcvreserve, sndreserve; struct sockaddr *saddr; struct sockaddr_in *sin; - u_int16_t tport; struct proc *p = &proc0; /* only used for socreate and sobind */ nmp->nm_so = (struct socket *)0; @@ -217,18 +216,39 @@ nfs_connect(nmp, rep) * Some servers require that the client port be a reserved port number. */ if (saddr->sa_family == AF_INET && (nmp->nm_flag & NFSMNT_RESVPORT)) { + struct sockopt sopt; + int ip; struct sockaddr_in ssin; + + bzero(&sopt, sizeof sopt); + ip = IP_PORTRANGE_LOW; + sopt.sopt_dir = SOPT_SET; + sopt.sopt_level = IPPROTO_IP; + sopt.sopt_name = IP_PORTRANGE; + sopt.sopt_val = (void *)&ip; + sopt.sopt_valsize = sizeof(ip); + sopt.sopt_p = NULL; + error = sosetopt(so, &sopt); + if (error) + goto bad; bzero(&ssin, sizeof ssin); sin = &ssin; sin->sin_len = sizeof (struct sockaddr_in); sin->sin_family = AF_INET; sin->sin_addr.s_addr = INADDR_ANY; - tport = IPPORT_RESERVED - 1; - sin->sin_port = htons(tport); - while ((error = sobind(so, (struct sockaddr *)sin, p)) - == EADDRINUSE && - --tport > IPPORT_RESERVED / 2) - sin->sin_port = htons(tport); + sin->sin_port = htons(0); + error = sobind(so, (struct sockaddr *)sin, p); + if (error) + goto bad; + bzero(&sopt, sizeof sopt); + ip = IP_PORTRANGE_DEFAULT; + sopt.sopt_dir = SOPT_SET; + sopt.sopt_level = IPPROTO_IP; + sopt.sopt_name = IP_PORTRANGE; + sopt.sopt_val = (void *)&ip; + sopt.sopt_valsize = sizeof(ip); + sopt.sopt_p = NULL; + error = sosetopt(so, &sopt); if (error) goto bad; } @@ -908,7 +928,7 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) struct mbuf **mdp; caddr_t *dposp; { - register struct mbuf *m, *mrep; + register struct mbuf *m, *mrep, *m2; register struct nfsreq *rep; register u_int32_t *tl; register int i; @@ -1021,8 +1041,8 @@ tryagain: if (nmp->nm_soflags & PR_CONNREQUIRED) error = nfs_sndlock(rep); if (!error) { - m = m_copym(m, 0, M_COPYALL, M_WAIT); - error = nfs_send(nmp->nm_so, nmp->nm_nam, m, rep); + m2 = m_copym(m, 0, M_COPYALL, M_WAIT); + error = nfs_send(nmp->nm_so, nmp->nm_nam, m2, rep); if (nmp->nm_soflags & PR_CONNREQUIRED) nfs_sndunlock(rep); } @@ -1157,7 +1177,7 @@ tryagain: cachable = fxdr_unsigned(int, *tl++); reqtime += fxdr_unsigned(int, *tl++); if (reqtime > time_second) { - fxdr_hyper(tl, &frev); + frev = fxdr_hyper(tl); nqnfs_clientlease(nmp, np, nqlflag, cachable, reqtime, frev); } @@ -1317,7 +1337,7 @@ nfs_rephead(siz, nd, slp, err, cache, frev, mrq, mbp, bposp) *tl++ = txdr_unsigned(nd->nd_flag & ND_LEASE); *tl++ = txdr_unsigned(cache); *tl++ = txdr_unsigned(nd->nd_duration); - txdr_hyper(frev, tl); + txdr_hyper(*frev, tl); } else { nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = 0; diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 9a36211..fc0b1c8 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95 - * $Id: nfs_subs.c,v 1.73 1999/02/17 13:59:29 bde Exp $ + * $Id: nfs_subs.c,v 1.74 1999/05/11 19:54:46 phk Exp $ */ /* @@ -1345,9 +1345,9 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink); vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid); vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid); - fxdr_hyper(&fp->fa3_size, &vap->va_size); + vap->va_size = fxdr_hyper(&fp->fa3_size); vap->va_blocksize = NFS_FABLKSIZE; - fxdr_hyper(&fp->fa3_used, &vap->va_bytes); + vap->va_bytes = fxdr_hyper(&fp->fa3_used); vap->va_fileid = fxdr_unsigned(int32_t, fp->fa3_fileid.nfsuquad[1]); fxdr_nfsv3time(&fp->fa3_atime, &vap->va_atime); @@ -1360,7 +1360,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid); vap->va_size = fxdr_unsigned(u_int32_t, fp->fa2_size); vap->va_blocksize = fxdr_unsigned(int32_t, fp->fa2_blocksize); - vap->va_bytes = fxdr_unsigned(int32_t, fp->fa2_blocks) + vap->va_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks) * NFS_FABLKSIZE; vap->va_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid); fxdr_nfsv2time(&fp->fa2_atime, &vap->va_atime); @@ -1810,7 +1810,7 @@ nfsm_srvwcc(nfsd, before_ret, before_vap, after_ret, after_vap, mbp, bposp) } else { nfsm_build(tl, u_int32_t *, 7 * NFSX_UNSIGNED); *tl++ = nfs_true; - txdr_hyper(&(before_vap->va_size), tl); + txdr_hyper(before_vap->va_size, tl); tl += 2; txdr_nfsv3time(&(before_vap->va_mtime), tl); tl += 2; @@ -1860,8 +1860,8 @@ nfsm_srvfattr(nfsd, vap, fp) if (nfsd->nd_flag & ND_NFSV3) { fp->fa_type = vtonfsv3_type(vap->va_type); fp->fa_mode = vtonfsv3_mode(vap->va_mode); - txdr_hyper(&vap->va_size, &fp->fa3_size); - txdr_hyper(&vap->va_bytes, &fp->fa3_used); + txdr_hyper(vap->va_size, &fp->fa3_size); + txdr_hyper(vap->va_bytes, &fp->fa3_used); fp->fa3_rdev.specdata1 = txdr_unsigned(umajor(vap->va_rdev)); fp->fa3_rdev.specdata2 = txdr_unsigned(uminor(vap->va_rdev)); fp->fa3_fsid.nfsuquad[0] = 0; diff --git a/sys/nfsserver/nfsm_subs.h b/sys/nfsserver/nfsm_subs.h index 3692b7b..71d9f7b 100644 --- a/sys/nfsserver/nfsm_subs.h +++ b/sys/nfsserver/nfsm_subs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 - * $Id: nfsm_subs.h,v 1.21 1998/05/31 20:08:57 peter Exp $ + * $Id: nfsm_subs.h,v 1.22 1998/12/25 10:34:27 dfr Exp $ */ @@ -264,7 +264,7 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, if ((full) && (a)->va_size != VNOVAL) { \ nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ *tl++ = nfs_true; \ - txdr_hyper(&(a)->va_size, tl); \ + txdr_hyper((a)->va_size, tl); \ } else { \ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ *tl = nfs_false; \ @@ -479,7 +479,7 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ if (*tl == nfs_true) { \ nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - fxdr_hyper(tl, &(a)->va_size); \ + (a)->va_size = fxdr_hyper(tl); \ } \ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ switch (fxdr_unsigned(int, *tl)) { \ |