|
|
| version 1.8, 2004/05/13 23:49:23 | version 1.9, 2004/05/19 22:52:58 |
|---|---|
| Line 49 | Line 49 |
| #include <sys/kernel.h> | #include <sys/kernel.h> |
| static d_open_t cttyopen; | static d_open_t cttyopen; |
| static d_close_t cttyclose; | |
| static d_read_t cttyread; | static d_read_t cttyread; |
| static d_write_t cttywrite; | static d_write_t cttywrite; |
| static d_ioctl_t cttyioctl; | static d_ioctl_t cttyioctl; |
| Line 64 struct cdevsw ctty_cdevsw = { | Line 65 struct cdevsw ctty_cdevsw = { |
| /* clone */ NULL, | /* clone */ NULL, |
| /* open */ cttyopen, | /* open */ cttyopen, |
| /* close */ nullclose, | /* close */ cttyclose, |
| /* read */ cttyread, | /* read */ cttyread, |
| /* write */ cttywrite, | /* write */ cttywrite, |
| /* ioctl */ cttyioctl, | /* ioctl */ cttyioctl, |
| Line 87 cttyopen(dev_t dev, int flag, int mode, | Line 88 cttyopen(dev_t dev, int flag, int mode, |
| KKASSERT(p); | KKASSERT(p); |
| ttyvp = cttyvp(p); | ttyvp = cttyvp(p); |
| if (ttyvp) { | |
| if (ttyvp == NULL) | vn_lock(ttyvp, NULL, LK_EXCLUSIVE | LK_RETRY, td); |
| return (ENXIO); | |
| vn_lock(ttyvp, NULL, LK_EXCLUSIVE | LK_RETRY, td); | |
| #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, td); | |
| if (!error) | |
| #endif /* PARANOID */ | |
| error = VOP_OPEN(ttyvp, flag, NOCRED, td); | error = VOP_OPEN(ttyvp, flag, NOCRED, td); |
| VOP_UNLOCK(ttyvp, NULL, 0, td); | VOP_UNLOCK(ttyvp, NULL, 0, td); |
| } else { | |
| error = ENXIO; | |
| } | |
| return (error); | return (error); |
| } | } |
| static int | |
| cttyclose(dev_t dev, int fflag, int devtype, struct thread *td) | |
| { | |
| struct proc *p = td->td_proc; | |
| struct vnode *ttyvp; | |
| int error; | |
| KKASSERT(p); | |
| ttyvp = cttyvp(p); | |
| if (ttyvp == NULL) | |
| error = EIO; | |
| else | |
| error = VOP_CLOSE(ttyvp, fflag, td); | |
| return(error); | |
| } | |
| /*ARGSUSED*/ | /*ARGSUSED*/ |
| static int | static int |
| cttyread(dev, uio, flag) | cttyread(dev, uio, flag) |
| Line 201 static void | Line 206 static void |
| ctty_drvinit(unused) | ctty_drvinit(unused) |
| void *unused; | void *unused; |
| { | { |
| cdevsw_add(&ctty_cdevsw, 0, 0); | |
| make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty"); | make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty"); |
| } | } |