From owner-freebsd-current Sun Nov 10 12: 2:23 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 56B5B37B401 for ; Sun, 10 Nov 2002 12:02:18 -0800 (PST) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 269FF43E3B for ; Sun, 10 Nov 2002 12:02:17 -0800 (PST) (envelope-from tmoestl@gmx.net) Received: (qmail 12885 invoked by uid 0); 10 Nov 2002 20:02:15 -0000 Received: from pd9e16004.dip.t-dialin.net (HELO forge.local) (217.225.96.4) by mail.gmx.net (mp018-rz3) with SMTP; 10 Nov 2002 20:02:15 -0000 Received: from tmm by forge.local with local (Exim 4.10 #1) id 18AyHh-0001b8-00; Sun, 10 Nov 2002 21:02:17 +0100 Date: Sun, 10 Nov 2002 21:02:16 +0100 From: Thomas Moestl To: Dima Dorfman Cc: current@FreeBSD.org Subject: Re: Anyone seeing snp(4) problems? Message-ID: <20021110200216.GC333@crow.dom2ip.de> Mail-Followup-To: Dima Dorfman , current@FreeBSD.org References: <20021109210938.A73683@FreeBSD.org> <20021110174046.GS5793@trit.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="oyUTqETQ0mS9luUI" Content-Disposition: inline In-Reply-To: <20021110174046.GS5793@trit.org> User-Agent: Mutt/1.4i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, 2002/11/10 at 17:40:47 +0000, Dima Dorfman wrote: > Juli Mallett wrote: > > I just tried to "sudo watch ttyv1" and ran into the following: > > > > % Fatal trap 12: page fault while in kernel mode > .. > > Looks like use of a NULL structure, accessing member at offsetof==0x60? > > > > Anyway, I couldn't get a dump, but I'll keep trying... Also this kernel > > is a bit stale, but it'll take a while to get the kernel on this box updated, > > so I figured I'd go ahead and post now, and try with a new one when I can. > > Is snp loaded from a module, and if it is, are the modules in sync > with the kernel? I tried the above command on a -current about a > month old and it works for me. If something broke recently, I'm > interested in tracebacks. Speaking of snp, what do you think of the attached patches? They fix three problems: - the ioctl()s really operate on udev_ts. dev_t is defined differently in kernel and userland and is even of different size on 64-bit platforms, leading to an ioctl() number mismatch there. - SNPGTTY returned a kernel pointer instead of a correctly formed udev_t - watch(8) assumed that FIONREAD takes a size_t *, when it really takes just an int * The last patch updates the manpage accordingly. - Thomas -- Thomas Moestl http://www.tu-bs.de/~y0015675/ http://people.FreeBSD.org/~tmm/ PGP fingerprint: 1C97 A604 2BD0 E492 51D0 9C0F 1FE6 4F1D 419C 776C --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="snp.diff" Index: sys/snoop.h =================================================================== RCS file: /d/ncvs/src/sys/sys/snoop.h,v retrieving revision 1.21 diff -u -r1.21 snoop.h --- sys/snoop.h 10 Sep 2002 03:58:44 -0000 1.21 +++ sys/snoop.h 10 Nov 2002 19:49:39 -0000 @@ -30,8 +30,8 @@ * detached from its current tty. */ -#define SNPSTTY _IOW('T', 90, dev_t) -#define SNPGTTY _IOR('T', 89, dev_t) +#define SNPSTTY _IOW('T', 90, udev_t) +#define SNPGTTY _IOR('T', 89, udev_t) /* * These values would be returned by FIONREAD ioctl Index: dev/snp/snp.c =================================================================== RCS file: /d/ncvs/src/sys/dev/snp/snp.c,v retrieving revision 1.73 diff -u -r1.73 snp.c --- dev/snp/snp.c 10 Apr 2002 03:51:49 -0000 1.73 +++ dev/snp/snp.c 10 Nov 2002 19:49:39 -0000 @@ -544,7 +544,7 @@ * SNPGTTY happy, else we can't know what is device * major/minor for tty. */ - *((dev_t *)data) = snp->snp_target; + *((udev_t *)data) = dev2udev(snp->snp_target); break; case FIONBIO: --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="watch.diff" Index: watch.c =================================================================== RCS file: /d/ncvs/src/usr.sbin/watch/watch.c,v retrieving revision 1.26 diff -u -r1.26 watch.c --- watch.c 10 Aug 2002 08:42:10 -0000 1.26 +++ watch.c 10 Nov 2002 19:49:09 -0000 @@ -285,8 +285,8 @@ int main(int ac, char *av[]) { - int res, idata, rv; - size_t nread, b_size = MIN_SIZE; + int res, rv, nread; + size_t b_size = MIN_SIZE; char ch, *buf, chb[READB_LEN]; fd_set fd_s; @@ -362,7 +362,7 @@ if (nread > READB_LEN) nread = READB_LEN; rv = read(std_in, chb, nread); - if (rv == -1 || (unsigned)rv != nread) + if (rv == -1 || rv != nread) fatal(EX_IOERR, "read (stdin) failed"); switch (chb[0]) { @@ -379,7 +379,7 @@ default: if (opt_write) { rv = write(snp_io, chb, nread); - if (rv == -1 || (unsigned)rv != nread) { + if (rv == -1 || rv != nread) { detach_snp(); if (opt_no_switch) fatal(EX_IOERR, @@ -394,10 +394,10 @@ if (!FD_ISSET(snp_io, &fd_s)) continue; - if ((res = ioctl(snp_io, FIONREAD, &idata)) != 0) + if ((res = ioctl(snp_io, FIONREAD, &nread)) != 0) fatal(EX_OSERR, "ioctl(FIONREAD)"); - switch (idata) { + switch (nread) { case SNP_OFLOW: if (opt_reconn_oflow) attach_snp(); @@ -418,7 +418,6 @@ cleanup(-1); break; default: - nread = (unsigned)idata; if (nread < (b_size / 2) && (b_size / 2) > MIN_SIZE) { free(buf); if (!(buf = (char *) malloc(b_size / 2))) @@ -432,10 +431,10 @@ fatal(EX_UNAVAILABLE, "malloc failed"); } rv = read(snp_io, buf, nread); - if (rv == -1 || (unsigned)rv != nread) + if (rv == -1 || rv != nread) fatal(EX_IOERR, "read failed"); rv = write(std_out, buf, nread); - if (rv == -1 || (unsigned)rv != nread) + if (rv == -1 || rv != nread) fatal(EX_IOERR, "write failed"); } } /* While */ --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="snp.4.diff" Index: snp.4 =================================================================== RCS file: /d/ncvs/src/share/man/man4/snp.4,v retrieving revision 1.24 diff -u -r1.24 snp.4 --- snp.4 13 Aug 2002 14:12:31 -0000 1.24 +++ snp.4 10 Nov 2002 20:02:09 -0000 @@ -36,11 +36,11 @@ The argument passed to the .Xr ioctl 2 is the address of a variable of type -.Vt dev_t . +.Vt udev_t . To detach the .Nm device from a tty use a pointer to a value of -.Po Vt dev_t Pc Ns \-1 . +.Dv NOUDEV . .Pp The .Dv SNPGTTY --oyUTqETQ0mS9luUI-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message