-/*
- * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
*
- * @(#)tty_tty.c 7.11 (Berkeley) %G%
+ * @(#)tty_tty.c 7.17 (Berkeley) %G%
*/
/*
#include "param.h"
#include "systm.h"
#include "conf.h"
-#include "user.h"
#include "ioctl.h"
-#include "tty.h"
#include "proc.h"
+#include "tty.h"
#include "vnode.h"
#include "file.h"
-#include "uio.h"
#define cttyvp(p) ((p)->p_flag&SCTTY ? (p)->p_session->s_ttyvp : NULL)
/*ARGSUSED*/
-cttyopen(dev, flag)
+cttyopen(dev, flag, mode, p)
dev_t dev;
- int flag;
+ int flag, mode;
+ struct proc *p;
{
- struct proc *p = curproc;
struct vnode *ttyvp = cttyvp(p);
int error;
return (ENXIO);
VOP_LOCK(ttyvp);
error = VOP_ACCESS(ttyvp,
- (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred);
+ (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, p);
+ if (!error)
+ error = VOP_OPEN(ttyvp, flag, NOCRED, p);
VOP_UNLOCK(ttyvp);
- if (error)
- return (error);
- return (VOP_OPEN(ttyvp, flag, NOCRED));
+ return (error);
}
/*ARGSUSED*/
cttyread(dev, uio, flag)
dev_t dev;
struct uio *uio;
+ int flag;
{
- register struct vnode *ttyvp = cttyvp(curproc);
+ register struct vnode *ttyvp = cttyvp(uio->uio_procp);
int error;
if (ttyvp == NULL)
- return (ENXIO);
+ return (EIO);
VOP_LOCK(ttyvp);
error = VOP_READ(ttyvp, uio, flag, NOCRED);
VOP_UNLOCK(ttyvp);
cttywrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
+ int flag;
{
- register struct vnode *ttyvp = cttyvp(curproc);
+ register struct vnode *ttyvp = cttyvp(uio->uio_procp);
int error;
if (ttyvp == NULL)
- return (ENXIO);
+ return (EIO);
VOP_LOCK(ttyvp);
error = VOP_WRITE(ttyvp, uio, flag, NOCRED);
VOP_UNLOCK(ttyvp);
}
/*ARGSUSED*/
-cttyioctl(dev, cmd, addr, flag)
+cttyioctl(dev, cmd, addr, flag, p)
dev_t dev;
int cmd;
caddr_t addr;
int flag;
+ struct proc *p;
{
- struct vnode *ttyvp = cttyvp(curproc);
+ struct vnode *ttyvp = cttyvp(p);
if (ttyvp == NULL)
- return (ENXIO);
+ return (EIO);
if (cmd == TIOCNOTTY) {
- if (!SESS_LEADER(curproc)) {
- curproc->p_flag &= ~SCTTY;
+ if (!SESS_LEADER(p)) {
+ p->p_flag &= ~SCTTY;
return (0);
} else
return (EINVAL);
}
- return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED));
+ return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, p));
}
/*ARGSUSED*/
-cttyselect(dev, flag)
+cttyselect(dev, flag, p)
dev_t dev;
int flag;
+ struct proc *p;
{
- struct vnode *ttyvp = cttyvp(curproc);
+ struct vnode *ttyvp = cttyvp(p);
if (ttyvp == NULL)
return (1); /* try operation to get EOF/failure */
- return (VOP_SELECT(ttyvp, flag, FREAD|FWRITE, NOCRED));
+ return (VOP_SELECT(ttyvp, flag, FREAD|FWRITE, NOCRED, p));
}