summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/vfs_syscalls.c11
-rw-r--r--sys/kern/vnode_if.c4
-rw-r--r--sys/kern/vnode_if.src14
-rw-r--r--sys/nfs/nfs_serv.c45
-rw-r--r--sys/nfs/nfs_vnops.c30
-rw-r--r--sys/ufs/ext2fs/ext2fs_vnops.c12
-rw-r--r--sys/ufs/ufs/ufs_vnops.c13
7 files changed, 62 insertions, 67 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index a8db38f7ece..2e1cf5f8103 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.79 2001/07/26 02:10:41 assar Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.80 2001/07/26 20:24:47 millert Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -1249,8 +1249,6 @@ sys_mknod(p, v, retval)
} else {
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
&nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
}
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -1301,10 +1299,7 @@ sys_mkfifo(p, v, retval)
vattr.va_type = VFIFO;
vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
- return (error);
+ return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
#endif /* FIFO */
}
@@ -1398,8 +1393,6 @@ sys_symlink(p, v, retval)
vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
- if (error == 0)
- vput(nd.ni_vp);
out:
FREE(path, M_NAMEI);
return (error);
diff --git a/sys/kern/vnode_if.c b/sys/kern/vnode_if.c
index f5f698b6c13..1f30d85c507 100644
--- a/sys/kern/vnode_if.c
+++ b/sys/kern/vnode_if.c
@@ -154,7 +154,7 @@ int vop_mknod_vp_offsets[] = {
struct vnodeop_desc vop_mknod_desc = {
0,
"vop_mknod",
- 0 | VDESC_VP0_WILLRELE,
+ 0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE,
vop_mknod_vp_offsets,
VOPARG_OFFSETOF(struct vop_mknod_args, a_vpp),
VDESC_NO_OFFSET,
@@ -797,7 +797,7 @@ int vop_symlink_vp_offsets[] = {
struct vnodeop_desc vop_symlink_desc = {
0,
"vop_symlink",
- 0 | VDESC_VP0_WILLRELE,
+ 0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE,
vop_symlink_vp_offsets,
VOPARG_OFFSETOF(struct vop_symlink_args, a_vpp),
VDESC_NO_OFFSET,
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index e75c931d1a8..fdf8e6e4015 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -1,4 +1,4 @@
-# $OpenBSD: vnode_if.src,v 1.12 2001/07/26 02:10:41 assar Exp $
+# $OpenBSD: vnode_if.src,v 1.13 2001/07/26 20:24:47 millert Exp $
# $NetBSD: vnode_if.src,v 1.10 1996/05/11 18:26:27 mycroft Exp $
#
# Copyright (c) 1992, 1993
@@ -102,12 +102,12 @@ vop_create {
#
#% mknod dvp L U U
-#% mknod vpp - L -
+#% mknod vpp - X -
#
vop_mknod {
IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
- OUT struct vnode **vpp;
+ OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
};
@@ -314,12 +314,16 @@ vop_rmdir {
#
#% symlink dvp L U U
-#% symlink vpp - L -
+#% symlink vpp - U -
+#
+# XXX - note that the return vnode has already been VRELE'ed
+# by the filesystem layer. To use it you must use vget,
+# possibly with a further namei.
#
vop_symlink {
IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
- OUT struct vnode **vpp;
+ OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
IN char *target;
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index efd9972dd9c..0fadf687f7b 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_serv.c,v 1.25 2001/07/26 02:10:41 assar Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.26 2001/07/26 20:24:47 millert Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@@ -1362,6 +1362,16 @@ nfsrv_create(nfsd, slp, procp, mrq)
nfsm_reply(0);
return (0);
}
+ nd.ni_cnd.cn_nameiop = LOOKUP;
+ nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
+ nd.ni_cnd.cn_proc = procp;
+ nd.ni_cnd.cn_cred = cred;
+ if ((error = lookup(&nd)) != 0) {
+ free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
+ nfsm_reply(0);
+ return (0);
+ }
+
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
vrele(nd.ni_dvp);
@@ -1544,7 +1554,14 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
goto out;
}
+ nd.ni_cnd.cn_nameiop = LOOKUP;
+ nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
+ nd.ni_cnd.cn_proc = procp;
+ nd.ni_cnd.cn_cred = procp->p_ucred;
+ error = lookup(&nd);
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
+ if (error)
+ goto out;
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
vrele(nd.ni_dvp);
vput(nd.ni_vp);
@@ -2035,17 +2052,23 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
else {
if (v3) {
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(nd.ni_vp, &va, cred,
- procp);
- vput(nd.ni_vp);
- } else {
+ nd.ni_cnd.cn_nameiop = LOOKUP;
+ nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW);
+ nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF);
+ nd.ni_cnd.cn_proc = procp;
+ nd.ni_cnd.cn_cred = cred;
+ error = lookup(&nd);
+ if (!error) {
+ bzero((caddr_t)fhp, sizeof(nfh));
+ fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
+ error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
+ if (!error)
+ error = VOP_GETATTR(nd.ni_vp, &va, cred,
+ procp);
+ vput(nd.ni_vp);
+ }
+ } else
vrele(nd.ni_startdir);
- vput(nd.ni_vp);
- }
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
}
out:
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index c1bee0c45fb..f189a448a73 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.36 2001/07/26 02:10:41 assar Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.37 2001/07/26 20:24:47 millert Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -1155,6 +1155,8 @@ nfs_mknod(v)
int error;
error = nfs_mknodrpc(ap->a_dvp, &newvp, ap->a_cnp, ap->a_vap);
+ if (!error)
+ vrele(newvp);
return (error);
}
@@ -1631,30 +1633,18 @@ nfs_symlink(v)
nfsm_wcc_data(dvp, wccflag);
}
nfsm_reqdone;
- /*
- * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
- */
- if (error == EEXIST)
- error = 0;
- if (error == 0 && newvp == NULL) {
- struct nfsnode *np = NULL;
-
- error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen,
- cnp->cn_cred, cnp->cn_proc, &np);
- if (error == 0)
- newvp = NFSTOV(np);
- }
- if (error) {
- if (newvp != NULL)
- vput(newvp);
- } else {
- *ap->a_vpp = newvp;
- }
+ if (newvp)
+ vrele(newvp);
FREE(cnp->cn_pnbuf, M_NAMEI);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
vrele(dvp);
+ /*
+ * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
+ */
+ if (error == EEXIST)
+ error = 0;
return (error);
}
diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c
index 0414ab59077..b34882e4ead 100644
--- a/sys/ufs/ext2fs/ext2fs_vnops.c
+++ b/sys/ufs/ext2fs/ext2fs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_vnops.c,v 1.15 2001/07/26 02:10:41 assar Exp $ */
+/* $OpenBSD: ext2fs_vnops.c,v 1.16 2001/07/26 20:24:47 millert Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */
/*
@@ -134,8 +134,6 @@ ext2fs_mknod(v)
register struct vattr *vap = ap->a_vap;
register struct vnode **vpp = ap->a_vpp;
register struct inode *ip;
- struct mount *mp;
- ino_t ino;
int error;
if ((error =
@@ -160,11 +158,6 @@ ext2fs_mknod(v)
(*vpp)->v_type = VNON;
vgone(*vpp);
*vpp = 0;
- error = VFS_VGET(mp, ino, vpp);
- if (error != 0) {
- *vpp = NULL;
- return (error);
- }
return (0);
}
@@ -1199,8 +1192,7 @@ ext2fs_symlink(v)
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, NULL,
(struct proc *)0);
- if (error)
- vput(vp);
+ vput(vp);
return (error);
}
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index a2983450f9a..1347b1736f1 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.35 2001/07/26 02:10:41 assar Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.36 2001/07/26 20:24:47 millert Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -152,8 +152,6 @@ ufs_mknod(v)
} */ *ap = v;
struct vattr *vap = ap->a_vap;
struct vnode **vpp = ap->a_vpp;
- struct mount *mp;
- ino_t ino;
struct inode *ip;
int error;
@@ -179,11 +177,7 @@ ufs_mknod(v)
vput(*vpp);
(*vpp)->v_type = VNON;
vgone(*vpp);
- error = VFS_VGET(mp, ino, vpp);
- if (error != 0) {
- *vpp = NULL;
- return (error);
- }
+ *vpp = 0;
return (0);
}
@@ -1574,8 +1568,7 @@ ufs_symlink(v)
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, NULL,
(struct proc *)0);
- if (error)
- vput(vp);
+ vput(vp);
return (error);
}