From 1675cfdf22cef92a0cdffa1664812c9489409bfd Mon Sep 17 00:00:00 2001 From: cognet Date: Fri, 23 Sep 2005 23:22:22 +0000 Subject: [PATCH] MFC rev 1.101 and 1.102: revision 1.101 date: 2005/09/18 19:23:35; author: cognet; state: Exp; lines: +14 -5 Slightly change the API for the SNPSTTY ioctl so that the userland now provides a file descriptor instead of a dev_t. revision 1.102 date: 2005/09/19 13:48:45; author: ru; state: Exp; lines: +5 -5 Restore the ability to detach from a tty via SIOCSTTY and document recent changes in a manpage. Approved by: re --- sys/dev/snp/snp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 3e190c70909a..4008baee85b5 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include static l_close_t snplclose; static l_write_t snplwrite; @@ -518,18 +520,25 @@ snpioctl(dev, cmd, data, flags, td) struct snoop *snp; struct tty *tp, *tpo; struct cdev *tdev; + struct file *fp; int s; snp = dev->si_drv1; switch (cmd) { case SNPSTTY: -#if 0 - tdev = findcdev(*((dev_t *)data)); -#else - tdev = NULL; -#endif - if (tdev == NULL) + s = *(int *)data; + if (s < 0) return (snp_down(snp)); + if (fget(td, s, &fp) != 0) + return (EINVAL); + if (fp->f_type != DTYPE_VNODE || + fp->f_vnode->v_type != VCHR || + fp->f_vnode->v_rdev == NULL) { + fdrop(fp, td); + return (EINVAL); + } + tdev = fp->f_vnode->v_rdev; + fdrop(fp, td); tp = snpdevtotty(tdev); if (!tp)