Various changes lifted from the OpenBSD cvs tree:

txdr_hyper and fxdr_hyper tweaks to avoid excessive CPU order knowledge.

nfs_serv.c: don't call nfsm_adj() with negative values, windows clients
could crash servers when doing a readdir of a large directory.

nfs_socket.c: Use IP_PORTRANGE to get a priviliged port without a spin
loop trying to bind().  Don't clobber a mbuf pointer or we get panics
on a NFS3ERR_JUKEBOX error from a server when reusing a freed mbuf.

nfs_subs.c: Don't loose st_blocks on NFSv2 mounts when > 2GB.

Obtained from:  OpenBSD
This commit is contained in:
peter 1999-06-05 05:35:03 +00:00
parent 06a6a667a6
commit 21732dea0c
19 changed files with 228 additions and 165 deletions

View File

@ -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;

View File

@ -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)) { \

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_nqlease.c 8.9 (Berkeley) 5/20/95
* $Id: nfs_nqlease.c,v 1.40 1999/02/25 00:03:51 peter Exp $
* $Id: nfs_nqlease.c,v 1.41 1999/05/02 23:56:24 alc Exp $
*/
@ -772,7 +772,7 @@ nqnfsrv_getlease(nfsd, slp, procp, mrq)
nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(cache);
*tl++ = txdr_unsigned(nfsd->nd_duration);
txdr_hyper(&frev, tl);
txdr_hyper(frev, tl);
nfsm_build(fp, struct nfs_fattr *, NFSX_V3FATTR);
nfsm_srvfillattr(vap, fp);
nfsm_srvdone;
@ -893,7 +893,7 @@ nqnfs_getlease(vp, rwflag, cred, p)
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, rwflag, cachable, reqtime, frev);
nfsm_loadattr(vp, (struct vattr *)0);
} else

View File

@ -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 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
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 |

View File

@ -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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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;

View File

@ -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;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.82 1999/02/16 10:49:54 dfr Exp $
* $Id: nfs_vfsops.c,v 1.83 1999/04/10 18:53:29 peter Exp $
*/
#include <sys/param.h>
@ -291,11 +291,11 @@ nfs_statfs(mp, sbp, p)
sbp->f_iosize = nfs_iosize(nmp);
if (v3) {
sbp->f_bsize = NFS_FABLKSIZE;
fxdr_hyper(&sfp->sf_tbytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_tbytes);
sbp->f_blocks = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
fxdr_hyper(&sfp->sf_fbytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_fbytes);
sbp->f_bfree = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
fxdr_hyper(&sfp->sf_abytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_abytes);
sbp->f_bavail = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
sbp->f_files = (fxdr_unsigned(int32_t,
sfp->sf_tfiles.nfsuquad[1]) & 0x7fffffff);
@ -375,7 +375,7 @@ nfs_fsinfo(nmp, vp, cred, p)
if (nmp->nm_readdirsize == 0)
nmp->nm_readdirsize = max;
}
fxdr_hyper(&fsp->fs_maxfilesize, &maxfsize);
maxfsize = fxdr_hyper(&fsp->fs_maxfilesize);
if (maxfsize > 0 && maxfsize < nmp->nm_maxfilesize)
nmp->nm_maxfilesize = maxfsize;
nmp->nm_state |= NFSSTA_GOTFSINFO;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
* $Id: nfs_vnops.c,v 1.128 1999/05/06 20:00:30 phk Exp $
* $Id: nfs_vnops.c,v 1.129 1999/05/11 19:54:47 phk Exp $
*/
@ -1048,7 +1048,7 @@ nfs_readrpc(vp, uiop, cred)
nfsm_fhtom(vp, v3);
nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED * 3);
if (v3) {
txdr_hyper(&uiop->uio_offset, tl);
txdr_hyper(uiop->uio_offset, tl);
*(tl + 2) = txdr_unsigned(len);
} else {
*tl++ = txdr_unsigned(uiop->uio_offset);
@ -1115,7 +1115,7 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit)
nfsm_fhtom(vp, v3);
if (v3) {
nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
txdr_hyper(&uiop->uio_offset, tl);
txdr_hyper(uiop->uio_offset, tl);
tl += 2;
*tl++ = txdr_unsigned(len);
*tl++ = txdr_unsigned(*iomode);
@ -2075,7 +2075,7 @@ nfs_readdirrpc(vp, uiop, cred)
if (v3) {
nfsm_dissect(tl, u_int32_t *,
3 * NFSX_UNSIGNED);
fxdr_hyper(tl, &fileno);
fileno = fxdr_hyper(tl);
len = fxdr_unsigned(int, *(tl + 2));
} else {
nfsm_dissect(tl, u_int32_t *,
@ -2258,7 +2258,7 @@ nfs_readdirplusrpc(vp, uiop, cred)
/* loop thru the dir entries, doctoring them to 4bsd form */
while (more_dirs && bigenough) {
nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
fxdr_hyper(tl, &fileno);
fileno = fxdr_hyper(tl);
len = fxdr_unsigned(int, *(tl + 2));
if (len <= 0 || len > NFS_MAXNAMLEN) {
error = EBADRPC;
@ -2580,7 +2580,7 @@ nfs_commit(vp, offset, cnt, cred, procp)
nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1));
nfsm_fhtom(vp, 1);
nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
txdr_hyper(&offset, tl);
txdr_hyper(offset, tl);
tl += 2;
*tl = txdr_unsigned(cnt);
nfsm_request(vp, NFSPROC_COMMIT, procp, cred);

View File

@ -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)) { \

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95
* $Id: xdr_subs.h,v 1.9 1997/02/22 09:42:53 peter Exp $
* $Id: xdr_subs.h,v 1.10 1998/05/31 20:09:01 peter Exp $
*/
@ -79,13 +79,12 @@
((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \
}
#define fxdr_hyper(f, t) { \
((int32_t *)(t))[_QUAD_HIGHWORD] = ntohl(((int32_t *)(f))[0]); \
((int32_t *)(t))[_QUAD_LOWWORD] = ntohl(((int32_t *)(f))[1]); \
}
#define fxdr_hyper(f) \
((((u_quad_t)ntohl(((u_int32_t *)(f))[0])) << 32) | \
(u_quad_t)(ntohl(((u_int32_t *)(f))[1])))
#define txdr_hyper(f, t) { \
((int32_t *)(t))[0] = htonl(((int32_t *)(f))[_QUAD_HIGHWORD]); \
((int32_t *)(t))[1] = htonl(((int32_t *)(f))[_QUAD_LOWWORD]); \
((u_int32_t *)(t))[0] = htonl((u_int32_t)((f) >> 32)); \
((u_int32_t *)(t))[1] = htonl((u_int32_t)((f) & 0xffffffff)); \
}
#endif

View File

@ -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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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;

View File

@ -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;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.82 1999/02/16 10:49:54 dfr Exp $
* $Id: nfs_vfsops.c,v 1.83 1999/04/10 18:53:29 peter Exp $
*/
#include <sys/param.h>
@ -291,11 +291,11 @@ nfs_statfs(mp, sbp, p)
sbp->f_iosize = nfs_iosize(nmp);
if (v3) {
sbp->f_bsize = NFS_FABLKSIZE;
fxdr_hyper(&sfp->sf_tbytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_tbytes);
sbp->f_blocks = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
fxdr_hyper(&sfp->sf_fbytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_fbytes);
sbp->f_bfree = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
fxdr_hyper(&sfp->sf_abytes, &tquad);
tquad = fxdr_hyper(&sfp->sf_abytes);
sbp->f_bavail = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
sbp->f_files = (fxdr_unsigned(int32_t,
sfp->sf_tfiles.nfsuquad[1]) & 0x7fffffff);
@ -375,7 +375,7 @@ nfs_fsinfo(nmp, vp, cred, p)
if (nmp->nm_readdirsize == 0)
nmp->nm_readdirsize = max;
}
fxdr_hyper(&fsp->fs_maxfilesize, &maxfsize);
maxfsize = fxdr_hyper(&fsp->fs_maxfilesize);
if (maxfsize > 0 && maxfsize < nmp->nm_maxfilesize)
nmp->nm_maxfilesize = maxfsize;
nmp->nm_state |= NFSSTA_GOTFSINFO;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
* $Id: nfs_vnops.c,v 1.128 1999/05/06 20:00:30 phk Exp $
* $Id: nfs_vnops.c,v 1.129 1999/05/11 19:54:47 phk Exp $
*/
@ -1048,7 +1048,7 @@ nfs_readrpc(vp, uiop, cred)
nfsm_fhtom(vp, v3);
nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED * 3);
if (v3) {
txdr_hyper(&uiop->uio_offset, tl);
txdr_hyper(uiop->uio_offset, tl);
*(tl + 2) = txdr_unsigned(len);
} else {
*tl++ = txdr_unsigned(uiop->uio_offset);
@ -1115,7 +1115,7 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit)
nfsm_fhtom(vp, v3);
if (v3) {
nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
txdr_hyper(&uiop->uio_offset, tl);
txdr_hyper(uiop->uio_offset, tl);
tl += 2;
*tl++ = txdr_unsigned(len);
*tl++ = txdr_unsigned(*iomode);
@ -2075,7 +2075,7 @@ nfs_readdirrpc(vp, uiop, cred)
if (v3) {
nfsm_dissect(tl, u_int32_t *,
3 * NFSX_UNSIGNED);
fxdr_hyper(tl, &fileno);
fileno = fxdr_hyper(tl);
len = fxdr_unsigned(int, *(tl + 2));
} else {
nfsm_dissect(tl, u_int32_t *,
@ -2258,7 +2258,7 @@ nfs_readdirplusrpc(vp, uiop, cred)
/* loop thru the dir entries, doctoring them to 4bsd form */
while (more_dirs && bigenough) {
nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
fxdr_hyper(tl, &fileno);
fileno = fxdr_hyper(tl);
len = fxdr_unsigned(int, *(tl + 2));
if (len <= 0 || len > NFS_MAXNAMLEN) {
error = EBADRPC;
@ -2580,7 +2580,7 @@ nfs_commit(vp, offset, cnt, cred, procp)
nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1));
nfsm_fhtom(vp, 1);
nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
txdr_hyper(&offset, tl);
txdr_hyper(offset, tl);
tl += 2;
*tl = txdr_unsigned(cnt);
nfsm_request(vp, NFSPROC_COMMIT, procp, cred);

View File

@ -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)) { \

View File

@ -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 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
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 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
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 |

View File

@ -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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
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;

View File

@ -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;

View File

@ -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)) { \