From owner-freebsd-current@FreeBSD.ORG Thu Feb 2 23:30:01 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org 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 08DAB16A420 for ; Thu, 2 Feb 2006 23:30:01 +0000 (GMT) (envelope-from mime@traveller.cz) Received: from ss.eunet.cz (ss.eunet.cz [193.85.228.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7208043D55 for ; Thu, 2 Feb 2006 23:29:59 +0000 (GMT) (envelope-from mime@traveller.cz) Received: from localhost.i.cz (ss.eunet.cz [193.85.228.13]) by ss.eunet.cz (8.13.3/8.13.1) with ESMTP id k12NTrEq019732 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Fri, 3 Feb 2006 00:29:58 +0100 (CET) (envelope-from mime@traveller.cz) From: Michal Mertl To: freebsd-current@freebsd.org Content-Type: multipart/mixed; boundary="=-EHgGsY+mVrGMXkzIh+ZU" Date: Fri, 03 Feb 2006 00:29:48 +0100 Message-Id: <1138922988.10456.29.camel@genius.i.cz> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 FreeBSD GNOME Team Port Subject: buglets with pts - with patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2006 23:30:01 -0000 --=-EHgGsY+mVrGMXkzIh+ZU Content-Type: text/plain Content-Transfer-Encoding: 7bit I found a couple of display issues with the new pts type ptys. wall and who - don't check the utmp tty validity (see also PR bin/84041) The attached patch duplicates the check from the w program in who and wall. For some reason closed pts ttys are displayed/printed to when there wasn't a problem with the old pty implementation. ps - the TT column displays garbage (always "pts") The attached patch trims "pts/" from the tty name. The printout doesn't look nice ("10443 pts IWs 0:00,00 bash" changes to "10443 3 IWs 0:00,00 bash") but the field width is 4 which doesn't allow much. The right solution would probably involve removing TT column and always use the longer version TTY with width of 8 (which allows to correctly display "pts/3"). I checked Solaris 10 and it displays the full tty name by default. Regards Michal --=-EHgGsY+mVrGMXkzIh+ZU Content-Disposition: attachment; filename=wall.diff Content-Type: text/x-patch; name=wall.diff; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit Index: wall.c =================================================================== RCS file: /home/fcvs/cvs/src/usr.bin/wall/wall.c,v retrieving revision 1.23 diff -u -r1.23 wall.c --- wall.c 21 Feb 2003 08:46:44 -0000 1.23 +++ wall.c 2 Feb 2006 22:49:50 -0000 @@ -82,6 +82,19 @@ char *mbuf; int +ttystat(char *line, int sz) +{ + struct stat sb; + char ttybuf[MAXPATHLEN]; + + (void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line); + if (stat(ttybuf, &sb) == 0) { + return (0); + } else + return (-1); +} + +int main(int argc, char *argv[]) { struct iovec iov; @@ -140,6 +153,8 @@ while (fread((char *)&utmp, sizeof(utmp), 1, fp) == 1) { if (!utmp.ut_name[0]) continue; + if (ttystat(utmp.ut_line, UT_LINESIZE) != 0) + continue; if (grouplist) { ingroup = 0; strlcpy(username, utmp.ut_name, sizeof(utmp.ut_name)); --=-EHgGsY+mVrGMXkzIh+ZU Content-Disposition: attachment; filename=who.diff Content-Type: text/x-patch; name=who.diff; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit Index: who.c =================================================================== RCS file: /home/fcvs/cvs/src/usr.bin/who/who.c,v retrieving revision 1.21 diff -u -r1.21 who.c --- who.c 29 May 2005 15:52:48 -0000 1.21 +++ who.c 2 Feb 2006 22:44:29 -0000 @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD: src/usr.bin/who/who.c,v 1.21 2005/05/29 15:52:48 charnier Exp $"); +#include #include #include #include @@ -203,14 +204,31 @@ putchar('\n'); } +int +ttystat(char *line, int sz) +{ + struct stat sb; + char ttybuf[MAXPATHLEN]; + + (void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line); + if (stat(ttybuf, &sb) == 0) { + return (0); + } else + return (-1); +} + static void process_utmp(FILE *fp) { struct utmp ut; - while (fread(&ut, sizeof(ut), 1, fp) == 1) - if (*ut.ut_name != '\0') - row(&ut); + while (fread(&ut, sizeof(ut), 1, fp) == 1) { + if (*ut.ut_name == '\0') + continue; + if (ttystat(ut.ut_line, UT_LINESIZE) != 0) + continue; + row(&ut); + } } static void --=-EHgGsY+mVrGMXkzIh+ZU Content-Disposition: attachment; filename=ps.diff Content-Type: text/x-patch; name=ps.diff; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit Index: print.c =================================================================== RCS file: /home/fcvs/cvs/src/bin/ps/print.c,v retrieving revision 1.93 diff -u -r1.93 print.c --- print.c 20 Jul 2004 05:52:00 -0000 1.93 +++ print.c 2 Feb 2006 23:05:07 -0000 @@ -366,6 +366,8 @@ if (strncmp(ttname, "tty", 3) == 0 || strncmp(ttname, "cua", 3) == 0) ttname += 3; + if (strncmp(ttname, "pts/", 4) == 0) + ttname += 4; (void)printf("%*.*s%c", v->width - 1, v->width - 1, ttname, k->ki_p->ki_kiflag & KI_CTTY ? ' ' : '-'); } --=-EHgGsY+mVrGMXkzIh+ZU--