added extra argument in vn_open and VOP_OPEN to allow cloning devices

This commit is contained in:
christos 1994-11-14 06:01:16 +00:00
parent c2c3dce760
commit 1a320dc9be
6 changed files with 30 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_acct.c,v 1.33 1994/10/20 04:22:39 cgd Exp $ */
/* $NetBSD: kern_acct.c,v 1.34 1994/11/14 06:01:16 christos Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@ -115,7 +115,7 @@ acct(p, uap, retval)
if (SCARG(uap, path) != NULL) {
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path),
p);
if (error = vn_open(&nd, FWRITE, 0))
if (error = vn_open(&nd, FWRITE, 0, NULL))
return (error);
VOP_UNLOCK(nd.ni_vp);
if (nd.ni_vp->v_type != VREG) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ktrace.c,v 1.13 1994/10/20 04:22:49 cgd Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.14 1994/11/14 06:01:18 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -249,7 +249,7 @@ ktrace(curp, uap, retval)
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, fname),
curp);
if (error = vn_open(&nd, FREAD|FWRITE, 0)) {
if (error = vn_open(&nd, FREAD|FWRITE, 0, NULL)) {
curp->p_traceflag &= ~KTRFAC_ACTIVE;
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.34 1994/11/06 20:39:50 mycroft Exp $ */
/* $NetBSD: kern_sig.c,v 1.35 1994/11/14 06:01:20 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -1172,7 +1172,7 @@ coredump(p)
sprintf(name, "%s.core", p->p_comm);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
if (error = vn_open(&nd,
O_CREAT | FWRITE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))
O_CREAT | FWRITE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, NULL))
return (error);
vp = nd.ni_vp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.36 1994/10/30 21:48:14 cgd Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.37 1994/11/14 06:01:22 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -617,7 +617,8 @@ open(p, uap, retval)
cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
if (error = vn_open(&nd, flags, cmode)) {
fp->f_data = (caddr_t) NULL;
if (error = vn_open(&nd, flags, cmode, fp)) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@ -631,8 +632,23 @@ open(p, uap, retval)
fdp->fd_ofiles[indx] = NULL;
return (error);
}
p->p_dupfd = 0;
vp = nd.ni_vp;
if (fp->f_data != (caddr_t) NULL) {
/*
* The fp data was changed, so it is a cloning operation
* Cleanup and return
*/
VOP_UNLOCK(vp);
if (flags & FWRITE)
vp->v_writecount--;
vput(vp);
*retval = indx;
return (0);
}
fp->f_flag = flags & FMASK;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_vnops.c,v 1.15 1994/10/30 21:48:16 cgd Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.16 1994/11/14 06:01:24 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -62,9 +62,10 @@ struct fileops vnops =
* Common code for vnode open operations.
* Check permissions, and call the VOP_OPEN or VOP_CREATE routine.
*/
vn_open(ndp, fmode, cmode)
vn_open(ndp, fmode, cmode, fp)
register struct nameidata *ndp;
int fmode, cmode;
struct file *fp;
{
register struct vnode *vp;
register struct proc *p = ndp->ni_cnd.cn_proc;
@ -139,7 +140,7 @@ vn_open(ndp, fmode, cmode)
if (error = VOP_SETATTR(vp, vap, cred, p))
goto bad;
}
if (error = VOP_OPEN(vp, fmode, cred, p))
if (error = VOP_OPEN(vp, fmode, cred, p, fp))
goto bad;
if (fmode & FWRITE)
vp->v_writecount++;

View File

@ -1,4 +1,4 @@
# $NetBSD: vnode_if.src,v 1.4 1994/10/30 21:48:17 cgd Exp $
# $NetBSD: vnode_if.src,v 1.5 1994/11/14 06:01:25 christos Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@ -58,6 +58,7 @@ vop_open {
IN int mode;
IN struct ucred *cred;
IN struct proc *p;
INOUT struct file *fp;
};
vop_close {