Restore the ability to detach from a tty via SIOCSTTY and document

recent changes in a manpage.

Reviewed by:	cognet
This commit is contained in:
Ruslan Ermilov 2005-09-19 13:48:45 +00:00
parent db2dc2cd01
commit 6ed0b39d28
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150322
3 changed files with 16 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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