Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Sep 2005 10:12:52 +0300
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Olivier Houchard <cognet@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/watch watch.c
Message-ID:  <20050919071252.GG65954@ip.net.ua>
In-Reply-To: <200509181924.j8IJO5p7062783@repoman.freebsd.org>
References:  <200509181924.j8IJO5p7062783@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--5L6AZ1aJH5mDrqCQ
Content-Type: multipart/mixed; boundary="5CUMAwwhRxlRszMD"
Content-Disposition: inline


--5CUMAwwhRxlRszMD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

On Sun, Sep 18, 2005 at 07:24:05PM +0000, Olivier Houchard wrote:
> cognet      2005-09-18 19:24:05 UTC
>=20
>   FreeBSD src repository
>=20
>   Modified files:
>     usr.sbin/watch       watch.c=20
>   Log:
>   Open the tty device and pass the fd for SNPSTTY.
>  =20
>   MFC after:      3 days
>  =20
>   Revision  Changes    Path
>   1.32      +8 -2      src/usr.sbin/watch/watch.c
>=20
The attached patch does the following:

- Restores the ability to detach from a tty via SIOCSTTY.
- Removes a stray debugging printf.
- Fixes the module build (vnode_if.h is now necessary).
- Documents the change.


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--5CUMAwwhRxlRszMD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p
Content-Transfer-Encoding: quoted-printable

Index: sys/dev/snp/snp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/dev/snp/snp.c,v
retrieving revision 1.101
diff -u -p -r1.101 snp.c
--- sys/dev/snp/snp.c	18 Sep 2005 19:23:35 -0000	1.101
+++ sys/dev/snp/snp.c	19 Sep 2005 07:04:40 -0000
@@ -527,7 +527,9 @@ snpioctl(dev, cmd, data, flags, td)
 	switch (cmd) {
 	case SNPSTTY:
 		s =3D *(int *)data;
-		if (s < 0 || fget(td, s, &fp) !=3D 0)
+		if (s < 0)
+			return (snp_down(snp));
+		if (fget(td, s, &fp) !=3D 0)
 			return (EINVAL);
 		if (fp->f_type !=3D DTYPE_VNODE ||
 		    fp->f_vnode->v_type !=3D VCHR) {
@@ -536,8 +538,6 @@ snpioctl(dev, cmd, data, flags, td)
 		}
 		tdev =3D fp->f_vnode->v_rdev;
 		fdrop(fp, td);
-		if (tdev =3D=3D NULL)
-			return (snp_down(snp));
=20
 		tp =3D snpdevtotty(tdev);
 		if (!tp)
@@ -593,7 +593,6 @@ snpioctl(dev, cmd, data, flags, td)
 			*(int *)data =3D snp->snp_len;
 		else
 			if (snp->snp_flags & SNOOP_DOWN) {
-				printf("IT IS DOWN\n");
 				if (snp->snp_flags & SNOOP_OFLOW)
 					*(int *)data =3D SNP_OFLOW;
 				else
Index: sys/modules/snp/Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/modules/snp/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- sys/modules/snp/Makefile	29 Dec 2004 08:47:29 -0000	1.4
+++ sys/modules/snp/Makefile	19 Sep 2005 07:06:11 -0000
@@ -4,5 +4,6 @@
=20
 KMOD=3D	snp
 SRCS=3D	snp.c
+SRCS+=3D	vnode_if.h
=20
 .include <bsd.kmod.mk>
Index: usr.sbin/watch/watch.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.sbin/watch/watch.c,v
retrieving revision 1.32
diff -u -p -r1.32 watch.c
--- usr.sbin/watch/watch.c	18 Sep 2005 19:24:05 -0000	1.32
+++ usr.sbin/watch/watch.c	19 Sep 2005 07:07:05 -0000
@@ -218,10 +218,10 @@ setup_scr(void)
 static void
 detach_snp(void)
 {
-	dev_t		dev;
+	int		fd;
=20
-	dev =3D NODEV;
-	ioctl(snp_io, SNPSTTY, &dev);
+	fd =3D -1;
+	ioctl(snp_io, SNPSTTY, &fd);
 }
=20
 static void
Index: share/man/man4/snp.4
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/share/man/man4/snp.4,v
retrieving revision 1.26
diff -u -p -r1.26 snp.4
--- share/man/man4/snp.4	21 Jan 2005 08:36:37 -0000	1.26
+++ share/man/man4/snp.4	19 Sep 2005 07:09:11 -0000
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD: src/share/man/man4/snp.4,v 1.26 2005/01/21 08:36:37 ru Exp $
 .\"
-.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

--5CUMAwwhRxlRszMD--

--5L6AZ1aJH5mDrqCQ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (FreeBSD)

iD8DBQFDLmT0qRfpzJluFF4RArD1AJ0dd0DzbvR83VyBE42hzGuQrHvfewCfQTGF
rQ/h0WyINNpTiHT37tjGTSM=
=ToqC
-----END PGP SIGNATURE-----

--5L6AZ1aJH5mDrqCQ--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050919071252.GG65954>