summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/nfs/nfs_bio.c105
-rw-r--r--sys/nfs/nfs_boot.c49
-rw-r--r--sys/nfs/nfs_node.c62
-rw-r--r--sys/nfs/nfs_nqlease.c54
-rw-r--r--sys/nfs/nfs_serv.c246
-rw-r--r--sys/nfs/nfs_socket.c80
-rw-r--r--sys/nfs/nfs_srvcache.c6
-rw-r--r--sys/nfs/nfs_subs.c63
-rw-r--r--sys/nfs/nfs_syscalls.c84
-rw-r--r--sys/nfs/nfs_var.h223
-rw-r--r--sys/nfs/nfs_vfsops.c47
-rw-r--r--sys/nfs/nfs_vnops.c461
-rw-r--r--sys/nfs/nfsdiskless.h9
-rw-r--r--sys/nfs/nfsm_subs.h25
-rw-r--r--sys/nfs/nfsmount.h66
-rw-r--r--sys/nfs/nfsnode.h106
-rw-r--r--sys/nfs/xdr_subs.h21
17 files changed, 1073 insertions, 634 deletions
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c
index 0476a70083d..3f194a4f50d 100644
--- a/sys/nfs/nfs_bio.c
+++ b/sys/nfs/nfs_bio.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_bio.c,v 1.21 1995/07/24 21:20:46 cgd Exp $ */
+/* $OpenBSD: nfs_bio.c,v 1.3 1996/02/29 09:24:48 niklas Exp $ */
+/* $NetBSD: nfs_bio.c,v 1.23 1996/02/09 21:48:19 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -47,6 +48,8 @@
#include <sys/trace.h>
#include <sys/mount.h>
#include <sys/kernel.h>
+#include <sys/namei.h>
+#include <sys/signalvar.h>
#include <vm/vm.h>
@@ -56,8 +59,8 @@
#include <nfs/nfs.h>
#include <nfs/nfsmount.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
-struct buf *incore(), *nfs_getcacheblk();
extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
extern int nfs_numasync;
@@ -65,6 +68,7 @@ extern int nfs_numasync;
* Vnode op for read using bio
* Any similarity to readip() is purely coincidental
*/
+int
nfs_bioread(vp, uio, ioflag, cred)
register struct vnode *vp;
register struct uio *uio;
@@ -73,13 +77,13 @@ nfs_bioread(vp, uio, ioflag, cred)
{
register struct nfsnode *np = VTONFS(vp);
register int biosize, diff;
- struct buf *bp, *rabp;
+ struct buf *bp = NULL, *rabp;
struct vattr vattr;
struct proc *p;
struct nfsmount *nmp;
daddr_t lbn, bn, rabn;
caddr_t baddr;
- int got_buf, nra, error = 0, n, on, not_readin;
+ int got_buf = 0, nra, error = 0, n = 0, on = 0, not_readin;
#ifdef lint
ioflag = ioflag;
@@ -118,22 +122,25 @@ nfs_bioread(vp, uio, ioflag, cred)
if (np->n_flag & NMODIFIED) {
if ((nmp->nm_flag & NFSMNT_MYWRITE) == 0 ||
vp->v_type != VREG) {
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
}
np->n_attrstamp = 0;
np->n_direofoffset = 0;
- if (error = VOP_GETATTR(vp, &vattr, cred, p))
+ error = VOP_GETATTR(vp, &vattr, cred, p);
+ if (error)
return (error);
- np->n_mtime = vattr.va_mtime.ts_sec;
+ np->n_mtime = vattr.va_mtime.tv_sec;
} else {
- if (error = VOP_GETATTR(vp, &vattr, cred, p))
+ if ((error = VOP_GETATTR(vp, &vattr, cred, p)) != 0)
return (error);
- if (np->n_mtime != vattr.va_mtime.ts_sec) {
+ if (np->n_mtime != vattr.va_mtime.tv_sec) {
np->n_direofoffset = 0;
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
- np->n_mtime = vattr.va_mtime.ts_sec;
+ np->n_mtime = vattr.va_mtime.tv_sec;
}
}
}
@@ -156,14 +163,16 @@ nfs_bioread(vp, uio, ioflag, cred)
np->n_direofoffset = 0;
cache_purge(vp);
}
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
np->n_brev = np->n_lrev;
}
} else if (vp->v_type == VDIR && (np->n_flag & NMODIFIED)) {
np->n_direofoffset = 0;
cache_purge(vp);
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
}
}
@@ -182,6 +191,13 @@ nfs_bioread(vp, uio, ioflag, cred)
case VDIR:
error = nfs_readdirrpc(vp, uio, cred);
break;
+ case VCHR:
+ case VSOCK:
+ case VFIFO:
+ case VBAD:
+ case VNON:
+ case VBLK:
+ break;
};
return (error);
}
@@ -237,7 +253,8 @@ again:
if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0) {
bp->b_flags |= B_READ;
not_readin = 0;
- if (error = nfs_doio(bp, cred, p)) {
+ error = nfs_doio(bp, cred, p);
+ if (error) {
brelse(bp);
return (error);
}
@@ -278,7 +295,7 @@ again:
return (EINTR);
if ((bp->b_flags & B_DONE) == 0) {
bp->b_flags |= B_READ;
- if (error = nfs_doio(bp, cred, p)) {
+ if ((error = nfs_doio(bp, cred, p)) != 0) {
brelse(bp);
return (error);
}
@@ -297,7 +314,7 @@ again:
return (EINTR);
if ((bp->b_flags & B_DONE) == 0) {
bp->b_flags |= B_READ;
- if (error = nfs_doio(bp, cred, p)) {
+ if ((error = nfs_doio(bp, cred, p)) != 0) {
brelse(bp);
return (error);
}
@@ -328,6 +345,13 @@ again:
n = min(uio->uio_resid, NFS_DIRBLKSIZ - bp->b_resid);
got_buf = 1;
break;
+ case VBAD:
+ case VSOCK:
+ case VCHR:
+ case VBLK:
+ case VNON:
+ case VFIFO:
+ break;
};
if (n > 0) {
@@ -342,6 +366,14 @@ again:
case VDIR:
uio->uio_offset = bp->b_blkno;
break;
+ case VREG:
+ case VBAD:
+ case VFIFO:
+ case VSOCK:
+ case VCHR:
+ case VBLK:
+ case VNON:
+ break;
};
if (got_buf)
brelse(bp);
@@ -352,14 +384,16 @@ again:
/*
* Vnode op for write using bio
*/
-nfs_write(ap)
+int
+nfs_write(v)
+ void *v;
+{
struct vop_write_args /* {
- struct vnode *a_vp;
+ struct vnode a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
+ } */ *ap = v;
register int biosize;
register struct uio *uio = ap->a_uio;
struct proc *p = uio->uio_procp;
@@ -388,12 +422,14 @@ nfs_write(ap)
if (ioflag & (IO_APPEND | IO_SYNC)) {
if (np->n_flag & NMODIFIED) {
np->n_attrstamp = 0;
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
}
if (ioflag & IO_APPEND) {
np->n_attrstamp = 0;
- if (error = VOP_GETATTR(vp, &vattr, cred, p))
+ error = VOP_GETATTR(vp, &vattr, cred, p);
+ if (error)
return (error);
uio->uio_offset = np->n_size;
}
@@ -438,7 +474,8 @@ nfs_write(ap)
return (error);
if (np->n_lrev != np->n_brev ||
(np->n_flag & NQNFSNONCACHE)) {
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
np->n_brev = np->n_lrev;
}
@@ -493,13 +530,15 @@ again:
if (np->n_lrev != np->n_brev ||
(np->n_flag & NQNFSNONCACHE)) {
brelse(bp);
- if (error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1))
+ error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
+ if (error)
return (error);
np->n_brev = np->n_lrev;
goto again;
}
}
- if (error = uiomove((char *)bp->b_data + on, n, uio)) {
+ error = uiomove((char *)bp->b_data + on, n, uio);
+ if (error) {
bp->b_flags |= B_ERROR;
brelse(bp);
return (error);
@@ -532,7 +571,7 @@ again:
*/
if ((np->n_flag & NQNFSNONCACHE) || (ioflag & IO_SYNC)) {
bp->b_proc = p;
- if (error = VOP_BWRITE(bp))
+ if ((error = VOP_BWRITE(bp)) != 0)
return (error);
} else if ((n + on) == biosize &&
(nmp->nm_flag & NFSMNT_NQNFS) == 0) {
@@ -577,6 +616,7 @@ nfs_getcacheblk(vp, bn, size, p)
* Flush and invalidate all dirty buffers. If another process is already
* doing the flush, just wait for completion.
*/
+int
nfs_vinvalbuf(vp, flags, cred, p, intrflg)
struct vnode *vp;
int flags;
@@ -637,6 +677,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg)
* This is mainly to avoid queueing async I/O requests when the nfsiods
* are all hung on a dead server.
*/
+int
nfs_asyncio(bp, cred)
register struct buf *bp;
struct ucred *cred;
@@ -674,14 +715,14 @@ nfs_asyncio(bp, cred)
int
nfs_doio(bp, cr, p)
register struct buf *bp;
- struct cred *cr;
+ struct ucred *cr;
struct proc *p;
{
register struct uio *uiop;
register struct vnode *vp;
struct nfsnode *np;
struct nfsmount *nmp;
- int error, diff, len;
+ int error = 0, diff, len;
struct uio uio;
struct iovec io;
@@ -753,7 +794,7 @@ nfs_doio(bp, cr, p)
NQNFS_CKINVALID(vp, np, NQL_READ) &&
np->n_lrev != np->n_brev) ||
(!(nmp->nm_flag & NFSMNT_NQNFS) &&
- np->n_mtime != np->n_vattr.va_mtime.ts_sec))) {
+ np->n_mtime != np->n_vattr.va_mtime.tv_sec))) {
uprintf("Process killed due to text file modification\n");
psignal(p, SIGKILL);
p->p_holdcnt++;
@@ -776,6 +817,12 @@ nfs_doio(bp, cr, p)
*/
bp->b_blkno = uiop->uio_offset;
break;
+ case VNON:
+ case VBLK:
+ case VCHR:
+ case VFIFO:
+ case VBAD:
+ case VSOCK:
};
if (error) {
bp->b_flags |= B_ERROR;
diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c
index 6e961f18114..130743a21a1 100644
--- a/sys/nfs/nfs_boot.c
+++ b/sys/nfs/nfs_boot.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_boot.c,v 1.20 1995/12/19 23:07:24 cgd Exp $ */
+/* $OpenBSD: nfs_boot.c,v 1.3 1996/02/29 09:24:49 niklas Exp $ */
+/* $NetBSD: nfs_boot.c,v 1.23 1996/02/13 17:53:33 gwr Exp $ */
/*
* Copyright (c) 1995 Adam Glass, Gordon Ross
@@ -51,6 +52,7 @@
#include <nfs/nfsdiskless.h>
#include <nfs/krpc.h>
#include <nfs/xdr_subs.h>
+#include <nfs/nfs_var.h>
#include "ether.h"
#if NETHER == 0
@@ -239,27 +241,29 @@ nfs_boot_init(nd, procp)
}
#endif
- get_path_and_handle(&bp_sin, "root", &nd->nd_root);
- get_path_and_handle(&bp_sin, "swap", &nd->nd_swap);
+ bcopy(&bp_sin, &nd->nd_boot, sizeof(bp_sin));
return (0);
}
-static void
-get_path_and_handle(bpsin, key, ndmntp)
+void
+nfs_boot_getfh(bpsin, key, ndmntp)
struct sockaddr_in *bpsin; /* bootparam server */
char *key; /* root or swap */
struct nfs_dlmount *ndmntp; /* output */
{
char pathname[MAXPATHLEN];
char *sp, *dp, *endp;
+ struct sockaddr_in *sin;
int error;
+ sin = &ndmntp->ndm_saddr;
+
/*
* Get server:pathname for "key" (root or swap)
* using RPC to bootparam/getfile
*/
- error = bp_getfile(bpsin, key, &ndmntp->ndm_saddr,
+ error = bp_getfile(bpsin, key, sin,
ndmntp->ndm_host, pathname);
if (error)
panic("nfs_boot: bootparam get %s: %d", key, error);
@@ -268,10 +272,16 @@ get_path_and_handle(bpsin, key, ndmntp)
* Get file handle for "key" (root or swap)
* using RPC to mountd/mount
*/
- error = md_mount(&ndmntp->ndm_saddr, pathname, ndmntp->ndm_fh);
+ error = md_mount(sin, pathname, ndmntp->ndm_fh);
if (error)
panic("nfs_boot: mountd %s, error=%d", key, error);
+ /* Set port number for NFS use. */
+ /* XXX: NFS port is always 2049, right? */
+ error = krpc_portmap(sin, NFS_PROG, NFS_VER2, &sin->sin_port);
+ if (error)
+ panic("nfs_boot: portmap NFS/v2, error=%d", error);
+
/* Construct remote path (for getmntinfo(3)) */
dp = ndmntp->ndm_host;
endp = dp + MNAMELEN - 1;
@@ -426,9 +436,13 @@ bp_getfile(bpsin, key, md_sin, serv_name, pathname)
/* client name (hostname) */
m = xdr_string_encode(hostname, hostnamelen);
+ if (m == NULL)
+ return (ENOMEM);
/* key name (root or swap) */
m->m_next = xdr_string_encode(key, strlen(key));
+ if (m->m_next == NULL)
+ return (ENOMEM);
/* RPC: bootparam/getfile */
error = krpc_call(bpsin, BOOTPARAM_PROG, BOOTPARAM_VERS,
@@ -502,6 +516,8 @@ md_mount(mdsin, path, fhp)
if (error) return error;
m = xdr_string_encode(path, strlen(path));
+ if (m == NULL)
+ return (ENOMEM);
/* Do RPC to mountd. */
error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1,
@@ -509,20 +525,23 @@ md_mount(mdsin, path, fhp)
if (error)
return error; /* message already freed */
+ /* The reply might have only the errno. */
+ if (m->m_len < 4)
+ goto bad;
+ /* Have at least errno, so check that. */
+ rdata = mtod(m, struct rdata *);
+ error = fxdr_unsigned(u_int32_t, rdata->errno);
+ if (error)
+ goto out;
+
+ /* Have errno==0, so the fh must be there. */
if (m->m_len < sizeof(*rdata)) {
m = m_pullup(m, sizeof(*rdata));
if (m == NULL)
goto bad;
+ rdata = mtod(m, struct rdata *);
}
- rdata = mtod(m, struct rdata *);
- error = fxdr_unsigned(u_int32_t, rdata->errno);
- if (error)
- goto bad;
bcopy(rdata->fh, fhp, NFS_FHSIZE);
-
- /* Set port number for NFS use. */
- error = krpc_portmap(mdsin, NFS_PROG, NFS_VER2,
- &mdsin->sin_port);
goto out;
bad:
diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c
index 70642f153ca..4a61b20f897 100644
--- a/sys/nfs/nfs_node.c
+++ b/sys/nfs/nfs_node.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_node.c,v 1.14 1995/12/19 23:07:27 cgd Exp $ */
+/* $OpenBSD: nfs_node.c,v 1.3 1996/02/29 09:24:50 niklas Exp $ */
+/* $NetBSD: nfs_node.c,v 1.15 1996/02/09 21:48:24 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -53,6 +54,7 @@
#include <nfs/nfsnode.h>
#include <nfs/nfsmount.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
#define NFSNOHASH(fhsum) \
(&nfsnodehashtbl[(fhsum) & nfsnodehash])
@@ -66,6 +68,7 @@ u_long nfsnodehash;
* Initialize hash links for nfsnodes
* and build nfsnode free list.
*/
+void
nfs_nhinit()
{
@@ -96,6 +99,7 @@ nfs_hash(fhp)
* In all cases, a pointer to a
* nfsnode structure is returned.
*/
+int
nfs_nget(mntp, fhp, npp)
struct mount *mntp;
register nfsv2fh_t *fhp;
@@ -104,7 +108,6 @@ nfs_nget(mntp, fhp, npp)
register struct nfsnode *np;
struct nfsnodehashhead *nhpp;
register struct vnode *vp;
- extern int (**nfsv2_vnodeop_p)();
struct vnode *nvp;
int error;
@@ -120,7 +123,8 @@ loop:
*npp = np;
return(0);
}
- if (error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &nvp)) {
+ error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &nvp);
+ if (error) {
*npp = 0;
return (error);
}
@@ -150,11 +154,13 @@ loop:
return (0);
}
-nfs_inactive(ap)
+int
+nfs_inactive(v)
+ void *v;
+{
struct vop_inactive_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct nfsnode *np;
register struct sillyrename *sp;
struct proc *p = curproc; /* XXX */
@@ -185,11 +191,13 @@ nfs_inactive(ap)
/*
* Reclaim an nfsnode so that it can be used for other purposes.
*/
-nfs_reclaim(ap)
+int
+nfs_reclaim(v)
+ void *v;
+{
struct vop_reclaim_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
register struct nfsmount *nmp = VFSTONFS(vp->v_mount);
@@ -214,11 +222,13 @@ nfs_reclaim(ap)
/*
* Lock an nfsnode
*/
-nfs_lock(ap)
+int
+nfs_lock(v)
+ void *v;
+{
struct vop_lock_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
/*
@@ -238,23 +248,30 @@ nfs_lock(ap)
/*
* Unlock an nfsnode
*/
-nfs_unlock(ap)
+int
+nfs_unlock(v)
+ void *v;
+{
+#if 0
struct vop_unlock_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
-
+ } */ *ap = v;
+#endif
return (0);
}
/*
* Check for a locked nfsnode
*/
-nfs_islocked(ap)
+int
+nfs_islocked(v)
+ void *v;
+{
+#if 0
struct vop_islocked_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (0);
}
@@ -265,12 +282,13 @@ nfs_islocked(ap)
*/
/* ARGSUSED */
int
-nfs_abortop(ap)
+nfs_abortop(v)
+ void *v;
+{
struct vop_abortop_args /* {
struct vnode *a_dvp;
struct componentname *a_cnp;
- } */ *ap;
-{
+ } */ *ap = v;
if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
FREE(ap->a_cnp->cn_pnbuf, M_NAMEI);
diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c
index 66106f6cfa2..c128d1793fd 100644
--- a/sys/nfs/nfs_nqlease.c
+++ b/sys/nfs/nfs_nqlease.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_nqlease.c,v 1.11 1995/12/19 23:07:29 cgd Exp $ */
+/* $OpenBSD: nfs_nqlease.c,v 1.3 1996/02/29 09:24:51 niklas Exp $ */
+/* $NetBSD: nfs_nqlease.c,v 1.12 1996/02/09 21:48:26 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -74,6 +75,7 @@
#include <nfs/nqnfs.h>
#include <nfs/nfsnode.h>
#include <nfs/nfsmount.h>
+#include <nfs/nfs_var.h>
time_t nqnfsstarttime = (time_t)0;
u_int32_t nqnfs_prog, nqnfs_vers;
@@ -81,11 +83,6 @@ int nqsrv_clockskew = NQ_CLOCKSKEW;
int nqsrv_writeslack = NQ_WRITESLACK;
int nqsrv_maxlease = NQ_MAXLEASE;
int nqsrv_maxnumlease = NQ_MAXNUMLEASE;
-void nqsrv_instimeq(), nqsrv_send_eviction(), nfs_sndunlock();
-void nqsrv_unlocklease(), nqsrv_waitfor_expiry(), nfsrv_slpderef();
-void nqsrv_addhost(), nqsrv_locklease(), nqnfs_serverd();
-void nqnfs_clientlease();
-struct mbuf *nfsm_rpchead();
/*
* Signifies which rpcs can have piggybacked lease requests
@@ -146,6 +143,7 @@ extern int nfsd_waiting;
* is when a new lease is being allocated, since it is not in the timer
* queue yet. (Ditto for the splsoftclock() and splx(s) calls)
*/
+int
nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred)
struct vnode *vp;
u_int *duration;
@@ -157,8 +155,8 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred)
struct ucred *cred;
{
register struct nqlease *lp;
- register struct nqfhhashhead *lpp;
- register struct nqhost *lph;
+ register struct nqfhhashhead *lpp = NULL;
+ register struct nqhost *lph = NULL;
struct nqlease *tlp;
struct nqm **lphp;
struct vattr vattr;
@@ -169,7 +167,7 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred)
return (0);
if (*duration > nqsrv_maxlease)
*duration = nqsrv_maxlease;
- if (error = VOP_GETATTR(vp, &vattr, cred, nd->nd_procp))
+ if ((error = VOP_GETATTR(vp, &vattr, cred, nd->nd_procp)) != 0)
return (error);
*frev = vattr.va_filerev;
s = splsoftclock();
@@ -181,7 +179,7 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred)
* Find the lease by searching the hash list.
*/
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- if (error = VFS_VPTOFH(vp, &fh.fh_fid)) {
+ if ((error = VFS_VPTOFH(vp, &fh.fh_fid)) != 0) {
splx(s);
return (error);
}
@@ -304,14 +302,16 @@ doreply:
* Local lease check for server syscalls.
* Just set up args and let nqsrv_getlease() do the rest.
*/
-lease_check(ap)
+int
+lease_check(v)
+ void *v;
+{
struct vop_lease_args /* {
struct vnode *a_vp;
struct proc *a_p;
struct ucred *a_cred;
int a_flag;
- } */ *ap;
-{
+ } */ *ap = v;
int duration = 0, cache;
struct nfsd nfsd;
u_quad_t frev;
@@ -320,6 +320,7 @@ lease_check(ap)
nfsd.nd_procp = ap->a_p;
(void) nqsrv_getlease(ap->a_vp, &duration, NQL_CHECK | ap->a_flag,
&nfsd, (struct mbuf *)0, &cache, &frev, ap->a_cred);
+ return 0;
}
/*
@@ -389,6 +390,7 @@ nqsrv_instimeq(lp, duration)
* This is somewhat messy due to the union in the nqhost structure.
* The local host is indicated by the special value of NQLOCALSLP for slp.
*/
+int
nqsrv_cmpnam(slp, nam, lph)
register struct nfssvc_sock *slp;
struct mbuf *nam;
@@ -586,7 +588,7 @@ tryagain:
void
nqnfs_serverd()
{
- register struct nqlease *lp, *lq;
+ register struct nqlease *lp;
register struct nqhost *lph;
struct nqlease *nextlp;
struct nqm *lphnext, *olphnext;
@@ -668,6 +670,7 @@ nqnfs_serverd()
* Do the from/to xdr translation and call nqsrv_getlease() to
* do the real work.
*/
+int
nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -694,8 +697,9 @@ nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED);
flags = fxdr_unsigned(int, *tl++);
nfsd->nd_duration = fxdr_unsigned(int, *tl);
- if (error = nfsrv_fhtovp(fhp,
- TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp,
+ TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
if (rdonly && flags == NQL_WRITE) {
error = EROFS;
@@ -719,6 +723,7 @@ nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq)
* Called from nfssvc_nfsd() when a "vacated" message is received from a
* client. Find the entry and expire it.
*/
+int
nqnfsrv_vacated(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -792,6 +797,7 @@ nfsmout:
/*
* Client get lease rpc function.
*/
+int
nqnfs_getlease(vp, rwflag, cred, p)
register struct vnode *vp;
int rwflag;
@@ -836,6 +842,7 @@ nqnfs_getlease(vp, rwflag, cred, p)
/*
* Client vacated message function.
*/
+int
nqnfs_vacated(vp, cred)
register struct vnode *vp;
struct ucred *cred;
@@ -881,6 +888,7 @@ nqnfs_vacated(vp, cred)
/*
* Called for client side callbacks
*/
+int
nqnfs_callback(nmp, mrep, md, dpos)
struct nfsmount *nmp;
struct mbuf *mrep, *md;
@@ -899,7 +907,7 @@ nqnfs_callback(nmp, mrep, md, dpos)
nd.nd_mrep = mrep;
nd.nd_md = md;
nd.nd_dpos = dpos;
- if (error = nfs_getreq(&nd, FALSE))
+ if ((error = nfs_getreq(&nd, FALSE)) != 0)
return (error);
md = nd.nd_md;
dpos = nd.nd_dpos;
@@ -910,7 +918,8 @@ nqnfs_callback(nmp, mrep, md, dpos)
fhp = &nfh.fh_generic;
nfsm_srvmtofh(fhp);
m_freem(mrep);
- if (error = nfs_nget(nmp->nm_mountp, fhp, &np))
+ error = nfs_nget(nmp->nm_mountp, (nfsv2fh_t *) fhp, &np);
+ if (error)
return (error);
vp = NFSTOV(np);
if (np->n_timer.cqe_next != 0) {
@@ -932,6 +941,7 @@ nqnfs_callback(nmp, mrep, md, dpos)
* "sleep" since nfs_reclaim() called from vclean() can pull a node off
* the list asynchronously.
*/
+int
nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
register struct nfsmount *nmp;
struct ucred *cred;
@@ -943,7 +953,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
register struct nfsnode *np;
struct vnode *vp;
struct nfsreq myrep;
- int error, vpid;
+ int error = 0, vpid;
/*
* First initialize some variables
@@ -999,13 +1009,15 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
while (np != (void *)&nmp->nm_timerhead &&
(nmp->nm_flag & NFSMNT_DISMINPROG) == 0) {
vp = NFSTOV(np);
-if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) panic("trash2");
+if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN))
+ panic("trash2");
vpid = vp->v_id;
if (np->n_expiry < time.tv_sec) {
if (vget(vp, 1) == 0) {
nmp->nm_inprog = vp;
if (vpid == vp->v_id) {
-if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) panic("trash3");
+if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN))
+ panic("trash3");
CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer);
np->n_timer.cqe_next = 0;
if ((np->n_flag & (NMODIFIED | NQNFSEVICTED))
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index c7b6b15d728..51c402b992e 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_serv.c,v 1.19 1995/12/19 23:07:32 cgd Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.3 1996/02/29 09:24:52 niklas Exp $ */
+/* $NetBSD: nfs_serv.c,v 1.22 1996/02/09 21:48:27 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -75,6 +76,7 @@
#include <nfs/xdr_subs.h>
#include <nfs/nfsm_subs.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
/* Defs */
#define TRUE 1
@@ -90,6 +92,7 @@ nfstype nfs_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON,
/*
* nqnfs access service
*/
+int
nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -103,7 +106,7 @@ nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq)
register u_int32_t *tl;
register int32_t t1;
caddr_t bpos;
- int error = 0, rdonly, cache, mode = 0;
+ int error = 0, rdonly, cache = 0, mode = 0;
char *cp2;
struct mbuf *mb, *mreq;
u_quad_t frev;
@@ -111,7 +114,8 @@ nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq)
fhp = &nfh.fh_generic;
nfsm_srvmtofh(fhp);
nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
if (*tl++ == nfs_true)
mode |= VREAD;
@@ -128,6 +132,7 @@ nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq)
/*
* nfs getattr service
*/
+int
nfsrv_getattr(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -150,7 +155,8 @@ nfsrv_getattr(nfsd, mrep, md, dpos, cred, nam, mrq)
fhp = &nfh.fh_generic;
nfsm_srvmtofh(fhp);
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
nqsrv_getl(vp, NQL_READ);
error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp);
@@ -164,6 +170,7 @@ nfsrv_getattr(nfsd, mrep, md, dpos, cred, nam, mrq)
/*
* nfs setattr service
*/
+int
nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -187,8 +194,10 @@ nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq)
fhp = &nfh.fh_generic;
nfsm_srvmtofh(fhp);
- nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL));
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ nfsm_dissect(sp, struct nfsv2_sattr *,
+ NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL));
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
nqsrv_getl(vp, NQL_WRITE);
VATTR_NULL(&va);
@@ -212,9 +221,9 @@ nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq)
#ifdef notyet
fxdr_nfstime(&sp->sa_nfsatime, &va.va_atime);
#else
- va.va_atime.ts_sec =
+ va.va_atime.tv_sec =
fxdr_unsigned(int32_t, sp->sa_nfsatime.nfs_sec);
- va.va_atime.ts_nsec = 0;
+ va.va_atime.tv_nsec = 0;
#endif
}
if (sp->sa_nfsmtime.nfs_sec != nfs_xdrneg1)
@@ -239,11 +248,11 @@ nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq)
if (vp->v_type == VDIR) {
error = EISDIR;
goto out;
- } else if (error = nfsrv_access(vp, VWRITE, cred, rdonly,
- nfsd->nd_procp))
+ } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly,
+ nfsd->nd_procp)) != 0)
goto out;
}
- if (error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) {
+ if ((error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) != 0) {
vput(vp);
nfsm_reply(0);
}
@@ -263,6 +272,7 @@ out:
/*
* nfs lookup rpc
*/
+int
nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -296,8 +306,8 @@ nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = LOOKUP;
nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ if ((error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp)) != 0)
nfsm_reply(0);
nqsrv_getl(nd.ni_startdir, NQL_READ);
vrele(nd.ni_startdir);
@@ -305,7 +315,7 @@ nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq)
vp = nd.ni_vp;
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) {
+ if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) {
vput(vp);
nfsm_reply(0);
}
@@ -336,6 +346,7 @@ nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq)
/*
* nfs readlink service
*/
+int
nfsrv_readlink(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -351,7 +362,7 @@ nfsrv_readlink(nfsd, mrep, md, dpos, cred, nam, mrq)
caddr_t bpos;
int error = 0, rdonly, cache, i, tlen, len;
char *cp2;
- struct mbuf *mb, *mb2, *mp2, *mp3, *mreq;
+ struct mbuf *mb, *mb2, *mp2 = NULL, *mp3 = NULL, *mreq;
struct vnode *vp;
nfsv2fh_t nfh;
fhandle_t *fhp;
@@ -389,7 +400,8 @@ nfsrv_readlink(nfsd, mrep, md, dpos, cred, nam, mrq)
uiop->uio_rw = UIO_READ;
uiop->uio_segflg = UIO_SYSSPACE;
uiop->uio_procp = (struct proc *)0;
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) {
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error) {
m_freem(mp3);
nfsm_reply(0);
}
@@ -418,6 +430,7 @@ out:
/*
* nfs read service
*/
+int
nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -454,7 +467,8 @@ nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq)
fxdr_hyper(tl, &off);
}
nfsm_srvstrsiz(cnt, NFS_MAXDATA);
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
if (vp->v_type != VREG) {
error = (vp->v_type == VDIR) ? EISDIR : EACCES;
@@ -462,12 +476,16 @@ nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_reply(0);
}
nqsrv_getl(vp, NQL_READ);
- if ((error = nfsrv_access(vp, VREAD, cred, rdonly, nfsd->nd_procp)) &&
- (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp))) {
- vput(vp);
- nfsm_reply(0);
- }
- if (error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp)) {
+ error = nfsrv_access(vp, VREAD, cred, rdonly, nfsd->nd_procp);
+ if (error)
+ goto out;
+ error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp);
+ if (error)
+ goto out;
+ error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp);
+
+ if (error) {
+out:
vput(vp);
nfsm_reply(0);
}
@@ -537,6 +555,7 @@ nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq)
/*
* nfs write service
*/
+int
nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -592,7 +611,8 @@ nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)
mp->m_len -= siz;
NFSMADV(mp, siz);
}
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
if (vp->v_type != VREG) {
error = (vp->v_type == VDIR) ? EISDIR : EACCES;
@@ -600,7 +620,8 @@ nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_reply(0);
}
nqsrv_getl(vp, NQL_WRITE);
- if (error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp)) {
+ error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp);
+ if (error) {
vput(vp);
nfsm_reply(0);
}
@@ -643,7 +664,7 @@ nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_reply(0);
}
uiop->uio_resid = siz;
- if (error = VOP_WRITE(vp, uiop, ioflags, cred)) {
+ if ((error = VOP_WRITE(vp, uiop, ioflags, cred)) != 0) {
vput(vp);
nfsm_reply(0);
}
@@ -665,6 +686,7 @@ nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)
* nfs create service
* now does a truncate to 0 length via. setattr if it already exists
*/
+int
nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -683,7 +705,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
int error = 0, rdev, cache, len, tsize;
char *cp2;
struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp;
+ struct vnode *vp = NULL;
nfsv2fh_t nfh;
fhandle_t *fhp;
u_quad_t frev;
@@ -695,8 +717,9 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
nfsm_reply(0);
VATTR_NULL(&va);
nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL));
@@ -717,7 +740,9 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
if (va.va_type == VREG || va.va_type == VSOCK) {
vrele(nd.ni_startdir);
nqsrv_getl(nd.ni_dvp, NQL_WRITE);
- if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va))
+ error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd,
+ &va);
+ if (error)
nfsm_reply(0);
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
} else if (va.va_type == VCHR || va.va_type == VBLK ||
@@ -731,14 +756,16 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
error = ENXIO;
goto out;
#endif /* FIFO */
- } else if (error = suser(cred, (u_short *)0)) {
+ } else if ((error = suser(cred, (u_short *)0)) != 0) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
vput(nd.ni_dvp);
goto out;
} else
va.va_rdev = (dev_t)rdev;
nqsrv_getl(nd.ni_dvp, NQL_WRITE);
- if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) {
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd,
+ &va);
+ if (error) {
vrele(nd.ni_startdir);
nfsm_reply(0);
}
@@ -746,7 +773,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
nd.ni_cnd.cn_proc = nfsd->nd_procp;
nd.ni_cnd.cn_cred = nfsd->nd_procp->p_ucred;
- if (error = lookup(&nd)) {
+ if ((error = lookup(&nd)) != 0) {
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
nfsm_reply(0);
}
@@ -783,13 +810,16 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
} else
fxdr_hyper(&sp->sa_nqsize, &va.va_size);
if (va.va_size != -1) {
- if (error = nfsrv_access(vp, VWRITE, cred,
- (nd.ni_cnd.cn_flags & RDONLY), nfsd->nd_procp)) {
+ error = nfsrv_access(vp, VWRITE, cred,
+ (nd.ni_cnd.cn_flags & RDONLY),
+ nfsd->nd_procp);
+ if (error) {
vput(vp);
nfsm_reply(0);
}
nqsrv_getl(vp, NQL_WRITE);
- if (error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) {
+ error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp);
+ if (error) {
vput(vp);
nfsm_reply(0);
}
@@ -797,7 +827,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
}
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) {
+ if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) {
vput(vp);
nfsm_reply(0);
}
@@ -824,11 +854,13 @@ out:
vrele(nd.ni_startdir);
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
nfsm_reply(0);
+ return 0;
}
/*
* nfs remove service
*/
+int
nfsrv_remove(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -854,35 +886,30 @@ nfsrv_remove(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = DELETE;
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
nfsm_reply(0);
vp = nd.ni_vp;
- if (vp->v_type == VDIR &&
- (error = suser(cred, (u_short *)0)))
- goto out;
/*
* The root of a mounted filesystem cannot be deleted.
*/
if (vp->v_flag & VROOT) {
- error = EBUSY;
- goto out;
- }
- if (vp->v_flag & VTEXT)
- (void) vnode_pager_uncache(vp);
-out:
- if (!error) {
- nqsrv_getl(nd.ni_dvp, NQL_WRITE);
- nqsrv_getl(vp, NQL_WRITE);
- error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- } else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == vp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
vput(vp);
+ error = EBUSY;
+ goto out;
}
+ if (vp->v_flag & VTEXT)
+ (void) vnode_pager_uncache(vp);
+ nqsrv_getl(nd.ni_dvp, NQL_WRITE);
+ nqsrv_getl(vp, NQL_WRITE);
+ error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
+out:
nfsm_reply(0);
nfsm_srvdone;
}
@@ -890,6 +917,7 @@ out:
/*
* nfs rename service
*/
+int
nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -904,7 +932,7 @@ nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq)
char *cp2;
struct mbuf *mb, *mreq;
struct nameidata fromnd, tond;
- struct vnode *fvp, *tvp, *tdvp;
+ struct vnode *fvp = NULL, *tvp, *tdvp;
nfsv2fh_t fnfh, tnfh;
fhandle_t *ffhp, *tfhp;
u_quad_t frev;
@@ -924,8 +952,9 @@ nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq)
fromnd.ni_cnd.cn_cred = cred;
fromnd.ni_cnd.cn_nameiop = DELETE;
fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART;
- if (error = nfs_namei(&fromnd, ffhp, len, nfsd->nd_slp, nam, &md,
- &dpos, nfsd->nd_procp))
+ error = nfs_namei(&fromnd, ffhp, len, nfsd->nd_slp, nam, &md,
+ &dpos, nfsd->nd_procp);
+ if (error)
nfsm_reply(0);
fvp = fromnd.ni_vp;
nfsm_srvmtofh(tfhp);
@@ -934,8 +963,9 @@ nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq)
tond.ni_cnd.cn_cred = cred;
tond.ni_cnd.cn_nameiop = RENAME;
tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART;
- if (error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md,
- &dpos, nfsd->nd_procp)) {
+ error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md,
+ &dpos, nfsd->nd_procp);
+ if (error) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@@ -1022,6 +1052,7 @@ nfsmout:
/*
* nfs link service
*/
+int
nfsrv_link(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1036,7 +1067,7 @@ nfsrv_link(nfsd, mrep, md, dpos, cred, nam, mrq)
int error = 0, rdonly, cache, len;
char *cp2;
struct mbuf *mb, *mreq;
- struct vnode *vp, *xp;
+ struct vnode *vp;
nfsv2fh_t nfh, dnfh;
fhandle_t *fhp, *dfhp;
u_quad_t frev;
@@ -1046,39 +1077,30 @@ nfsrv_link(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_srvmtofh(fhp);
nfsm_srvmtofh(dfhp);
nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
- if (error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
- if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0)))
- goto out1;
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
- if (error = nfs_namei(&nd, dfhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
- goto out1;
- xp = nd.ni_vp;
- if (xp != NULL) {
- error = EEXIST;
+ error = nfs_namei(&nd, dfhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
goto out;
- }
- xp = nd.ni_dvp;
- if (vp->v_mount != xp->v_mount)
- error = EXDEV;
-out:
- if (!error) {
- nqsrv_getl(vp, NQL_WRITE);
- nqsrv_getl(xp, NQL_WRITE);
- error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
- } else {
+ if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
- if (nd.ni_vp)
- vrele(nd.ni_vp);
+ vrele(nd.ni_vp);
+ error = EEXIST;
+ goto out;
}
-out1:
+ nqsrv_getl(nd.ni_dvp, NQL_WRITE);
+ nqsrv_getl(vp, NQL_WRITE);
+ error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
+out:
vrele(vp);
nfsm_reply(0);
nfsm_srvdone;
@@ -1087,6 +1109,7 @@ out1:
/*
* nfs symbolic link service
*/
+int
nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1116,8 +1139,9 @@ nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
goto out;
nfsm_strsiz(len2, NFS_MAXPATHLEN);
MALLOC(pathcp, caddr_t, len2 + 1, M_TEMP, M_WAITOK);
@@ -1168,6 +1192,7 @@ nfsmout:
/*
* nfs mkdir service
*/
+int
nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1196,8 +1221,9 @@ nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
nfsm_reply(0);
nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
VATTR_NULL(&va);
@@ -1215,12 +1241,12 @@ nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
nfsm_reply(0);
}
nqsrv_getl(nd.ni_dvp, NQL_WRITE);
- if (error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va))
+ if ((error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) != 0)
nfsm_reply(0);
vp = nd.ni_vp;
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) {
+ if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) {
vput(vp);
nfsm_reply(0);
}
@@ -1245,6 +1271,7 @@ nfsmout:
/*
* nfs rmdir service
*/
+int
nfsrv_rmdir(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1270,8 +1297,9 @@ nfsrv_rmdir(nfsd, mrep, md, dpos, cred, nam, mrq)
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = DELETE;
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
- if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
- nfsd->nd_procp))
+ error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos,
+ nfsd->nd_procp);
+ if (error)
nfsm_reply(0);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@@ -1344,6 +1372,7 @@ struct flrep {
u_int32_t fl_fattr[NFSX_NQFATTR / sizeof (u_int32_t)];
};
+int
nfsrv_readdir(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1353,7 +1382,7 @@ nfsrv_readdir(nfsd, mrep, md, dpos, cred, nam, mrq)
{
register char *bp, *be;
register struct mbuf *mp;
- register struct dirent *dp;
+ register struct dirent *dp = NULL;
register caddr_t cp;
register u_int32_t *tl;
register int32_t t1;
@@ -1381,10 +1410,12 @@ nfsrv_readdir(nfsd, mrep, md, dpos, cred, nam, mrq)
siz = NFS_MAXREADDIR;
fullsiz = siz;
ncookies = siz / 16; /* Guess at the number of cookies needed. */
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
nqsrv_getl(vp, NQL_READ);
- if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) {
+ error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp);
+ if (error) {
vput(vp);
nfsm_reply(0);
}
@@ -1527,6 +1558,7 @@ again:
nfsm_srvdone;
}
+int
nqnfsrv_readdirlook(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1536,7 +1568,7 @@ nqnfsrv_readdirlook(nfsd, mrep, md, dpos, cred, nam, mrq)
{
register char *bp, *be;
register struct mbuf *mp;
- register struct dirent *dp;
+ register struct dirent *dp = NULL;
register caddr_t cp;
register u_int32_t *tl;
register int32_t t1;
@@ -1568,10 +1600,12 @@ nqnfsrv_readdirlook(nfsd, mrep, md, dpos, cred, nam, mrq)
siz = NFS_MAXREADDIR;
fullsiz = siz;
ncookies = siz / 16; /* Guess at the number of cookies needed. */
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
nqsrv_getl(vp, NQL_READ);
- if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) {
+ error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp);
+ if (error) {
vput(vp);
nfsm_reply(0);
}
@@ -1766,6 +1800,7 @@ invalid:
/*
* nfs statfs service
*/
+int
nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1778,7 +1813,7 @@ nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq)
register u_int32_t *tl;
register int32_t t1;
caddr_t bpos;
- int error = 0, rdonly, cache, isnq;
+ int error = 0, rdonly, cache = 0, isnq;
char *cp2;
struct mbuf *mb, *mb2, *mreq;
struct vnode *vp;
@@ -1790,7 +1825,8 @@ nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq)
fhp = &nfh.fh_generic;
isnq = (nfsd->nd_nqlflag != NQL_NOVAL);
nfsm_srvmtofh(fhp);
- if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);
+ if (error)
nfsm_reply(0);
sf = &statfs;
error = VFS_STATFS(vp->v_mount, sf, nfsd->nd_procp);
@@ -1813,6 +1849,7 @@ nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq)
* Null operation, used by clients to ping server
*/
/* ARGSUSED */
+int
nfsrv_null(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1821,7 +1858,7 @@ nfsrv_null(nfsd, mrep, md, dpos, cred, nam, mrq)
struct mbuf *nam, **mrq;
{
caddr_t bpos;
- int error = VNOVAL, cache;
+ int error = VNOVAL, cache = 0;
struct mbuf *mb, *mreq;
u_quad_t frev;
@@ -1833,6 +1870,7 @@ nfsrv_null(nfsd, mrep, md, dpos, cred, nam, mrq)
* No operation, used for obsolete procedures
*/
/* ARGSUSED */
+int
nfsrv_noop(nfsd, mrep, md, dpos, cred, nam, mrq)
struct nfsd *nfsd;
struct mbuf *mrep, *md;
@@ -1841,7 +1879,7 @@ nfsrv_noop(nfsd, mrep, md, dpos, cred, nam, mrq)
struct mbuf *nam, **mrq;
{
caddr_t bpos;
- int error, cache;
+ int error, cache = 0;
struct mbuf *mb, *mreq;
u_quad_t frev;
@@ -1863,6 +1901,7 @@ nfsrv_noop(nfsd, mrep, md, dpos, cred, nam, mrq)
* this because it opens a security hole, but since the nfs server opens
* a security hole the size of a barn door anyhow, what the heck.
*/
+int
nfsrv_access(vp, flags, cred, rdonly, p)
register struct vnode *vp;
int flags;
@@ -1883,6 +1922,13 @@ nfsrv_access(vp, flags, cred, rdonly, p)
switch (vp->v_type) {
case VREG: case VDIR: case VLNK:
return (EROFS);
+ case VNON:
+ case VBLK:
+ case VCHR:
+ case VSOCK:
+ case VFIFO:
+ case VBAD:
+ break;
}
}
/*
@@ -1893,7 +1939,7 @@ nfsrv_access(vp, flags, cred, rdonly, p)
if ((vp->v_flag & VTEXT) && !vnode_pager_uncache(vp))
return (ETXTBSY);
}
- if (error = VOP_GETATTR(vp, &vattr, cred, p))
+ if ((error = VOP_GETATTR(vp, &vattr, cred, p)) != 0)
return (error);
if ((error = VOP_ACCESS(vp, flags, cred, p)) &&
cred->cr_uid != vattr.va_uid)
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 909da6378d3..84bc8cb97e4 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_socket.c,v 1.22 1995/12/19 23:07:38 cgd Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.3 1996/02/29 09:24:53 niklas Exp $ */
+/* $NetBSD: nfs_socket.c,v 1.23 1996/02/09 21:48:29 christos Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -55,6 +56,7 @@
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/tprintf.h>
+#include <sys/namei.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -67,6 +69,7 @@
#include <nfs/nfsnode.h>
#include <nfs/nfsrtt.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
#define TRUE 1
#define FALSE 0
@@ -153,10 +156,6 @@ static int proct[NFS_NPROCS] = {
#define NFS_CWNDSCALE 256
#define NFS_MAXCWND (NFS_CWNDSCALE * 32)
static int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256, };
-int nfs_sbwait();
-void nfs_disconnect(), nfs_realign(), nfsrv_wakenfsd(), nfs_sndunlock();
-void nfs_rcvunlock(), nqnfs_serverd(), nqnfs_clientlease();
-struct mbuf *nfsm_rpchead();
int nfsrtton = 0;
struct nfsrtt nfsrtt;
@@ -164,6 +163,7 @@ struct nfsrtt nfsrtt;
* Initialize sockets and congestion for a new NFS connection.
* We do not free the sockaddr if error.
*/
+int
nfs_connect(nmp, rep)
register struct nfsmount *nmp;
struct nfsreq *rep;
@@ -177,8 +177,9 @@ nfs_connect(nmp, rep)
nmp->nm_so = (struct socket *)0;
saddr = mtod(nmp->nm_nam, struct sockaddr *);
- if (error = socreate(saddr->sa_family,
- &nmp->nm_so, nmp->nm_sotype, nmp->nm_soproto))
+ error = socreate(saddr->sa_family,
+ &nmp->nm_so, nmp->nm_sotype, nmp->nm_soproto);
+ if (error)
goto bad;
so = nmp->nm_so;
nmp->nm_soflags = so->so_proto->pr_flags;
@@ -212,7 +213,7 @@ nfs_connect(nmp, rep)
goto bad;
}
} else {
- if (error = soconnect(so, nmp->nm_nam))
+ if ((error = soconnect(so, nmp->nm_nam)) != 0)
goto bad;
/*
@@ -273,7 +274,7 @@ nfs_connect(nmp, rep)
rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
}
- if (error = soreserve(so, sndreserve, rcvreserve))
+ if ((error = soreserve(so, sndreserve, rcvreserve)) != 0)
goto bad;
so->so_rcv.sb_flags |= SB_NOINTR;
so->so_snd.sb_flags |= SB_NOINTR;
@@ -302,6 +303,7 @@ bad:
* If this fails the mount point is DEAD!
* nb: Must be called with the nfs_sndlock() set on the mount point.
*/
+int
nfs_reconnect(rep)
register struct nfsreq *rep;
{
@@ -310,7 +312,7 @@ nfs_reconnect(rep)
int error;
nfs_disconnect(nmp);
- while (error = nfs_connect(nmp, rep)) {
+ while ((error = nfs_connect(nmp, rep)) != 0) {
if (error == EINTR || error == ERESTART)
return (EINTR);
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfscon", 0);
@@ -357,6 +359,7 @@ nfs_disconnect(nmp)
* - return EPIPE if a connection is lost for connection based sockets (TCP...)
* - do any cleanup required by recoverable socket errors (???)
*/
+int
nfs_send(so, nam, top, rep)
register struct socket *so;
struct mbuf *nam;
@@ -425,6 +428,7 @@ nfs_send(so, nam, top, rep)
* For SOCK_STREAM we must be very careful to read an entire record once
* we have read any of it, even if the system call has been interrupted.
*/
+int
nfs_receive(rep, aname, mp)
register struct nfsreq *rep;
struct mbuf **aname;
@@ -456,7 +460,7 @@ nfs_receive(rep, aname, mp)
* until we have an entire rpc request/reply.
*/
if (sotype != SOCK_DGRAM) {
- if (error = nfs_sndlock(&rep->r_nmp->nm_flag, rep))
+ if ((error = nfs_sndlock(&rep->r_nmp->nm_flag, rep)) != 0)
return (error);
tryagain:
/*
@@ -473,7 +477,7 @@ tryagain:
return (EINTR);
}
if ((so = rep->r_nmp->nm_so) == NULL) {
- if (error = nfs_reconnect(rep)) {
+ if ((error = nfs_reconnect(rep)) != 0) {
nfs_sndunlock(&rep->r_nmp->nm_flag);
return (error);
}
@@ -482,7 +486,8 @@ tryagain:
while (rep->r_flags & R_MUSTRESEND) {
m = m_copym(rep->r_mreq, 0, M_COPYALL, M_WAIT);
nfsstats.rpcretries++;
- if (error = nfs_send(so, rep->r_nmp->nm_nam, m, rep)) {
+ error = nfs_send(so, rep->r_nmp->nm_nam, m, rep);
+ if (error) {
if (error == EINTR || error == ERESTART ||
(error = nfs_reconnect(rep))) {
nfs_sndunlock(&rep->r_nmp->nm_flag);
@@ -631,6 +636,7 @@ errout:
* with outstanding requests using the xid, until ours is found.
*/
/* ARGSUSED */
+int
nfs_reply(myrep)
struct nfsreq *myrep;
{
@@ -652,7 +658,7 @@ nfs_reply(myrep)
* Also necessary for connection based protocols to avoid
* race conditions during a reconnect.
*/
- if (error = nfs_rcvlock(myrep))
+ if ((error = nfs_rcvlock(myrep)) != 0)
return (error);
/* Already received, bye bye */
if (myrep->r_mrep != NULL) {
@@ -796,6 +802,7 @@ nfsmout:
* by mrep or error
* nb: always frees up mreq mbuf list
*/
+int
nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
struct vnode *vp;
struct mbuf *mrest;
@@ -812,7 +819,6 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
register int i;
struct nfsmount *nmp;
struct mbuf *md, *mheadend;
- struct nfsreq *reph;
struct nfsnode *np;
time_t reqtime, waituntil;
caddr_t dpos, cp2;
@@ -1065,6 +1071,7 @@ nfsmout:
* Generate the rpc reply header
* siz arg. is used to decide if adding a cluster is worthwhile
*/
+int
nfs_rephead(siz, nd, err, cache, frev, mrq, mbp, bposp)
int siz;
struct nfsd *nd;
@@ -1178,7 +1185,9 @@ nfs_timer(arg)
register struct socket *so;
register struct nfsmount *nmp;
register int timeo;
+#ifdef NFSSERVER
static long lasttime = 0;
+#endif
int s, error;
s = splsoftnet();
@@ -1286,6 +1295,7 @@ nfs_timer(arg)
* Test for a termination condition pending on the process.
* This is used for NFSMNT_INT mounts.
*/
+int
nfs_sigintr(nmp, rep, p)
struct nfsmount *nmp;
struct nfsreq *rep;
@@ -1309,6 +1319,7 @@ nfs_sigintr(nmp, rep, p)
* and also to avoid race conditions between the processes with nfs requests
* in progress when a reconnect is necessary.
*/
+int
nfs_sndlock(flagp, rep)
register int *flagp;
struct nfsreq *rep;
@@ -1354,6 +1365,7 @@ nfs_sndunlock(flagp)
}
}
+int
nfs_rcvlock(rep)
register struct nfsreq *rep;
{
@@ -1491,6 +1503,7 @@ nfs_realign(m, hsiz)
* - verify it
* - fill in the cred struct.
*/
+int
nfs_getreq(nd, has_header)
register struct nfsd *nd;
int has_header;
@@ -1639,6 +1652,7 @@ nfsmout:
return (error);
}
+void
nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
@@ -1654,29 +1668,9 @@ nfs_msg(p, server, msg)
}
#ifdef NFSSERVER
-int nfsrv_null(),
- nfsrv_getattr(),
- nfsrv_setattr(),
- nfsrv_lookup(),
- nfsrv_readlink(),
- nfsrv_read(),
- nfsrv_write(),
- nfsrv_create(),
- nfsrv_remove(),
- nfsrv_rename(),
- nfsrv_link(),
- nfsrv_symlink(),
- nfsrv_mkdir(),
- nfsrv_rmdir(),
- nfsrv_readdir(),
- nfsrv_statfs(),
- nfsrv_noop(),
- nqnfsrv_readdirlook(),
- nqnfsrv_getlease(),
- nqnfsrv_vacated(),
- nqnfsrv_access();
-
-int (*nfsrv_procs[NFS_NPROCS])() = {
+int (*nfsrv_procs[NFS_NPROCS]) __P((struct nfsd *, struct mbuf *, struct mbuf *,
+ caddr_t, struct ucred *, struct mbuf *,
+ struct mbuf **)) = {
nfsrv_null,
nfsrv_getattr,
nfsrv_setattr,
@@ -1770,7 +1764,7 @@ nfsrv_rcv(so, arg, waitflag)
/*
* Now try and parse record(s) out of the raw stream data.
*/
- if (error = nfsrv_getstream(slp, waitflag)) {
+ if ((error = nfsrv_getstream(slp, waitflag)) != 0) {
if (error == EPERM)
slp->ns_flag |= SLP_DISCONN;
else
@@ -1820,6 +1814,7 @@ dorecs:
* stream socket. The "waitflag" argument indicates whether or not it
* can sleep.
*/
+int
nfsrv_getstream(slp, waitflag)
register struct nfssvc_sock *slp;
int waitflag;
@@ -1827,7 +1822,7 @@ nfsrv_getstream(slp, waitflag)
register struct mbuf *m;
register char *cp1, *cp2;
register int len;
- struct mbuf *om, *m2, *recm;
+ struct mbuf *om, *m2, *recm = NULL;
u_long recmark;
if (slp->ns_flag & SLP_GETSTREAM)
@@ -1924,6 +1919,7 @@ nfsrv_getstream(slp, waitflag)
/*
* Parse an RPC header.
*/
+int
nfsrv_dorec(slp, nd)
register struct nfssvc_sock *slp;
register struct nfsd *nd;
@@ -1934,7 +1930,7 @@ nfsrv_dorec(slp, nd)
if ((slp->ns_flag & SLP_VALID) == 0 ||
(m = slp->ns_rec) == (struct mbuf *)0)
return (ENOBUFS);
- if (slp->ns_rec = m->m_nextpkt)
+ if ((slp->ns_rec = m->m_nextpkt) != NULL)
m->m_nextpkt = (struct mbuf *)0;
else
slp->ns_recend = (struct mbuf *)0;
@@ -1947,7 +1943,7 @@ nfsrv_dorec(slp, nd)
nd->nd_md = nd->nd_mrep = m;
}
nd->nd_dpos = mtod(nd->nd_md, caddr_t);
- if (error = nfs_getreq(nd, TRUE)) {
+ if ((error = nfs_getreq(nd, TRUE)) != 0) {
m_freem(nd->nd_nam);
return (error);
}
diff --git a/sys/nfs/nfs_srvcache.c b/sys/nfs/nfs_srvcache.c
index 9e2d9ea0a35..169e2598f78 100644
--- a/sys/nfs/nfs_srvcache.c
+++ b/sys/nfs/nfs_srvcache.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_srvcache.c,v 1.10 1994/12/13 17:17:03 mycroft Exp $ */
+/* $OpenBSD: nfs_srvcache.c,v 1.2 1996/02/29 09:24:55 niklas Exp $ */
+/* $NetBSD: nfs_srvcache.c,v 1.11 1996/02/09 21:48:32 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -64,6 +65,7 @@
#include <nfs/nfs.h>
#include <nfs/nfsrvcache.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
long numnfsrvcache, desirednfsrvcache = NFSRVCACHESIZ;
@@ -138,6 +140,7 @@ static int repliesstatus[NFS_NPROCS] = {
/*
* Initialize the server request cache list
*/
+void
nfsrv_initcache()
{
@@ -159,6 +162,7 @@ nfsrv_initcache()
* return DOIT
* Update/add new request at end of lru list
*/
+int
nfsrv_getcache(nam, nd, repp)
struct mbuf *nam;
register struct nfsd *nd;
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index 1322229fe51..305f23df96e 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_subs.c,v 1.22 1995/12/19 23:07:43 cgd Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.4 1996/02/29 09:24:56 niklas Exp $ */
+/* $NetBSD: nfs_subs.c,v 1.24 1996/02/09 21:48:34 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -63,9 +64,12 @@
#include <nfs/nfsmount.h>
#include <nfs/nqnfs.h>
#include <nfs/nfsrtt.h>
+#include <nfs/nfs_var.h>
#include <miscfs/specfs/specdev.h>
+#include <vm/vm.h>
+
#include <netinet/in.h>
#ifdef ISO
#include <netiso/iso.h>
@@ -266,6 +270,7 @@ nfsm_rpchead(cr, nqnfs, procid, auth_type, auth_len, auth_str, mrest,
/*
* copies mbuf chain to the uio scatter/gather list
*/
+int
nfsm_mbuftouio(mrep, uiop, siz, dpos)
struct mbuf **mrep;
register struct uio *uiop;
@@ -340,6 +345,7 @@ nfsm_mbuftouio(mrep, uiop, siz, dpos)
/*
* copies a uio scatter/gather list to an mbuf chain...
*/
+int
nfsm_uiotombuf(uiop, mq, siz, bpos)
register struct uio *uiop;
struct mbuf **mq;
@@ -427,6 +433,7 @@ nfsm_uiotombuf(uiop, mq, siz, bpos)
* This is used by the macros nfsm_dissect and nfsm_dissecton for tough
* cases. (The macros use the vars. dpos and dpos2)
*/
+int
nfsm_disct(mdp, dposp, siz, left, cp2)
struct mbuf **mdp;
caddr_t *dposp;
@@ -489,6 +496,7 @@ nfsm_disct(mdp, dposp, siz, left, cp2)
/*
* Advance the position in the mbuf chain.
*/
+int
nfs_adv(mdp, dposp, offs, left)
struct mbuf **mdp;
caddr_t *dposp;
@@ -515,13 +523,14 @@ nfs_adv(mdp, dposp, offs, left)
/*
* Copy a string into mbufs for the hard cases...
*/
+int
nfsm_strtmbuf(mb, bpos, cp, siz)
struct mbuf **mb;
char **bpos;
char *cp;
long siz;
{
- register struct mbuf *m1, *m2;
+ register struct mbuf *m1 = NULL, *m2;
long left, xfer, len, tlen;
u_int32_t *tl;
int putsize;
@@ -580,6 +589,7 @@ nfsm_strtmbuf(mb, bpos, cp, siz)
/*
* Called once to initialize data structures...
*/
+void
nfs_init()
{
register int i;
@@ -632,7 +642,7 @@ nfs_init()
* Initialize reply list and start timer
*/
TAILQ_INIT(&nfs_reqq);
- nfs_timer();
+ nfs_timer(NULL);
}
#ifdef NFSCLIENT
@@ -650,6 +660,7 @@ nfs_init()
* Iff vap not NULL
* copy the attributes to *vaper
*/
+int
nfs_loadattrcache(vpp, mdp, dposp, vaper)
struct vnode **vpp;
struct mbuf **mdp;
@@ -659,7 +670,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
register struct vnode *vp = *vpp;
register struct vattr *vap;
register struct nfsv2_fattr *fp;
- extern int (**spec_nfsv2nodeop_p)();
+ extern int (**spec_nfsv2nodeop_p) __P((void *));
register struct nfsnode *np;
register struct nfsnodehashhead *nhpp;
register int32_t t1;
@@ -676,7 +687,8 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
dpos = *dposp;
t1 = (mtod(md, caddr_t) + md->m_len) - dpos;
isnq = (VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NQNFS);
- if (error = nfsm_disct(&md, &dpos, NFSX_FATTR(isnq), t1, &cp2))
+ error = nfsm_disct(&md, &dpos, NFSX_FATTR(isnq), t1, &cp2);
+ if (error)
return (error);
fp = (struct nfsv2_fattr *)cp2;
vtyp = nfstov_type(fp->fa_type);
@@ -705,7 +717,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
vp->v_type = vtyp;
if (vp->v_type == VFIFO) {
#ifdef FIFO
- extern int (**fifo_nfsv2nodeop_p)();
+ extern int (**fifo_nfsv2nodeop_p) __P((void *));
vp->v_op = fifo_nfsv2nodeop_p;
#else
return (EOPNOTSUPP);
@@ -713,7 +725,8 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
}
if (vp->v_type == VCHR || vp->v_type == VBLK) {
vp->v_op = spec_nfsv2nodeop_p;
- if (nvp = checkalias(vp, (dev_t)rdev, vp->v_mount)) {
+ nvp = checkalias(vp, (dev_t)rdev, vp->v_mount);
+ if (nvp) {
/*
* Discard unneeded vnode, but save its nfsnode.
*/
@@ -732,7 +745,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
*vpp = vp = nvp;
}
}
- np->n_mtime = mtime.ts_sec;
+ np->n_mtime = mtime.tv_sec;
}
vap = &np->n_vattr;
vap->va_type = vtyp;
@@ -789,13 +802,13 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
#endif
if (np->n_flag & NCHG) {
if (np->n_flag & NACC) {
- vaper->va_atime.ts_sec = np->n_atim.tv_sec;
- vaper->va_atime.ts_nsec =
+ vaper->va_atime.tv_sec = np->n_atim.tv_sec;
+ vaper->va_atime.tv_nsec =
np->n_atim.tv_usec * 1000;
}
if (np->n_flag & NUPD) {
- vaper->va_mtime.ts_sec = np->n_mtim.tv_sec;
- vaper->va_mtime.ts_nsec =
+ vaper->va_mtime.tv_sec = np->n_mtim.tv_sec;
+ vaper->va_mtime.tv_nsec =
np->n_mtim.tv_usec * 1000;
}
}
@@ -808,6 +821,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
* If the cache is valid, copy contents to *vap and return 0
* otherwise return an error
*/
+int
nfs_getattrcache(vp, vaper)
register struct vnode *vp;
struct vattr *vaper;
@@ -850,12 +864,12 @@ nfs_getattrcache(vp, vaper)
#endif
if (np->n_flag & NCHG) {
if (np->n_flag & NACC) {
- vaper->va_atime.ts_sec = np->n_atim.tv_sec;
- vaper->va_atime.ts_nsec = np->n_atim.tv_usec * 1000;
+ vaper->va_atime.tv_sec = np->n_atim.tv_sec;
+ vaper->va_atime.tv_nsec = np->n_atim.tv_usec * 1000;
}
if (np->n_flag & NUPD) {
- vaper->va_mtime.ts_sec = np->n_mtim.tv_sec;
- vaper->va_mtime.ts_nsec = np->n_mtim.tv_usec * 1000;
+ vaper->va_mtime.tv_sec = np->n_mtim.tv_sec;
+ vaper->va_mtime.tv_nsec = np->n_mtim.tv_usec * 1000;
}
}
return (0);
@@ -865,6 +879,7 @@ nfs_getattrcache(vp, vaper)
/*
* Set up nameidata for a lookup() call and do it
*/
+int
nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
register struct nameidata *ndp;
fhandle_t *fhp;
@@ -915,7 +930,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
if (len > 0) {
if (rem >= len)
*dposp += len;
- else if (error = nfs_adv(mdp, dposp, len, rem))
+ else if ((error = nfs_adv(mdp, dposp, len, rem)) != 0)
goto out;
}
ndp->ni_pathlen = tocp - cnp->cn_pnbuf;
@@ -923,8 +938,9 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
/*
* Extract and set starting directory.
*/
- if (error = nfsrv_fhtovp(fhp, FALSE, &dp, ndp->ni_cnd.cn_cred, slp,
- nam, &rdonly))
+ error = nfsrv_fhtovp(fhp, FALSE, &dp, ndp->ni_cnd.cn_cred, slp,
+ nam, &rdonly);
+ if (error)
goto out;
if (dp->v_type != VDIR) {
vrele(dp);
@@ -940,7 +956,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
* And call lookup() to do the real work
*/
cnp->cn_proc = p;
- if (error = lookup(ndp))
+ if ((error = lookup(ndp)) != 0)
goto out;
/*
* Check for encountering a symbolic link
@@ -1025,7 +1041,7 @@ nfsm_adj(mp, len, nul)
}
count -= m->m_len;
}
- while (m = m->m_next)
+ while ((m = m->m_next) != NULL)
m->m_len = 0;
}
@@ -1036,6 +1052,7 @@ nfsm_adj(mp, len, nul)
* - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
* - if not lockflag unlock it with VOP_UNLOCK()
*/
+int
nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp)
fhandle_t *fhp;
int lockflag;
@@ -1054,7 +1071,8 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp)
*vpp = (struct vnode *)0;
if ((mp = getvfs(&fhp->fh_fsid)) == NULL)
return (ESTALE);
- if (error = VFS_FHTOVP(mp, &fhp->fh_fid, nam, vpp, &exflags, &credanon))
+ error = VFS_FHTOVP(mp, &fhp->fh_fid, nam, vpp, &exflags, &credanon);
+ if (error)
return (error);
/*
* Check/setup credentials.
@@ -1097,6 +1115,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp)
* The AF_INET family is handled as a special case so that address mbufs
* don't need to be saved to store "struct in_addr", which is only 4 bytes.
*/
+int
netaddr_match(family, haddr, nam)
int family;
union nethostaddr *haddr;
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 1de179e8b1d..63ea290920c 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_syscalls.c,v 1.17 1995/12/19 23:07:46 cgd Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.3 1996/02/29 09:24:57 niklas Exp $ */
+/* $NetBSD: nfs_syscalls.c,v 1.18 1996/02/09 21:48:36 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -56,6 +57,7 @@
#include <sys/protosw.h>
#include <sys/namei.h>
#include <sys/syslog.h>
+#include <sys/filedesc.h>
#include <sys/syscallargs.h>
@@ -72,10 +74,14 @@
#include <nfs/nfsnode.h>
#include <nfs/nqnfs.h>
#include <nfs/nfsrtt.h>
+#include <nfs/nfs_var.h>
/* Global defs. */
extern u_int32_t nfs_prog, nfs_vers;
-extern int32_t (*nfsrv_procs[NFS_NPROCS])();
+extern int32_t (*nfsrv_procs[NFS_NPROCS]) __P((struct nfsd *, struct mbuf *,
+ struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *,
+ struct mbuf **));
extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
extern int nfs_numasync;
extern time_t nqnfsstarttime;
@@ -83,19 +89,22 @@ extern int nqsrv_writeslack;
extern int nfsrtton;
struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock;
int nuidhash_max = NFS_MAXUIDHASH;
-static int nfs_numnfsd = 0;
int nfsd_waiting = 0;
+#ifdef NFSSERVER
+static int nfs_numnfsd = 0;
static int notstarted = 1;
static int modify_flag = 0;
static struct nfsdrt nfsdrt;
-void nfsrv_cleancache(), nfsrv_rcv(), nfsrv_wakenfsd(), nfs_sndunlock();
-static void nfsd_rt();
-void nfsrv_slpderef(), nfsrv_init();
+#endif
#define TRUE 1
#define FALSE 0
static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
+#ifdef NFSSERVER
+static void nfsd_rt __P((struct timeval *, int, struct nfsd *, struct mbuf *,
+ int));
+#endif
/*
* NFS server system calls
* getfh() lives here too, but maybe should move to kern/vfs_syscalls.c
@@ -104,9 +113,10 @@ static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
/*
* Get file handle system call
*/
+int
sys_getfh(p, v, retval)
struct proc *p;
- void *v;
+ register void *v;
register_t *retval;
{
register struct sys_getfh_args /* {
@@ -121,11 +131,11 @@ sys_getfh(p, v, retval)
/*
* Must be super user
*/
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, fname), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
bzero((caddr_t)&fh, sizeof(fh));
@@ -145,6 +155,7 @@ sys_getfh(p, v, retval)
* - remains in the kernel as an nfsd
* - remains in the kernel as an nfsiod
*/
+int
sys_nfssvc(p, v, retval)
struct proc *p;
void *v;
@@ -155,21 +166,23 @@ sys_nfssvc(p, v, retval)
syscallarg(caddr_t) argp;
} */ *uap = v;
struct nameidata nd;
+ struct nfsmount *nmp;
+ int error;
+#ifdef NFSSERVER
struct file *fp;
struct mbuf *nam;
struct nfsd_args nfsdarg;
struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs;
- struct nfsd_cargs ncd;
struct nfsd *nfsd;
struct nfssvc_sock *slp;
- struct nfsuid *nuidp, **nuh;
- struct nfsmount *nmp;
- int error;
+ struct nfsuid *nuidp;
+#endif
+ struct nfsd_cargs ncd;
/*
* Must be super user
*/
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
while (nfssvc_sockhead_flag & SLP_INIT) {
nfssvc_sockhead_flag |= SLP_WANTINIT;
@@ -185,12 +198,12 @@ sys_nfssvc(p, v, retval)
#ifndef NFSCLIENT
error = ENOSYS;
#else /* !NFSCLIENT */
- if (error =
- copyin(SCARG(uap, argp), (caddr_t)&ncd, sizeof (ncd)))
+ error = copyin(SCARG(uap, argp), (caddr_t)&ncd, sizeof (ncd));
+ if (error)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
ncd.ncd_dirp, p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
if ((nd.ni_vp->v_flag & VROOT) == 0)
error = EINVAL;
@@ -209,27 +222,31 @@ sys_nfssvc(p, v, retval)
#ifndef NFSSERVER
error = ENOSYS;
#else /* !NFSSERVER */
- if (error = copyin(SCARG(uap, argp), (caddr_t)&nfsdarg,
- sizeof(nfsdarg)))
+ error = copyin(SCARG(uap, argp), (caddr_t)&nfsdarg,
+ sizeof(nfsdarg));
+ if (error)
return (error);
- if (error = getsock(p->p_fd, nfsdarg.sock, &fp))
+ if ((error = getsock(p->p_fd, nfsdarg.sock, &fp)) != 0)
return (error);
/*
* Get the client address for connected sockets.
*/
if (nfsdarg.name == NULL || nfsdarg.namelen == 0)
nam = (struct mbuf *)0;
- else if (error = sockargs(&nam, nfsdarg.name, nfsdarg.namelen,
- MT_SONAME))
- return (error);
+ else {
+ error = sockargs(&nam, nfsdarg.name, nfsdarg.namelen,
+ MT_SONAME);
+ if (error)
+ return (error);
+ }
error = nfssvc_addsock(fp, nam);
#endif /* !NFSSERVER */
} else {
#ifndef NFSSERVER
error = ENOSYS;
#else /* !NFSSERVER */
- if (error = copyin(SCARG(uap, argp), (caddr_t)nsd,
- sizeof (*nsd)))
+ error = copyin(SCARG(uap, argp), (caddr_t)nsd, sizeof (*nsd));
+ if (error)
return (error);
if ((SCARG(uap, flag) & NFSSVC_AUTHIN) &&
(nfsd = nsd->nsd_nfsd) &&
@@ -293,6 +310,7 @@ sys_nfssvc(p, v, retval)
/*
* Adds a socket to the list for servicing by nfsds.
*/
+int
nfssvc_addsock(fp, mynam)
struct file *fp;
struct mbuf *mynam;
@@ -328,7 +346,7 @@ nfssvc_addsock(fp, mynam)
siz = NFS_MAXPACKET + sizeof (u_int32_t);
else
siz = NFS_MAXPACKET;
- if (error = soreserve(so, siz, siz)) {
+ if ((error = soreserve(so, siz, siz)) != 0) {
m_freem(mynam);
return (error);
}
@@ -383,6 +401,7 @@ nfssvc_addsock(fp, mynam)
* Called by nfssvc() for nfsds. Just loops around servicing rpc requests
* until it is killed by a signal.
*/
+int
nfssvc_nfsd(nsd, argp, p)
struct nfsd_srvargs *nsd;
caddr_t argp;
@@ -397,7 +416,7 @@ nfssvc_nfsd(nsd, argp, p)
struct mbuf *mreq, *nam;
struct timeval starttime;
struct nfsuid *uidp;
- int error, cacherep, s;
+ int error = 0, cacherep, s;
int sotype;
s = splsoftnet();
@@ -479,7 +498,7 @@ nfssvc_nfsd(nsd, argp, p)
* nam2 == NULL for connection based protocols to disable
* recent request caching.
*/
- if (nam2 = nd->nd_nam) {
+ if ((nam2 = nd->nd_nam) != NULL) {
nam = nam2;
cacherep = RC_CHECKIT;
} else {
@@ -645,17 +664,17 @@ done:
* will stop using it and clear ns_flag at the end so that it will not be
* reassigned during cleanup.
*/
+void
nfsrv_zapsock(slp)
register struct nfssvc_sock *slp;
{
register struct nfsuid *nuidp, *nnuidp;
- register int i;
struct socket *so;
struct file *fp;
struct mbuf *m;
slp->ns_flag &= ~SLP_ALLFLAGS;
- if (fp = slp->ns_fp) {
+ if ((fp = slp->ns_fp) != NULL) {
slp->ns_fp = (struct file *)0;
so = slp->ns_so;
so->so_upcall = NULL;
@@ -783,6 +802,7 @@ nfsd_rt(startp, sotype, nd, nam, cacherep)
* They do read-ahead and write-behind operations on the block I/O cache.
* Never returns unless it fails or gets killed.
*/
+int
nfssvc_iod(p)
struct proc *p;
{
@@ -832,6 +852,7 @@ nfssvc_iod(p)
* Get an authorization string for the uid by having the mount_nfs sitting
* on this mount point porpous out of the kernel and do it.
*/
+int
nfs_getauth(nmp, rep, cred, auth_type, auth_str, auth_len)
register struct nfsmount *nmp;
struct nfsreq *rep;
@@ -846,7 +867,8 @@ nfs_getauth(nmp, rep, cred, auth_type, auth_str, auth_len)
nmp->nm_flag |= NFSMNT_WANTAUTH;
(void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
"nfsauth1", 2 * hz);
- if (error = nfs_sigintr(nmp, rep, rep->r_procp)) {
+ error = nfs_sigintr(nmp, rep, rep->r_procp);
+ if (error) {
nmp->nm_flag &= ~NFSMNT_WANTAUTH;
return (error);
}
diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h
new file mode 100644
index 00000000000..79973b95c1d
--- /dev/null
+++ b/sys/nfs/nfs_var.h
@@ -0,0 +1,223 @@
+/* $OpenBSD: nfs_var.h,v 1.1 1996/02/29 09:24:57 niklas Exp $ */
+/* $NetBSD: nfs_var.h,v 1.2 1996/02/13 17:06:52 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+struct vnode;
+struct uio;
+struct ucred;
+struct proc;
+struct buf;
+struct nfs_diskless;
+struct sockaddr_in;
+struct nfs_dlmount;
+struct vnode;
+struct nfsd;
+struct mbuf;
+struct file;
+struct nqlease;
+struct nqhost;
+struct nfssvc_sock;
+struct nfsmount;
+struct socket;
+struct nfsreq;
+struct vattr;
+struct nameidata;
+struct nfsnode;
+struct sillyrename;
+struct componentname;
+struct nfsd_srvargs;
+struct nfsd_cargs;
+
+
+/* nfs_bio.c */
+int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
+struct buf *nfs_getcacheblk __P((struct vnode *, daddr_t, int, struct proc *));
+int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
+ int));
+int nfs_asyncio __P((struct buf *, struct ucred *));
+int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
+
+/* nfs_boot.c */
+int nfs_boot_init __P((struct nfs_diskless *, struct proc *));
+int nfs_boot_init __P((struct nfs_diskless *, struct proc *));
+
+/* nfs_node.c */
+void nfs_nhinit __P((void));
+struct nfsnodehashhead *nfs_hash __P((nfsv2fh_t *));
+int nfs_nget __P((struct mount *, nfsv2fh_t *, struct nfsnode **));
+
+/* nfs_vnops.c */
+int nfs_null __P((struct vnode *, struct ucred *, struct proc *));
+int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
+int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
+int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int));
+int nfs_removeit __P((struct sillyrename *));
+int nfs_renameit __P((struct vnode *, struct componentname *,
+ struct sillyrename *));
+int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
+int nfs_readdirlookrpc __P((struct vnode *, struct uio *, struct ucred *));
+int nfs_sillyrename __P((struct vnode *, struct vnode *,
+ struct componentname *));
+int nfs_lookitup __P((struct sillyrename *, nfsv2fh_t *, struct proc *));
+
+/* nfs_nqlease.c */
+int nqsrv_getlease __P((struct vnode *, u_int *, int, struct nfsd *,
+ struct mbuf *, int *, u_quad_t *, struct ucred *));
+int lease_check __P((void *));
+void nqsrv_addhost __P((struct nqhost *, struct nfssvc_sock *, struct mbuf *));
+void nqsrv_instimeq __P((struct nqlease *, u_long));
+int nqsrv_cmpnam __P((struct nfssvc_sock *, struct mbuf *, struct nqhost *));
+void nqsrv_send_eviction __P((struct vnode *, struct nqlease *,
+ struct nfssvc_sock *, struct mbuf *,
+ struct ucred *));
+void nqsrv_waitfor_expiry __P((struct nqlease *));
+void nqnfs_serverd __P((void));
+int nqnfsrv_getlease __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nqnfsrv_vacated __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nqnfs_getlease __P((struct vnode *, int, struct ucred *, struct proc *));
+int nqnfs_vacated __P((struct vnode *, struct ucred *));
+int nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *,
+ caddr_t));
+int nqnfs_clientd __P((struct nfsmount *, struct ucred *, struct nfsd_cargs *,
+ int, caddr_t, struct proc *));
+void nqnfs_clientlease __P((struct nfsmount *, struct nfsnode *, int, int ,
+ time_t, u_quad_t));
+void lease_updatetime __P((int));
+void nqsrv_locklease __P((struct nqlease *));
+void nqsrv_unlocklease __P((struct nqlease *));
+
+/* nfs_serv.c */
+int nqnfsrv_access __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_getattr __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_setattr __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_lookup __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_readlink __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_read __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_write __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_create __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_remove __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_rename __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_link __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_symlink __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_mkdir __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_rmdir __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_readdir __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nqnfsrv_readdirlook __P((struct nfsd *, struct mbuf *, struct mbuf *,
+ caddr_t, struct ucred *, struct mbuf *,
+ struct mbuf **));
+int nfsrv_statfs __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_null __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_noop __P((struct nfsd *, struct mbuf *, struct mbuf *, caddr_t,
+ struct ucred *, struct mbuf *, struct mbuf **));
+int nfsrv_access __P((struct vnode *, int, struct ucred *, int, struct proc *));
+
+/* nfs_socket.c */
+int nfs_connect __P((struct nfsmount *, struct nfsreq *));
+int nfs_reconnect __P((struct nfsreq *));
+void nfs_disconnect __P((struct nfsmount *));
+int nfs_send __P((struct socket *, struct mbuf *, struct mbuf *,
+ struct nfsreq *));
+int nfs_receive __P((struct nfsreq *, struct mbuf **, struct mbuf **));
+int nfs_reply __P((struct nfsreq *));
+int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
+ struct ucred *, struct mbuf **, struct mbuf **,
+ caddr_t *));
+int nfs_rephead __P((int, struct nfsd *, int, int, u_quad_t *, struct mbuf **,
+ struct mbuf **, caddr_t *));
+void nfs_timer __P((void *));
+int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
+int nfs_sndlock __P((int *, struct nfsreq *));
+void nfs_sndunlock __P((int *));
+int nfs_rcvlock __P((struct nfsreq *));
+void nfs_rcvunlock __P((int *));
+void nfs_realign __P((struct mbuf *, int));
+int nfs_getreq __P((struct nfsd *, int));
+void nfs_msg __P((struct proc *, char *, char *));
+void nfsrv_rcv __P((struct socket *, caddr_t, int));
+int nfsrv_getstream __P((struct nfssvc_sock *, int));
+int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *));
+void nfsrv_wakenfsd __P((struct nfssvc_sock *));
+
+/* nfs_srvcache.c */
+void nfsrv_initcache __P((void));
+int nfsrv_getcache __P((struct mbuf *, struct nfsd *, struct mbuf **));
+void nfsrv_updatecache __P((struct mbuf *, struct nfsd *, int, struct mbuf *));
+void nfsrv_cleancache __P((void));
+
+/* nfs_subs.c */
+struct mbuf *nfsm_reqh __P((struct vnode *, u_long, int, caddr_t *));
+struct mbuf *nfsm_rpchead __P((struct ucred *, int, int, int, int, char *,
+ struct mbuf *, int, struct mbuf **,
+ u_int32_t *));
+int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
+int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
+int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
+int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
+int nfsm_strtmbuf __P((struct mbuf **, char **, char *, long));
+int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
+ struct vattr *));
+int nfs_getattrcache __P((struct vnode *, struct vattr *));
+int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
+ struct mbuf *, struct mbuf **, caddr_t *, struct proc *));
+void nfsm_adj __P((struct mbuf *, int, int));
+int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
+ struct nfssvc_sock *, struct mbuf *, int *));
+int netaddr_match __P((int, union nethostaddr *, struct mbuf *));
+
+/* nfs_syscalls.c */
+int nfssvc_addsock __P((struct file *, struct mbuf *));
+int nfssvc_nfsd __P((struct nfsd_srvargs *, caddr_t, struct proc *));
+void nfsrv_zapsock __P((struct nfssvc_sock *));
+void nfsrv_slpderef __P((struct nfssvc_sock *));
+void nfsrv_init __P((int));
+int nfssvc_iod __P((struct proc *));
+int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
+ int *, char **, int *));
+
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index d876fbd22fb..86bb4a684ad 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_vfsops.c,v 1.39 1995/12/19 23:07:49 cgd Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.5 1996/02/29 09:24:58 niklas Exp $ */
+/* $NetBSD: nfs_vfsops.c,v 1.42 1996/02/13 17:53:35 gwr Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -50,6 +51,7 @@
#include <sys/buf.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
+#include <sys/socketvar.h>
#include <sys/systm.h>
#include <net/if.h>
@@ -65,6 +67,7 @@
#include <nfs/nfsm_subs.h>
#include <nfs/nfsdiskless.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
/*
* nfs vfs operations.
@@ -116,7 +119,7 @@ nfs_statfs(mp, sbp, p)
nmp = VFSTONFS(mp);
isnq = (nmp->nm_flag & NFSMNT_NQNFS);
- if (error = nfs_nget(mp, &nmp->nm_fh, &np))
+ if ((error = nfs_nget(mp, &nmp->nm_fh, &np)) != 0)
return (error);
vp = NFSTOV(np);
nfsstats.rpccnt[NFSPROC_STATFS]++;
@@ -171,7 +174,6 @@ nfs_mountroot()
struct mount *mp;
struct vnode *vp;
struct proc *procp;
- struct ucred *cred;
long n;
int error;
@@ -196,8 +198,9 @@ nfs_mountroot()
/*
* Create the root mount point.
*/
+ nfs_boot_getfh(&nd.nd_boot, "root", &nd.nd_root);
mp = nfs_mount_diskless(&nd.nd_root, "/", 0, &vp);
- printf("root on %s\n", &nd.nd_root.ndm_host);
+ printf("root on %s\n", nd.nd_root.ndm_host);
/*
* Link it into the mount list.
@@ -212,7 +215,7 @@ nfs_mountroot()
/* Get root attributes (for the time). */
error = VOP_GETATTR(vp, &attr, procp->p_ucred, procp);
if (error) panic("nfs_mountroot: getattr for root");
- n = attr.va_mtime.ts_sec;
+ n = attr.va_mtime.tv_sec;
#ifdef DEBUG
printf("root time: 0x%x\n", n);
#endif
@@ -247,8 +250,9 @@ nfs_mountroot()
* Create a fake mount point just for the swap vnode so that the
* swap file can be on a different server from the rootfs.
*/
+ nfs_boot_getfh(&nd.nd_boot, "swap", &nd.nd_swap);
mp = nfs_mount_diskless(&nd.nd_swap, "/swap", 0, &vp);
- printf("swap on %s\n", &nd.nd_swap.ndm_host);
+ printf("swap on %s\n", nd.nd_swap.ndm_host);
/*
* Since the swap file is not the root dir of a file system,
@@ -290,7 +294,7 @@ nfs_mount_diskless(ndmntp, mntname, mntflag, vpp)
/* Create the mount point. */
mp = (struct mount *)malloc((u_long)sizeof(struct mount),
- M_MOUNT, M_NOWAIT);
+ M_MOUNT, M_WAITOK);
if (mp == NULL)
panic("nfs_mountroot: malloc mount for %s", mntname);
bzero((char *)mp, (u_long)sizeof(struct mount));
@@ -327,7 +331,8 @@ nfs_mount_diskless(ndmntp, mntname, mntflag, vpp)
bcopy((caddr_t)args.addr, mtod(m, caddr_t),
(m->m_len = args.addr->sa_len));
- if (error = mountnfs(&args, mp, m, mntname, args.hostname, vpp))
+ error = mountnfs(&args, mp, m, mntname, args.hostname, vpp);
+ if (error)
panic("nfs_mountroot: mount %s failed: %d", mntname);
return (mp);
@@ -444,7 +449,8 @@ nfs_mount(mp, path, data, ndp, p)
size_t len;
nfsv2fh_t nfh;
- if (error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args)))
+ error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args));
+ if (error)
return (error);
if (mp->mnt_flag & MNT_UPDATE) {
register struct nfsmount *nmp = VFSTONFS(mp);
@@ -455,17 +461,19 @@ nfs_mount(mp, path, data, ndp, p)
args.flags |= NFSMNT_RESVPORT; /* ALWAYS allocate one */
return (0);
}
- if (error = copyin((caddr_t)args.fh, (caddr_t)&nfh, sizeof (nfsv2fh_t)))
+ error = copyin((caddr_t)args.fh, (caddr_t)&nfh, sizeof (nfsv2fh_t));
+ if (error)
return (error);
- if (error = copyinstr(path, pth, MNAMELEN-1, &len))
+ if ((error = copyinstr(path, pth, MNAMELEN-1, &len)) != 0)
return (error);
bzero(&pth[len], MNAMELEN - len);
- if (error = copyinstr(args.hostname, hst, MNAMELEN-1, &len))
+ if ((error = copyinstr(args.hostname, hst, MNAMELEN-1, &len)) != 0)
return (error);
bzero(&hst[len], MNAMELEN - len);
/* sockargs() call must be after above copyin() calls */
- if (error = sockargs(&nam, (caddr_t)args.addr,
- args.addrlen, MT_SONAME))
+ error = sockargs(&nam, (caddr_t)args.addr,
+ args.addrlen, MT_SONAME);
+ if (error)
return (error);
args.fh = &nfh;
error = mountnfs(&args, mp, nam, pth, hst, &vp);
@@ -563,7 +571,7 @@ mountnfs(argp, mp, nam, pth, hst, vpp)
* this problem, because one can identify root inodes by their
* number == ROOTINO (2).
*/
- if (error = nfs_nget(mp, &nmp->nm_fh, &np))
+ if ((error = nfs_nget(mp, &nmp->nm_fh, &np)) != 0)
goto bad;
*vpp = NFSTOV(np);
VOP_GETATTR(*vpp, &attrs, curproc->p_ucred, curproc);
@@ -589,7 +597,6 @@ nfs_unmount(mp, mntflags, p)
struct nfsnode *np;
struct vnode *vp;
int error, flags = 0;
- extern int doforce;
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
@@ -608,7 +615,7 @@ nfs_unmount(mp, mntflags, p)
* the remote root. See comment in mountnfs(). The VFS unmount()
* has done vput on this vnode, otherwise we would get deadlock!
*/
- if (error = nfs_nget(mp, &nmp->nm_fh, &np))
+ if ((error = nfs_nget(mp, &nmp->nm_fh, &np)) != 0)
return(error);
vp = NFSTOV(np);
if (vp->v_usecount > 2) {
@@ -622,7 +629,7 @@ nfs_unmount(mp, mntflags, p)
nmp->nm_flag |= NFSMNT_DISMINPROG;
while (nmp->nm_inprog != NULLVP)
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfsdism", 0);
- if (error = vflush(mp, vp, flags)) {
+ if ((error = vflush(mp, vp, flags)) != 0) {
vput(vp);
nmp->nm_flag &= ~NFSMNT_DISMINPROG;
return (error);
@@ -663,7 +670,7 @@ nfs_root(mp, vpp)
int error;
nmp = VFSTONFS(mp);
- if (error = nfs_nget(mp, &nmp->nm_fh, &np))
+ if ((error = nfs_nget(mp, &nmp->nm_fh, &np)) != 0)
return (error);
vp = NFSTOV(np);
if (vp->v_type == VNON)
@@ -706,7 +713,7 @@ loop:
continue;
if (vget(vp, 1))
goto loop;
- if (error = VOP_FSYNC(vp, cred, waitfor, p))
+ if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0)
allerror = error;
vput(vp);
}
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 362a40d3a4b..2624d001764 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nfs_vnops.c,v 1.53 1995/12/19 23:07:54 cgd Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.4 1996/02/29 09:24:59 niklas Exp $ */
+/* $NetBSD: nfs_vnops.c,v 1.58 1996/02/09 21:48:41 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -70,6 +71,7 @@
#include <nfs/xdr_subs.h>
#include <nfs/nfsm_subs.h>
#include <nfs/nqnfs.h>
+#include <nfs/nfs_var.h>
/* Defs */
#define TRUE 1
@@ -78,7 +80,7 @@
/*
* Global vfs data structures for nfs
*/
-int (**nfsv2_vnodeop_p)();
+int (**nfsv2_vnodeop_p) __P((void *));
struct vnodeopv_entry_desc nfsv2_vnodeop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, nfs_lookup }, /* lookup */
@@ -123,7 +125,7 @@ struct vnodeopv_entry_desc nfsv2_vnodeop_entries[] = {
{ &vop_truncate_desc, nfs_truncate }, /* truncate */
{ &vop_update_desc, nfs_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
- { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
};
struct vnodeopv_desc nfsv2_vnodeop_opv_desc =
{ &nfsv2_vnodeop_p, nfsv2_vnodeop_entries };
@@ -131,7 +133,7 @@ struct vnodeopv_desc nfsv2_vnodeop_opv_desc =
/*
* Special device vnode ops
*/
-int (**spec_nfsv2nodeop_p)();
+int (**spec_nfsv2nodeop_p) __P((void *));
struct vnodeopv_entry_desc spec_nfsv2nodeop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, spec_lookup }, /* lookup */
@@ -176,13 +178,13 @@ struct vnodeopv_entry_desc spec_nfsv2nodeop_entries[] = {
{ &vop_truncate_desc, spec_truncate }, /* truncate */
{ &vop_update_desc, nfs_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
- { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
};
struct vnodeopv_desc spec_nfsv2nodeop_opv_desc =
{ &spec_nfsv2nodeop_p, spec_nfsv2nodeop_entries };
#ifdef FIFO
-int (**fifo_nfsv2nodeop_p)();
+int (**fifo_nfsv2nodeop_p) __P((void *));
struct vnodeopv_entry_desc fifo_nfsv2nodeop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, fifo_lookup }, /* lookup */
@@ -227,18 +229,17 @@ struct vnodeopv_entry_desc fifo_nfsv2nodeop_entries[] = {
{ &vop_truncate_desc, fifo_truncate }, /* truncate */
{ &vop_update_desc, nfs_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
- { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
};
struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc =
{ &fifo_nfsv2nodeop_p, fifo_nfsv2nodeop_entries };
#endif /* FIFO */
-void nqnfs_clientlease();
-
/*
* Global variables
*/
extern u_int32_t nfs_procids[NFS_NPROCS];
+extern u_int32_t nfs_xdrneg1;
extern u_int32_t nfs_prog, nfs_vers, nfs_true, nfs_false;
struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
int nfs_numasync = 0;
@@ -270,14 +271,15 @@ nfs_null(vp, cred, procp)
* changed on the server, accesses might still fail later.
*/
int
-nfs_access(ap)
+nfs_access(v)
+ void *v;
+{
struct vop_access_args /* {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register u_int32_t *tl;
register caddr_t cp;
@@ -326,14 +328,15 @@ nfs_access(ap)
*/
/* ARGSUSED */
int
-nfs_open(ap)
+nfs_open(v)
+ void *v;
+{
struct vop_open_args /* {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp);
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
@@ -370,19 +373,21 @@ nfs_open(ap)
(void) vnode_pager_uncache(vp);
np->n_attrstamp = 0;
np->n_direofoffset = 0;
- if (error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p))
+ error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
+ if (error)
return (error);
- np->n_mtime = vattr.va_mtime.ts_sec;
+ np->n_mtime = vattr.va_mtime.tv_sec;
} else {
- if (error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p))
+ error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
+ if (error)
return (error);
- if (np->n_mtime != vattr.va_mtime.ts_sec) {
+ if (np->n_mtime != vattr.va_mtime.tv_sec) {
np->n_direofoffset = 0;
if ((error = nfs_vinvalbuf(vp, V_SAVE,
ap->a_cred, ap->a_p, 1)) == EINTR)
return (error);
(void) vnode_pager_uncache(vp);
- np->n_mtime = vattr.va_mtime.ts_sec;
+ np->n_mtime = vattr.va_mtime.tv_sec;
}
}
}
@@ -397,15 +402,16 @@ nfs_open(ap)
*/
/* ARGSUSED */
int
-nfs_close(ap)
+nfs_close(v)
+ void *v;
+{
struct vop_close_args /* {
struct vnodeop_desc *a_desc;
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
int error = 0;
@@ -428,14 +434,15 @@ nfs_close(ap)
* nfs getattr call from vfs.
*/
int
-nfs_getattr(ap)
+nfs_getattr(v)
+ void *v;
+{
struct vop_getattr_args /* {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
register caddr_t cp;
@@ -466,15 +473,16 @@ nfs_getattr(ap)
* nfs setattr call.
*/
int
-nfs_setattr(ap)
+nfs_setattr(v)
+ void *v;
+{
struct vop_setattr_args /* {
struct vnodeop_desc *a_desc;
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct nfsv2_sattr *sp;
register caddr_t cp;
register int32_t t1;
@@ -485,7 +493,7 @@ nfs_setattr(ap)
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
register struct vattr *vap = ap->a_vap;
- u_quad_t frev, tsize;
+ u_quad_t frev, tsize = 0;
if (vap->va_size != VNOVAL) {
switch (vp->v_type) {
@@ -493,8 +501,8 @@ nfs_setattr(ap)
return (EISDIR);
case VCHR:
case VBLK:
- if (vap->va_mtime.ts_sec == VNOVAL &&
- vap->va_atime.ts_sec == VNOVAL &&
+ if (vap->va_mtime.tv_sec == VNOVAL &&
+ vap->va_atime.tv_sec == VNOVAL &&
vap->va_mode == (u_short)VNOVAL &&
vap->va_uid == VNOVAL &&
vap->va_gid == VNOVAL)
@@ -516,8 +524,8 @@ nfs_setattr(ap)
np->n_size = np->n_vattr.va_size = vap->va_size;
vnode_pager_setsize(vp, (u_long)np->n_size);
}
- } else if ((vap->va_mtime.ts_sec != VNOVAL ||
- vap->va_atime.ts_sec != VNOVAL) && (np->n_flag & NMODIFIED)) {
+ } else if ((vap->va_mtime.tv_sec != VNOVAL ||
+ vap->va_atime.tv_sec != VNOVAL) && (np->n_flag & NMODIFIED)) {
error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
if (error == EINTR)
return (error);
@@ -527,16 +535,16 @@ nfs_setattr(ap)
nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH+NFSX_SATTR(isnq));
nfsm_fhtom(vp);
nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR(isnq));
- if (vap->va_mode == (u_short)-1)
- sp->sa_mode = VNOVAL;
+ if (vap->va_mode == (u_short)VNOVAL)
+ sp->sa_mode = nfs_xdrneg1;
else
sp->sa_mode = vtonfs_mode(vp->v_type, vap->va_mode);
- if (vap->va_uid == (uid_t)-1)
- sp->sa_uid = VNOVAL;
+ if (vap->va_uid == VNOVAL)
+ sp->sa_uid = nfs_xdrneg1;
else
sp->sa_uid = txdr_unsigned(vap->va_uid);
- if (vap->va_gid == (gid_t)-1)
- sp->sa_gid = VNOVAL;
+ if (vap->va_gid == VNOVAL)
+ sp->sa_gid = nfs_xdrneg1;
else
sp->sa_gid = txdr_unsigned(vap->va_gid);
if (isnq) {
@@ -544,7 +552,7 @@ nfs_setattr(ap)
txdr_nqtime(&vap->va_atime, &sp->sa_nqatime);
txdr_nqtime(&vap->va_mtime, &sp->sa_nqmtime);
sp->sa_nqflags = txdr_unsigned(vap->va_flags);
- sp->sa_nqrdev = VNOVAL;
+ sp->sa_nqrdev = nfs_xdrneg1;
} else {
sp->sa_nfssize = txdr_unsigned(vap->va_size);
txdr_nfstime(&vap->va_atime, &sp->sa_nfsatime);
@@ -573,14 +581,15 @@ nfs_setattr(ap)
* If not found, unlock the directory nfsnode and do the rpc
*/
int
-nfs_lookup(ap)
+nfs_lookup(v)
+ void *v;
+{
struct vop_lookup_args /* {
struct vnodeop_desc *a_desc;
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct componentname *cnp = ap->a_cnp;
register struct vnode *dvp = ap->a_dvp;
register struct vnode **vpp = ap->a_vpp;
@@ -591,14 +600,14 @@ nfs_lookup(ap)
register int32_t t1, t2;
struct nfsmount *nmp;
caddr_t bpos, dpos, cp2;
- time_t reqtime;
+ time_t reqtime = 0;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
struct vnode *newvp;
long len;
nfsv2fh_t *fhp;
struct nfsnode *np;
int lockparent, wantparent, error = 0;
- int nqlflag, cachable;
+ int nqlflag = 0, cachable = 0;
u_quad_t frev;
*vpp = NULL;
@@ -648,7 +657,7 @@ nfs_lookup(ap)
goto cachehit;
}
} else if (!VOP_GETATTR(vdp, &vattr, cnp->cn_cred, cnp->cn_proc) &&
- vattr.va_ctime.ts_sec == VTONFS(vdp)->n_ctime)
+ vattr.va_ctime.tv_sec == VTONFS(vdp)->n_ctime)
goto cachehit;
cache_purge(vdp);
}
@@ -709,13 +718,13 @@ nfsmout:
m_freem(mrep);
return (EISDIR);
}
- if (error = nfs_nget(dvp->v_mount, fhp, &np)) {
+ if ((error = nfs_nget(dvp->v_mount, fhp, &np)) != 0) {
m_freem(mrep);
return (error);
}
newvp = NFSTOV(np);
- if (error =
- nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0)) {
+ error = nfs_loadattrcache(&newvp, &md, &dpos, NULL);
+ if (error) {
vrele(newvp);
m_freem(mrep);
return (error);
@@ -730,13 +739,14 @@ nfsmout:
VREF(dvp);
newvp = dvp;
} else {
- if (error = nfs_nget(dvp->v_mount, fhp, &np)) {
+ if ((error = nfs_nget(dvp->v_mount, fhp, &np)) != 0) {
m_freem(mrep);
return (error);
}
newvp = NFSTOV(np);
}
- if (error = nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0)) {
+ error = nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0);
+ if (error) {
vrele(newvp);
m_freem(mrep);
return (error);
@@ -748,7 +758,7 @@ nfsmout:
if ((cnp->cn_flags & MAKEENTRY) &&
(cnp->cn_nameiop != DELETE || !(flags & ISLASTCN))) {
if ((nmp->nm_flag & NFSMNT_NQNFS) == 0)
- np->n_ctime = np->n_vattr.va_ctime.ts_sec;
+ np->n_ctime = np->n_vattr.va_ctime.tv_sec;
else if (nqlflag && reqtime > time.tv_sec)
nqnfs_clientlease(nmp, np, nqlflag, cachable, reqtime,
frev);
@@ -762,14 +772,15 @@ nfsmout:
* Just call nfs_bioread() to do the work.
*/
int
-nfs_read(ap)
+nfs_read(v)
+ void *v;
+{
struct vop_read_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
if (vp->v_type != VREG)
@@ -781,13 +792,14 @@ nfs_read(ap)
* nfs readlink call
*/
int
-nfs_readlink(ap)
+nfs_readlink(v)
+ void *v;
+{
struct vop_readlink_args /* {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
if (vp->v_type != VLNK)
@@ -927,7 +939,7 @@ nfs_writerpc(vp, uiop, cred, ioflags)
nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp, cred);
nfsm_loadattr(vp, (struct vattr *)0);
if (nmp->nm_flag & NFSMNT_MYWRITE)
- VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.ts_sec;
+ VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.tv_sec;
else if ((nmp->nm_flag & NFSMNT_NQNFS) &&
NQNFS_CKCACHABLE(vp, NQL_WRITE)) {
nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED);
@@ -951,14 +963,15 @@ nfsmout:
*/
/* ARGSUSED */
int
-nfs_mknod(ap)
+nfs_mknod(v)
+ void *v;
+{
struct vop_mknod_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *dvp = ap->a_dvp;
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
@@ -967,7 +980,6 @@ nfs_mknod(ap)
register caddr_t cp;
register int32_t t1, t2;
struct vnode *newvp;
- struct vattr vattr;
char *cp2;
caddr_t bpos, dpos;
int error = 0, isnq;
@@ -985,11 +997,6 @@ nfs_mknod(ap)
vput(dvp);
return (EOPNOTSUPP);
}
- if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
- VOP_ABORTOP(dvp, cnp);
- vput(dvp);
- return (error);
- }
newvp = NULLVP;
nfsstats.rpccnt[NFSPROC_CREATE]++;
isnq = (VFSTONFS(dvp->v_mount)->nm_flag & NFSMNT_NQNFS);
@@ -999,8 +1006,8 @@ nfs_mknod(ap)
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR(isnq));
sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
- sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
- sp->sa_gid = txdr_unsigned(vattr.va_gid);
+ sp->sa_uid = nfs_xdrneg1;
+ sp->sa_gid = nfs_xdrneg1;
if (isnq) {
sp->sa_nqrdev = rdev;
sp->sa_nqflags = 0;
@@ -1029,14 +1036,15 @@ nfs_mknod(ap)
* nfs file create call
*/
int
-nfs_create(ap)
+nfs_create(v)
+ void *v;
+{
struct vop_create_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *dvp = ap->a_dvp;
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
@@ -1047,13 +1055,7 @@ nfs_create(ap)
caddr_t bpos, dpos, cp2;
int error = 0, isnq;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vattr vattr;
- if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
- VOP_ABORTOP(dvp, cnp);
- vput(dvp);
- return (error);
- }
nfsstats.rpccnt[NFSPROC_CREATE]++;
isnq = (VFSTONFS(dvp->v_mount)->nm_flag & NFSMNT_NQNFS);
nfsm_reqhead(dvp, NFSPROC_CREATE,
@@ -1062,13 +1064,13 @@ nfs_create(ap)
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR(isnq));
sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
- sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
- sp->sa_gid = txdr_unsigned(vattr.va_gid);
+ sp->sa_uid = nfs_xdrneg1;
+ sp->sa_gid = nfs_xdrneg1;
if (isnq) {
u_quad_t qval = 0;
txdr_hyper(&qval, &sp->sa_nqsize);
- sp->sa_nqrdev = -1;
+ sp->sa_nqrdev = nfs_xdrneg1;
sp->sa_nqflags = 0;
txdr_nqtime(&vap->va_atime, &sp->sa_nqatime);
txdr_nqtime(&vap->va_mtime, &sp->sa_nqmtime);
@@ -1101,14 +1103,15 @@ nfs_create(ap)
* do the remove rpc
*/
int
-nfs_remove(ap)
+nfs_remove(v)
+ void *v;
+{
struct vop_remove_args /* {
struct vnodeop_desc *a_desc;
struct vnode * a_dvp;
struct vnode * a_vp;
struct componentname * a_cnp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct vnode *dvp = ap->a_dvp;
register struct componentname *cnp = ap->a_cnp;
@@ -1207,7 +1210,9 @@ nfs_removeit(sp)
* nfs file rename call
*/
int
-nfs_rename(ap)
+nfs_rename(v)
+ void *v;
+{
struct vop_rename_args /* {
struct vnode *a_fdvp;
struct vnode *a_fvp;
@@ -1215,8 +1220,7 @@ nfs_rename(ap)
struct vnode *a_tdvp;
struct vnode *a_tvp;
struct componentname *a_tcnp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *fvp = ap->a_fvp;
register struct vnode *tvp = ap->a_tvp;
register struct vnode *fdvp = ap->a_fdvp;
@@ -1310,15 +1314,16 @@ nfs_renameit(sdvp, scnp, sp)
* nfs hard link create call
*/
int
-nfs_link(ap)
+nfs_link(v)
+ void *v;
+{
struct vop_link_args /* {
+ struct vnode *a_dvp;
struct vnode *a_vp;
- struct vnode *a_tdvp;
struct componentname *a_cnp;
- } */ *ap;
-{
+ } */ *ap = v;
+ register struct vnode *dvp = ap->a_dvp;
register struct vnode *vp = ap->a_vp;
- register struct vnode *tdvp = ap->a_tdvp;
register struct componentname *cnp = ap->a_cnp;
register u_int32_t *tl;
register caddr_t cp;
@@ -1327,12 +1332,12 @@ nfs_link(ap)
int error = 0;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- if (vp->v_mount != tdvp->v_mount) {
- /*VOP_ABORTOP(vp, cnp);*/
- if (tdvp == vp)
- vrele(vp);
+ if (dvp->v_mount != vp->v_mount) {
+ /*VOP_ABORTOP(dvp, cnp);*/
+ if (vp == dvp)
+ vrele(dvp);
else
- vput(vp);
+ vput(dvp);
return (EXDEV);
}
@@ -1341,21 +1346,21 @@ nfs_link(ap)
* doesn't get "out of sync" with the server.
* XXX There should be a better way!
*/
- VOP_FSYNC(tdvp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc);
+ VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc);
nfsstats.rpccnt[NFSPROC_LINK]++;
- nfsm_reqhead(tdvp, NFSPROC_LINK,
+ nfsm_reqhead(vp, NFSPROC_LINK,
NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen));
- nfsm_fhtom(tdvp);
nfsm_fhtom(vp);
+ nfsm_fhtom(dvp);
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- nfsm_request(tdvp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred);
+ nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred);
nfsm_reqdone;
FREE(cnp->cn_pnbuf, M_NAMEI);
- VTONFS(tdvp)->n_attrstamp = 0;
- VTONFS(vp)->n_flag |= NMODIFIED;
VTONFS(vp)->n_attrstamp = 0;
- vrele(vp);
+ VTONFS(dvp)->n_flag |= NMODIFIED;
+ VTONFS(dvp)->n_attrstamp = 0;
+ vrele(dvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
@@ -1369,15 +1374,16 @@ nfs_link(ap)
*/
/* start here */
int
-nfs_symlink(ap)
+nfs_symlink(v)
+ void *v;
+{
struct vop_symlink_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
char *a_target;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *dvp = ap->a_dvp;
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
@@ -1399,8 +1405,8 @@ nfs_symlink(ap)
nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN);
nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR(isnq));
sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode);
- sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
- sp->sa_gid = txdr_unsigned(cnp->cn_cred->cr_gid);
+ sp->sa_uid = nfs_xdrneg1;
+ sp->sa_gid = nfs_xdrneg1;
if (isnq) {
quad_t qval = -1;
@@ -1409,7 +1415,7 @@ nfs_symlink(ap)
txdr_nqtime(&vap->va_atime, &sp->sa_nqatime);
txdr_nqtime(&vap->va_mtime, &sp->sa_nqmtime);
} else {
- sp->sa_nfssize = -1;
+ sp->sa_nfssize = nfs_xdrneg1;
txdr_nfstime(&vap->va_atime, &sp->sa_nfsatime);
txdr_nfstime(&vap->va_mtime, &sp->sa_nfsmtime);
}
@@ -1431,14 +1437,15 @@ nfs_symlink(ap)
* nfs make dir call
*/
int
-nfs_mkdir(ap)
+nfs_mkdir(v)
+ void *v;
+{
struct vop_mkdir_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *dvp = ap->a_dvp;
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
@@ -1451,13 +1458,7 @@ nfs_mkdir(ap)
caddr_t bpos, dpos, cp2;
int error = 0, firsttry = 1, isnq;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vattr vattr;
- if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
- VOP_ABORTOP(dvp, cnp);
- vput(dvp);
- return (error);
- }
len = cnp->cn_namelen;
isnq = (VFSTONFS(dvp->v_mount)->nm_flag & NFSMNT_NQNFS);
nfsstats.rpccnt[NFSPROC_MKDIR]++;
@@ -1467,8 +1468,8 @@ nfs_mkdir(ap)
nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR(isnq));
sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode);
- sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
- sp->sa_gid = txdr_unsigned(vattr.va_gid);
+ sp->sa_uid = nfs_xdrneg1;
+ sp->sa_gid = nfs_xdrneg1;
if (isnq) {
quad_t qval = -1;
@@ -1477,7 +1478,7 @@ nfs_mkdir(ap)
txdr_nqtime(&vap->va_atime, &sp->sa_nqatime);
txdr_nqtime(&vap->va_mtime, &sp->sa_nqmtime);
} else {
- sp->sa_nfssize = -1;
+ sp->sa_nfssize = nfs_xdrneg1;
txdr_nfstime(&vap->va_atime, &sp->sa_nfsatime);
txdr_nfstime(&vap->va_mtime, &sp->sa_nfsmtime);
}
@@ -1518,13 +1519,14 @@ nfs_mkdir(ap)
* nfs remove directory call
*/
int
-nfs_rmdir(ap)
+nfs_rmdir(v)
+ void *v;
+{
struct vop_rmdir_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct vnode *dvp = ap->a_dvp;
register struct componentname *cnp = ap->a_cnp;
@@ -1570,7 +1572,9 @@ nfs_rmdir(ap)
* Ultrix implementation of NFS.
*/
int
-nfs_readdir(ap)
+nfs_readdir(v)
+ void *v;
+{
struct vop_readdir_args /* {
struct vnode *a_vp;
struct uio *a_uio;
@@ -1578,8 +1582,7 @@ nfs_readdir(ap)
int *a_eofflag;
u_long *a_cookies;
int a_ncookies;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
register struct uio *uio = ap->a_uio;
@@ -1600,7 +1603,7 @@ nfs_readdir(ap)
return (0);
}
} else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) == 0 &&
- np->n_mtime == vattr.va_mtime.ts_sec) {
+ np->n_mtime == vattr.va_mtime.tv_sec) {
nfsstats.direofcache_hits++;
return (0);
}
@@ -1655,11 +1658,11 @@ nfs_readdirrpc(vp, uiop, cred)
struct ucred *cred;
{
register long len;
- register struct dirent *dp;
+ register struct dirent *dp = NULL;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1;
- long tlen, lastlen;
+ long tlen, lastlen = 0;
caddr_t bpos, dpos, cp2;
int error = 0;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
@@ -1667,8 +1670,8 @@ nfs_readdirrpc(vp, uiop, cred)
caddr_t dpos2;
int siz;
int more_dirs = 1;
- u_long off, savoff;
- struct dirent *savdp;
+ u_long off = 0, savoff = 0;
+ struct dirent *savdp = NULL;
struct nfsmount *nmp;
struct nfsnode *np = VTONFS(vp);
long tresid, extra;
@@ -1804,7 +1807,7 @@ nfs_readdirlookrpc(vp, uiop, cred)
struct ucred *cred;
{
register int len;
- register struct dirent *dp;
+ register struct dirent *dp = NULL;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1;
@@ -1812,15 +1815,15 @@ nfs_readdirlookrpc(vp, uiop, cred)
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
struct nameidata nami, *ndp = &nami;
struct componentname *cnp = &ndp->ni_cnd;
- u_long off, endoff, fileno;
- time_t reqtime, ltime;
+ u_long off = 0, endoff = 0, fileno;
+ time_t reqtime, ltime = 0;
struct nfsmount *nmp;
struct nfsnode *np;
struct vnode *newvp;
nfsv2fh_t *fhp;
u_quad_t frev;
int error = 0, tlen, more_dirs = 1, tresid, doit, bigenough, i;
- int cachable;
+ int cachable = 0;
if (uiop->uio_iovcnt != 1)
panic("nfs rdirlook");
@@ -1868,12 +1871,13 @@ nfs_readdirlookrpc(vp, uiop, cred)
newvp = vp;
np = VTONFS(vp);
} else {
- if (error = nfs_nget(vp->v_mount, fhp, &np))
+ error = nfs_nget(vp->v_mount, fhp, &np);
+ if (error)
doit = 0;
newvp = NFSTOV(np);
}
- if (error = nfs_loadattrcache(&newvp, &md, &dpos,
- (struct vattr *)0))
+ error = nfs_loadattrcache(&newvp, &md, &dpos, NULL);
+ if (error)
doit = 0;
nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
fileno = fxdr_unsigned(u_int32_t, *tl++);
@@ -2019,7 +2023,7 @@ nfs_sillyrename(dvp, vp, cnp)
goto bad;
}
}
- if (error = nfs_renameit(dvp, cnp, sp))
+ if ((error = nfs_renameit(dvp, cnp, sp)) != 0)
goto bad;
nfs_lookitup(sp, &np->n_fh, cnp->cn_proc);
np->n_sillyrename = sp;
@@ -2087,15 +2091,16 @@ nfs_lookitup(sp, fhp, procp)
* context of the swapper process (2).
*/
int
-nfs_bmap(ap)
+nfs_bmap(v)
+ void *v;
+{
struct vop_bmap_args /* {
struct vnode *a_vp;
daddr_t a_bn;
struct vnode **a_vpp;
daddr_t *a_bnp;
int *a_runp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
if (ap->a_vpp != NULL)
@@ -2112,9 +2117,10 @@ nfs_bmap(ap)
* request.
*/
int
-nfs_strategy(ap)
- struct vop_strategy_args *ap;
+nfs_strategy(v)
+ void *v;
{
+ struct vop_strategy_args *ap = v;
register struct buf *bp = ap->a_bp;
struct ucred *cr;
struct proc *p;
@@ -2148,14 +2154,17 @@ nfs_strategy(ap)
*/
/* ARGSUSED */
int
-nfs_mmap(ap)
+nfs_mmap(v)
+ void *v;
+{
+#if 0
struct vop_mmap_args /* {
struct vnode *a_vp;
int a_fflags;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (EINVAL);
}
@@ -2167,15 +2176,16 @@ nfs_mmap(ap)
*/
/* ARGSUSED */
int
-nfs_fsync(ap)
+nfs_fsync(v)
+ void *v;
+{
struct vop_fsync_args /* {
struct vnodeop_desc *a_desc;
struct vnode * a_vp;
struct ucred * a_cred;
int a_waitfor;
struct proc * a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
register struct buf *bp;
@@ -2252,13 +2262,17 @@ loop:
* information from the remote server.
*/
/* ARGSUSED */
-nfs_pathconf(ap)
+int
+nfs_pathconf(v)
+ void *v;
+{
+#if 0
struct vop_pathconf_args /* {
struct vnode *a_vp;
int a_name;
register_t *a_retval;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (EINVAL);
}
@@ -2267,15 +2281,16 @@ nfs_pathconf(ap)
* NFS advisory byte-level locks.
*/
int
-nfs_advlock(ap)
+nfs_advlock(v)
+ void *v;
+{
struct vop_advlock_args /* {
struct vnode *a_vp;
caddr_t a_id;
int a_op;
struct flock *a_fl;
int a_flags;
- } */ *ap;
-{
+ } */ *ap = v;
register struct nfsnode *np = VTONFS(ap->a_vp);
return (lf_advlock(&np->n_lockf, np->n_size, ap->a_id, ap->a_op,
@@ -2286,11 +2301,12 @@ nfs_advlock(ap)
* Print out the contents of an nfsnode.
*/
int
-nfs_print(ap)
+nfs_print(v)
+ void *v;
+{
struct vop_print_args /* {
struct vnode *a_vp;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
@@ -2301,6 +2317,7 @@ nfs_print(ap)
fifo_printinfo(vp);
#endif /* FIFO */
printf("\n");
+ return 0;
}
/*
@@ -2308,14 +2325,17 @@ nfs_print(ap)
* Currently unsupported.
*/
int
-nfs_blkatoff(ap)
+nfs_blkatoff(v)
+ void *v;
+{
+#if 0
struct vop_blkatoff_args /* {
struct vnode *a_vp;
off_t a_offset;
char **a_res;
struct buf **a_bpp;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (EOPNOTSUPP);
}
@@ -2325,14 +2345,17 @@ nfs_blkatoff(ap)
* Currently unsupported.
*/
int
-nfs_valloc(ap)
+nfs_valloc(v)
+ void *v;
+{
+#if 0
struct vop_valloc_args /* {
struct vnode *a_pvp;
int a_mode;
struct ucred *a_cred;
struct vnode **a_vpp;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (EOPNOTSUPP);
}
@@ -2342,13 +2365,16 @@ nfs_valloc(ap)
* Currently unsupported.
*/
int
-nfs_vfree(ap)
+nfs_vfree(v)
+ void *v;
+{
+#if 0
struct vop_vfree_args /* {
struct vnode *a_pvp;
ino_t a_ino;
int a_mode;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
return (EOPNOTSUPP);
}
@@ -2357,15 +2383,18 @@ nfs_vfree(ap)
* NFS file truncation.
*/
int
-nfs_truncate(ap)
+nfs_truncate(v)
+ void *v;
+{
+#if 0
struct vop_truncate_args /* {
struct vnode *a_vp;
off_t a_length;
int a_flags;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
/* Use nfs_setattr */
printf("nfs_truncate: need to implement!!");
@@ -2376,14 +2405,17 @@ nfs_truncate(ap)
* NFS update.
*/
int
-nfs_update(ap)
+nfs_update(v)
+ void *v;
+{
+#if 0
struct vop_update_args /* {
struct vnode *a_vp;
struct timeval *a_ta;
struct timeval *a_tm;
int a_waitfor;
- } */ *ap;
-{
+ } */ *ap = v;
+#endif
/* Use nfs_setattr */
printf("nfs_update: need to implement!!");
@@ -2396,18 +2428,19 @@ nfs_update(ap)
* local to the client.
*/
int
-nfsspec_access(ap)
+nfsspec_access(v)
+ void *v;
+{
struct vop_access_args /* {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
struct vattr va;
int error;
- if (error = VOP_GETATTR(ap->a_vp, &va, ap->a_cred, ap->a_p))
+ if ((error = VOP_GETATTR(ap->a_vp, &va, ap->a_cred, ap->a_p)) != 0)
return (error);
return (vaccess(va.va_mode, va.va_uid, va.va_gid, ap->a_mode,
@@ -2418,14 +2451,15 @@ nfsspec_access(ap)
* Read wrapper for special devices.
*/
int
-nfsspec_read(ap)
+nfsspec_read(v)
+ void *v;
+{
struct vop_read_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
+ } */ *ap = v;
register struct nfsnode *np = VTONFS(ap->a_vp);
/*
@@ -2440,14 +2474,15 @@ nfsspec_read(ap)
* Write wrapper for special devices.
*/
int
-nfsspec_write(ap)
+nfsspec_write(v)
+ void *v;
+{
struct vop_write_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
+ } */ *ap = v;
register struct nfsnode *np = VTONFS(ap->a_vp);
/*
@@ -2464,14 +2499,15 @@ nfsspec_write(ap)
* Update the times on the nfsnode then do device close.
*/
int
-nfsspec_close(ap)
+nfsspec_close(v)
+ void *v;
+{
struct vop_close_args /* {
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
struct vattr vattr;
@@ -2482,13 +2518,13 @@ nfsspec_close(ap)
(vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
VATTR_NULL(&vattr);
if (np->n_flag & NACC) {
- vattr.va_atime.ts_sec = np->n_atim.tv_sec;
- vattr.va_atime.ts_nsec =
+ vattr.va_atime.tv_sec = np->n_atim.tv_sec;
+ vattr.va_atime.tv_nsec =
np->n_atim.tv_usec * 1000;
}
if (np->n_flag & NUPD) {
- vattr.va_mtime.ts_sec = np->n_mtim.tv_sec;
- vattr.va_mtime.ts_nsec =
+ vattr.va_mtime.tv_sec = np->n_mtim.tv_sec;
+ vattr.va_mtime.tv_nsec =
np->n_mtim.tv_usec * 1000;
}
(void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p);
@@ -2502,15 +2538,16 @@ nfsspec_close(ap)
* Read wrapper for fifos.
*/
int
-nfsfifo_read(ap)
+nfsfifo_read(v)
+ void *v;
+{
struct vop_read_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
- extern int (**fifo_vnodeop_p)();
+ } */ *ap = v;
+ extern int (**fifo_vnodeop_p) __P((void *));
register struct nfsnode *np = VTONFS(ap->a_vp);
/*
@@ -2525,15 +2562,16 @@ nfsfifo_read(ap)
* Write wrapper for fifos.
*/
int
-nfsfifo_write(ap)
+nfsfifo_write(v)
+ void *v;
+{
struct vop_write_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
- } */ *ap;
-{
- extern int (**fifo_vnodeop_p)();
+ } */ *ap = v;
+ extern int (**fifo_vnodeop_p) __P((void *));
register struct nfsnode *np = VTONFS(ap->a_vp);
/*
@@ -2550,18 +2588,19 @@ nfsfifo_write(ap)
* Update the times on the nfsnode then do fifo close.
*/
int
-nfsfifo_close(ap)
+nfsfifo_close(v)
+ void *v;
+{
struct vop_close_args /* {
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap;
-{
+ } */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct nfsnode *np = VTONFS(vp);
struct vattr vattr;
- extern int (**fifo_vnodeop_p)();
+ extern int (**fifo_vnodeop_p) __P((void *));
if (np->n_flag & (NACC | NUPD)) {
if (np->n_flag & NACC)
@@ -2573,13 +2612,13 @@ nfsfifo_close(ap)
(vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
VATTR_NULL(&vattr);
if (np->n_flag & NACC) {
- vattr.va_atime.ts_sec = np->n_atim.tv_sec;
- vattr.va_atime.ts_nsec =
+ vattr.va_atime.tv_sec = np->n_atim.tv_sec;
+ vattr.va_atime.tv_nsec =
np->n_atim.tv_usec * 1000;
}
if (np->n_flag & NUPD) {
- vattr.va_mtime.ts_sec = np->n_mtim.tv_sec;
- vattr.va_mtime.ts_nsec =
+ vattr.va_mtime.tv_sec = np->n_mtim.tv_sec;
+ vattr.va_mtime.tv_nsec =
np->n_mtim.tv_usec * 1000;
}
(void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p);
diff --git a/sys/nfs/nfsdiskless.h b/sys/nfs/nfsdiskless.h
index c4dc461f775..a1be7ec8b9d 100644
--- a/sys/nfs/nfsdiskless.h
+++ b/sys/nfs/nfsdiskless.h
@@ -1,4 +1,5 @@
-/* $NetBSD: nfsdiskless.h,v 1.7 1994/06/29 06:42:31 cgd Exp $ */
+/* $OpenBSD: nfsdiskless.h,v 1.2 1996/02/29 09:25:01 niklas Exp $ */
+/* $NetBSD: nfsdiskless.h,v 1.8 1996/02/13 17:53:32 gwr Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -55,6 +56,12 @@ struct nfs_dlmount {
u_char ndm_fh[NFS_FHSIZE]; /* The file's file handle */
};
struct nfs_diskless {
+ struct sockaddr_in nd_boot; /* Address of boot server */
struct nfs_dlmount nd_root; /* Mount info for root */
struct nfs_dlmount nd_swap; /* Mount info for swap */
};
+
+int nfs_boot_init __P((struct nfs_diskless *nd, struct proc *procp));
+void nfs_boot_getfh __P((struct sockaddr_in *bpsin, char *key,
+ struct nfs_dlmount *ndmntp));
+
diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h
index c2ff58a2de5..1ab31782df1 100644
--- a/sys/nfs/nfsm_subs.h
+++ b/sys/nfs/nfsm_subs.h
@@ -1,4 +1,5 @@
-/* $NetBSD: nfsm_subs.h,v 1.7 1995/12/19 23:08:00 cgd Exp $ */
+/* $OpenBSD: nfsm_subs.h,v 1.3 1996/02/29 09:25:02 niklas Exp $ */
+/* $NetBSD: nfsm_subs.h,v 1.8 1996/02/09 21:48:43 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -47,8 +48,6 @@
/*
* First define what the actual subs. return
*/
-extern struct mbuf *nfsm_reqh();
-
#define M_HASCL(m) ((m)->m_flags & M_EXT)
#define NFSMINOFF(m) \
if (M_HASCL(m)) \
@@ -93,7 +92,8 @@ extern struct mbuf *nfsm_reqh();
if (t1 >= (s)) { \
(a) = (c)(dpos); \
dpos += (s); \
- } else if (error = nfsm_disct(&md, &dpos, (s), t1, &cp2)) { \
+ } else if ((error = nfsm_disct(&md, &dpos, \
+ (s), t1, &cp2)) != 0) { \
m_freem(mrep); \
goto nfsmout; \
} else { \
@@ -111,7 +111,7 @@ extern struct mbuf *nfsm_reqh();
#define nfsm_mtofh(d,v) \
{ struct nfsnode *np; nfsv2fh_t *fhp; \
nfsm_dissect(fhp,nfsv2fh_t *,NFSX_FH); \
- if (error = nfs_nget((d)->v_mount, fhp, &np)) { \
+ if ((error = nfs_nget((d)->v_mount, fhp, &np)) != 0) { \
m_freem(mrep); \
goto nfsmout; \
} \
@@ -121,7 +121,7 @@ extern struct mbuf *nfsm_reqh();
#define nfsm_loadattr(v,a) \
{ struct vnode *tvp = (v); \
- if (error = nfs_loadattrcache(&tvp, &md, &dpos, (a))) { \
+ if ((error = nfs_loadattrcache(&tvp, &md, &dpos, (a))) != 0) { \
m_freem(mrep); \
goto nfsmout; \
} \
@@ -144,13 +144,13 @@ extern struct mbuf *nfsm_reqh();
#define nfsm_mtouio(p,s) \
if ((s) > 0 && \
- (error = nfsm_mbuftouio(&md,(p),(s),&dpos))) { \
+ (error = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
m_freem(mrep); \
goto nfsmout; \
}
#define nfsm_uiotom(p,s) \
- if (error = nfsm_uiotombuf((p),&mb,(s),&bpos)) { \
+ if ((error = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
m_freem(mreq); \
goto nfsmout; \
}
@@ -164,8 +164,8 @@ extern struct mbuf *nfsm_reqh();
#define nfsm_rndup(a) (((a)+3)&(~0x3))
#define nfsm_request(v, t, p, c) \
- if (error = nfs_request((v), mreq, (t), (p), \
- (c), &mrep, &md, &dpos)) \
+ if ((error = nfs_request((v), mreq, (t), (p), \
+ (c), &mrep, &md, &dpos)) != 0) \
goto nfsmout
#define nfsm_strtom(a,s,m) \
@@ -180,7 +180,8 @@ extern struct mbuf *nfsm_reqh();
*tl++ = txdr_unsigned(s); \
*(tl+((t2>>2)-2)) = 0; \
bcopy((caddr_t)(a), (caddr_t)tl, (s)); \
- } else if (error = nfsm_strtmbuf(&mb, &bpos, (a), (s))) { \
+ } else if ((error = nfsm_strtmbuf(&mb, &bpos, \
+ (a), (s))) != 0) { \
m_freem(mreq); \
goto nfsmout; \
}
@@ -208,7 +209,7 @@ extern struct mbuf *nfsm_reqh();
t1 = mtod(md, caddr_t)+md->m_len-dpos; \
if (t1 >= (s)) { \
dpos += (s); \
- } else if (error = nfs_adv(&md, &dpos, (s), t1)) { \
+ } else if ((error = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
m_freem(mrep); \
goto nfsmout; \
}
diff --git a/sys/nfs/nfsmount.h b/sys/nfs/nfsmount.h
index 4ad22bcf0ff..14c64adb710 100644
--- a/sys/nfs/nfsmount.h
+++ b/sys/nfs/nfsmount.h
@@ -1,4 +1,5 @@
-/* $NetBSD: nfsmount.h,v 1.8 1995/03/26 20:37:31 jtc Exp $ */
+/* $OpenBSD: nfsmount.h,v 1.2 1996/02/29 09:25:03 niklas Exp $ */
+/* $NetBSD: nfsmount.h,v 1.9 1996/02/09 21:48:44 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -78,51 +79,26 @@ struct nfsmount {
* Convert mount ptr to nfsmount ptr.
*/
#define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data))
-#endif /* _KERNEL */
/*
* Prototypes for NFS mount operations
*/
-int nfs_mount __P((
- struct mount *mp,
- char *path,
- caddr_t data,
- struct nameidata *ndp,
- struct proc *p));
-int nfs_start __P((
- struct mount *mp,
- int flags,
- struct proc *p));
-int nfs_unmount __P((
- struct mount *mp,
- int mntflags,
- struct proc *p));
-int nfs_root __P((
- struct mount *mp,
- struct vnode **vpp));
-int nfs_quotactl __P((
- struct mount *mp,
- int cmds,
- uid_t uid,
- caddr_t arg,
- struct proc *p));
-int nfs_statfs __P((
- struct mount *mp,
- struct statfs *sbp,
- struct proc *p));
-int nfs_sync __P((
- struct mount *mp,
- int waitfor,
- struct ucred *cred,
- struct proc *p));
-int nfs_fhtovp __P((
- struct mount *mp,
- struct fid *fhp,
- struct mbuf *nam,
- struct vnode **vpp,
- int *exflagsp,
- struct ucred **credanonp));
-int nfs_vptofh __P((
- struct vnode *vp,
- struct fid *fhp));
-int nfs_init __P(());
+int nfs_statfs __P((struct mount *, struct statfs *, struct proc *));
+int nfs_mountroot __P((void));
+void nfs_decode_args __P((struct nfsmount *, struct nfs_args *));
+int nfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *,
+ struct proc *));
+int mountnfs __P((struct nfs_args *, struct mount *, struct mbuf *, char *,
+ char *, struct vnode **));
+int nfs_unmount __P((struct mount *, int, struct proc *));
+int nfs_root __P((struct mount *, struct vnode **));
+int nfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
+int nfs_vget __P((struct mount *, ino_t, struct vnode **));
+int nfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
+ struct vnode **, int *, struct ucred **));
+int nfs_vptofh __P((struct vnode *, struct fid *));
+int nfs_start __P((struct mount *, int, struct proc *));
+int nfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
+void nfs_init __P((void));
+
+#endif /* _KERNEL */
diff --git a/sys/nfs/nfsnode.h b/sys/nfs/nfsnode.h
index 8ee133e85a1..6d18b325ad7 100644
--- a/sys/nfs/nfsnode.h
+++ b/sys/nfs/nfsnode.h
@@ -1,4 +1,5 @@
-/* $NetBSD: nfsnode.h,v 1.14 1995/03/26 20:37:32 jtc Exp $ */
+/* $OpenBSD: nfsnode.h,v 1.2 1996/02/29 09:25:04 niklas Exp $ */
+/* $NetBSD: nfsnode.h,v 1.15 1996/02/09 21:48:47 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -109,59 +110,60 @@ TAILQ_HEAD(, buf) nfs_bufq;
/*
* Prototypes for NFS vnode operations
*/
-int nfs_lookup __P((struct vop_lookup_args *));
-int nfs_create __P((struct vop_create_args *));
-int nfs_mknod __P((struct vop_mknod_args *));
-int nfs_open __P((struct vop_open_args *));
-int nfs_close __P((struct vop_close_args *));
-int nfsspec_close __P((struct vop_close_args *));
+int nfs_lookup __P((void *));
+int nfs_create __P((void *));
+int nfs_mknod __P((void *));
+int nfs_open __P((void *));
+int nfs_close __P((void *));
+int nfsspec_close __P((void *));
#ifdef FIFO
-int nfsfifo_close __P((struct vop_close_args *));
+int nfsfifo_close __P((void *));
#endif
-int nfs_access __P((struct vop_access_args *));
-int nfsspec_access __P((struct vop_access_args *));
-int nfs_getattr __P((struct vop_getattr_args *));
-int nfs_setattr __P((struct vop_setattr_args *));
-int nfs_read __P((struct vop_read_args *));
-int nfs_write __P((struct vop_write_args *));
-#define nfs_lease_check ((int (*) __P((struct vop_lease_args *)))nullop)
-int nfsspec_read __P((struct vop_read_args *));
-int nfsspec_write __P((struct vop_write_args *));
+int nfs_access __P((void *));
+int nfsspec_access __P((void *));
+int nfs_getattr __P((void *));
+int nfs_setattr __P((void *));
+int nfs_read __P((void *));
+int nfs_write __P((void *));
+#define nfs_lease_check (int (*) __P((void *))) nullop
+int nfsspec_read __P((void *));
+int nfsspec_write __P((void *));
#ifdef FIFO
-int nfsfifo_read __P((struct vop_read_args *));
-int nfsfifo_write __P((struct vop_write_args *));
+int nfsfifo_read __P((void *));
+int nfsfifo_write __P((void *));
#endif
-#define nfs_ioctl ((int (*) __P((struct vop_ioctl_args *)))enoioctl)
-#define nfs_select ((int (*) __P((struct vop_select_args *)))seltrue)
-int nfs_mmap __P((struct vop_mmap_args *));
-int nfs_fsync __P((struct vop_fsync_args *));
-#define nfs_seek ((int (*) __P((struct vop_seek_args *)))nullop)
-int nfs_remove __P((struct vop_remove_args *));
-int nfs_link __P((struct vop_link_args *));
-int nfs_rename __P((struct vop_rename_args *));
-int nfs_mkdir __P((struct vop_mkdir_args *));
-int nfs_rmdir __P((struct vop_rmdir_args *));
-int nfs_symlink __P((struct vop_symlink_args *));
-int nfs_readdir __P((struct vop_readdir_args *));
-int nfs_readlink __P((struct vop_readlink_args *));
-int nfs_abortop __P((struct vop_abortop_args *));
-int nfs_inactive __P((struct vop_inactive_args *));
-int nfs_reclaim __P((struct vop_reclaim_args *));
-int nfs_lock __P((struct vop_lock_args *));
-int nfs_unlock __P((struct vop_unlock_args *));
-int nfs_bmap __P((struct vop_bmap_args *));
-int nfs_strategy __P((struct vop_strategy_args *));
-int nfs_print __P((struct vop_print_args *));
-int nfs_islocked __P((struct vop_islocked_args *));
-int nfs_pathconf __P((struct vop_pathconf_args *));
-int nfs_advlock __P((struct vop_advlock_args *));
-int nfs_blkatoff __P((struct vop_blkatoff_args *));
-int nfs_vget __P((struct mount *, ino_t, struct vnode **));
-int nfs_valloc __P((struct vop_valloc_args *));
-#define nfs_reallocblks \
- ((int (*) __P((struct vop_reallocblks_args *)))eopnotsupp)
-int nfs_vfree __P((struct vop_vfree_args *));
-int nfs_truncate __P((struct vop_truncate_args *));
-int nfs_update __P((struct vop_update_args *));
-int nfs_bwrite __P((struct vop_bwrite_args *));
+#define nfs_ioctl (int (*) __P((void *))) enoioctl
+#define nfs_select (int (*) __P((void *))) seltrue
+int nfs_mmap __P((void *));
+int nfs_fsync __P((void *));
+#define nfs_seek (int (*) __P((void *))) nullop
+int nfs_remove __P((void *));
+int nfs_link __P((void *));
+int nfs_rename __P((void *));
+int nfs_mkdir __P((void *));
+int nfs_rmdir __P((void *));
+int nfs_symlink __P((void *));
+int nfs_readdir __P((void *));
+int nfs_readlink __P((void *));
+int nfs_abortop __P((void *));
+int nfs_inactive __P((void *));
+int nfs_reclaim __P((void *));
+int nfs_lock __P((void *));
+int nfs_unlock __P((void *));
+int nfs_bmap __P((void *));
+int nfs_strategy __P((void *));
+int nfs_print __P((void *));
+int nfs_islocked __P((void *));
+int nfs_pathconf __P((void *));
+int nfs_advlock __P((void *));
+int nfs_blkatoff __P((void *));
+int nfs_valloc __P((void *));
+#define nfs_reallocblks (int (*) __P((void *))) eopnotsupp
+int nfs_vfree __P((void *));
+int nfs_truncate __P((void *));
+int nfs_update __P((void *));
+int nfs_bwrite __P((void *));
+
+extern int (**nfsv2_vnodeop_p) __P((void *));
+
#endif /* _KERNEL */
diff --git a/sys/nfs/xdr_subs.h b/sys/nfs/xdr_subs.h
index cf3cfe9769f..bb6e721cdf2 100644
--- a/sys/nfs/xdr_subs.h
+++ b/sys/nfs/xdr_subs.h
@@ -1,4 +1,5 @@
-/* $NetBSD: xdr_subs.h,v 1.9 1995/12/19 23:08:30 cgd Exp $ */
+/* $OpenBSD: xdr_subs.h,v 1.3 1996/02/29 09:25:04 niklas Exp $ */
+/* $NetBSD: xdr_subs.h,v 1.10 1996/02/01 00:41:32 jtc Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -53,24 +54,24 @@
#define txdr_unsigned(v) (htonl((int32_t)(v)))
#define fxdr_nfstime(f, t) { \
- (t)->ts_sec = ntohl((f)->nfs_sec); \
+ (t)->tv_sec = ntohl((f)->nfs_sec); \
if ((f)->nfs_usec != 0xffffffff) \
- (t)->ts_nsec = 1000 * ntohl((f)->nfs_usec); \
+ (t)->tv_nsec = 1000 * ntohl((f)->nfs_usec); \
else \
- (t)->ts_nsec = 0; \
+ (t)->tv_nsec = 0; \
}
#define txdr_nfstime(f, t) { \
- (t)->nfs_sec = htonl((f)->ts_sec); \
- (t)->nfs_usec = htonl((f)->ts_nsec) / 1000; \
+ (t)->nfs_sec = htonl((f)->tv_sec); \
+ (t)->nfs_usec = htonl((f)->tv_nsec) / 1000; \
}
#define fxdr_nqtime(f, t) { \
- (t)->ts_sec = ntohl((f)->nq_sec); \
- (t)->ts_nsec = ntohl((f)->nq_nsec); \
+ (t)->tv_sec = ntohl((f)->nq_sec); \
+ (t)->tv_nsec = ntohl((f)->nq_nsec); \
}
#define txdr_nqtime(f, t) { \
- (t)->nq_sec = htonl((f)->ts_sec); \
- (t)->nq_nsec = htonl((f)->ts_nsec); \
+ (t)->nq_sec = htonl((f)->tv_sec); \
+ (t)->nq_nsec = htonl((f)->tv_nsec); \
}
#define fxdr_hyper(f, t) { \