From db795b2c7606fa5ffdcc900c11384e51ad99d8b1 Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 19 Sep 2005 13:48:45 +0000 Subject: Restore the ability to detach from a tty via SIOCSTTY and document recent changes in a manpage. Reviewed by: cognet --- share/man/man4/snp.4 | 13 ++++++++----- sys/dev/snp/snp.c | 10 +++++----- usr.sbin/watch/watch.c | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/share/man/man4/snp.4 b/share/man/man4/snp.4 index 809d30b..df70cb2 100644 --- a/share/man/man4/snp.4 +++ b/share/man/man4/snp.4 @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 24, 1995 +.Dd September 18, 2005 .Dt SNP 4 .Os .Sh NAME @@ -30,17 +30,20 @@ To associate a given .Nm device with a tty to be observed, open the .Nm -device and then use the +device and a tty device, and then issue the .Dv SNPSTTY -ioctl. +ioctl on +.Nm +device. The argument passed to the .Xr ioctl 2 is the address of a variable of type -.Vt udev_t . +.Vt int , +holding the file descriptor of a tty device. To detach the .Nm device from a tty use a pointer to a value of -.Dv NODEV . +\-1. .Pp The .Dv SNPGTTY diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index c18a4ce..4008bae 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -527,17 +527,18 @@ snpioctl(dev, cmd, data, flags, td) switch (cmd) { case SNPSTTY: s = *(int *)data; - if (s < 0 || fget(td, s, &fp) != 0) + 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_type != VCHR || + fp->f_vnode->v_rdev == NULL) { fdrop(fp, td); return (EINVAL); } tdev = fp->f_vnode->v_rdev; fdrop(fp, td); - if (tdev == NULL) - return (snp_down(snp)); tp = snpdevtotty(tdev); if (!tp) @@ -593,7 +594,6 @@ 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/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index a062ae0..11a80af 100644 --- a/usr.sbin/watch/watch.c +++ b/usr.sbin/watch/watch.c @@ -218,10 +218,10 @@ setup_scr(void) static void detach_snp(void) { - dev_t dev; + int fd; - dev = NODEV; - ioctl(snp_io, SNPSTTY, &dev); + fd = -1; + ioctl(snp_io, SNPSTTY, &fd); } static void -- cgit v1.1