mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Use the new ability to avoid practically all the gunk in this file.
When people access /dev/tty, locate their controlling tty and return the dev_t of it to them. This basically makes /dev/tty act like a variant symlink sort of thing which is much simpler than all the mucking about with vnodes.
This commit is contained in:
parent
f73cbde4cf
commit
241e77c8a5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76572
@ -54,8 +54,8 @@ static d_ioctl_t cttyioctl;
|
||||
static d_poll_t cttypoll;
|
||||
|
||||
#define CDEV_MAJOR 1
|
||||
/* Don't make this static, since fdesc_vnops uses it. */
|
||||
struct cdevsw ctty_cdevsw = {
|
||||
|
||||
static struct cdevsw ctty_cdevsw = {
|
||||
/* open */ cttyopen,
|
||||
/* close */ nullclose,
|
||||
/* read */ cttyread,
|
||||
@ -86,20 +86,7 @@ cttyopen(dev, flag, mode, p)
|
||||
if (ttyvp == NULL)
|
||||
return (ENXIO);
|
||||
vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
#ifdef PARANOID
|
||||
/*
|
||||
* Since group is tty and mode is 620 on most terminal lines
|
||||
* and since sessions protect terminals from processes outside
|
||||
* your session, this check is probably no longer necessary.
|
||||
* Since it inhibits setuid root programs that later switch
|
||||
* to another user from accessing /dev/tty, we have decided
|
||||
* to delete this test. (mckusick 5/93)
|
||||
*/
|
||||
error = VOP_ACCESS(ttyvp,
|
||||
(flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, p);
|
||||
if (!error)
|
||||
#endif /* PARANOID */
|
||||
error = VOP_OPEN(ttyvp, flag, NOCRED, p);
|
||||
error = VOP_OPEN(ttyvp, flag, NOCRED, p);
|
||||
VOP_UNLOCK(ttyvp, 0, p);
|
||||
return (error);
|
||||
}
|
||||
@ -188,13 +175,35 @@ cttypoll(dev, events, p)
|
||||
return (VOP_POLL(ttyvp, events, p->p_ucred, p));
|
||||
}
|
||||
|
||||
static void ctty_clone __P((void *arg, char *name, int namelen, dev_t *dev));
|
||||
|
||||
static void
|
||||
ctty_clone(void *arg, char *name, int namelen, dev_t *dev)
|
||||
{
|
||||
struct vnode *vp;
|
||||
|
||||
if (*dev != NODEV)
|
||||
return;
|
||||
if (strcmp(name, "tty"))
|
||||
return;
|
||||
vp = cttyvp(curproc);
|
||||
if (vp == NULL)
|
||||
return;
|
||||
*dev = vp->v_rdev;
|
||||
}
|
||||
|
||||
|
||||
static void ctty_drvinit __P((void *unused));
|
||||
static void
|
||||
ctty_drvinit(unused)
|
||||
void *unused;
|
||||
{
|
||||
|
||||
make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty");
|
||||
if (devfs_present) {
|
||||
EVENTHANDLER_REGISTER(dev_clone, ctty_clone, 0, 1000);
|
||||
} else {
|
||||
make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty");
|
||||
}
|
||||
}
|
||||
|
||||
SYSINIT(cttydev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ctty_drvinit,NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user