summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcognet <cognet@FreeBSD.org>2005-09-18 19:23:35 +0000
committercognet <cognet@FreeBSD.org>2005-09-18 19:23:35 +0000
commit007ea262517b74927effbe0dfbbe564fceb6c06f (patch)
tree9f6a6a0b8d2efe149ceb2ecc351359fe24ba972b
parent470e1e423668df42a3d7eb9bde35d09a9da372f6 (diff)
downloadFreeBSD-src-007ea262517b74927effbe0dfbbe564fceb6c06f.zip
FreeBSD-src-007ea262517b74927effbe0dfbbe564fceb6c06f.tar.gz
Slightly change the API for the SNPSTTY ioctl so that the userland now
provides a file descriptor instead of a dev_t. Discussed with: phk MFC after: 3 days
-rw-r--r--sys/dev/snp/snp.c19
-rw-r--r--sys/sys/snoop.h6
2 files changed, 16 insertions, 9 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index 3e190c7..c18a4ce 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$");
#include <sys/queue.h>
#include <sys/snoop.h>
#include <sys/uio.h>
+#include <sys/file.h>
+#include <sys/vnode.h>
static l_close_t snplclose;
static l_write_t snplwrite;
@@ -518,16 +520,22 @@ 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
+ s = *(int *)data;
+ if (s < 0 || fget(td, s, &fp) != 0)
+ return (EINVAL);
+ if (fp->f_type != DTYPE_VNODE ||
+ fp->f_vnode->v_type != VCHR) {
+ fdrop(fp, td);
+ return (EINVAL);
+ }
+ tdev = fp->f_vnode->v_rdev;
+ fdrop(fp, td);
if (tdev == NULL)
return (snp_down(snp));
@@ -585,6 +593,7 @@ snpioctl(dev, cmd, data, flags, td)
*(int *)data = snp->snp_len;
else
if (snp->snp_flags & SNOOP_DOWN) {
+ printf("IT IS DOWN\n");
if (snp->snp_flags & SNOOP_OFLOW)
*(int *)data = SNP_OFLOW;
else
diff --git a/sys/sys/snoop.h b/sys/sys/snoop.h
index 5c9b8be..b25aa49 100644
--- a/sys/sys/snoop.h
+++ b/sys/sys/snoop.h
@@ -25,12 +25,10 @@
/*
* These are snoop io controls
- * SNPSTTY accepts 'struct snptty' as input.
- * If ever type or unit set to -1,snoop device
- * detached from its current tty.
+ * SNPSTTY accepts a file descriptor as input.
*/
-#define SNPSTTY _IOW('T', 90, dev_t)
+#define SNPSTTY _IOW('T', 90, int)
#define SNPGTTY _IOR('T', 89, dev_t)
/*
OpenPOWER on IntegriCloud