CVS commit: src/usr.bin/w
Module Name:src Committed By: maya Date: Sat Apr 17 06:14:15 UTC 2021 Modified Files: src/usr.bin/w: pr_time.c w.c Log Message: Remove SCCS workarounds. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.bin/w/pr_time.c cvs rdiff -u -r1.90 -r1.91 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/pr_time.c diff -u src/usr.bin/w/pr_time.c:1.18 src/usr.bin/w/pr_time.c:1.19 --- src/usr.bin/w/pr_time.c:1.18 Wed Aug 17 13:48:11 2011 +++ src/usr.bin/w/pr_time.c Sat Apr 17 06:14:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $ */ +/* $NetBSD: pr_time.c,v 1.19 2021/04/17 06:14:15 maya Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)pr_time.c 8.2 (Berkeley) 4/4/94"; #else -__RCSID("$NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $"); +__RCSID("$NetBSD: pr_time.c,v 1.19 2021/04/17 06:14:15 maya Exp $"); #endif #endif /* not lint */ @@ -51,9 +51,6 @@ __RCSID("$NetBSD: pr_time.c,v 1.18 2011/ /* * pr_attime -- * Print the time since the user logged in. - * - * Note: SCCS forces the bizarre string manipulation, things like - * %I% get replaced in the source code. */ void pr_attime(time_t *started, time_t *now) @@ -71,11 +68,11 @@ pr_attime(time_t *started, time_t *now) /* If more than a week, use day-month-year. */ (void)strftime(buf, sizeof(buf), "%d%b%y", tp); } else if (tp->tm_yday != tnow_yday) { - /* If not today, use day-hour-am/pm. Damn SCCS */ - (void)strftime(buf, sizeof(buf), "%a%" "I%p", tp); + /* If not today, use day-hour-am/pm. */ + (void)strftime(buf, sizeof(buf), "%a%I%p", tp); } else { - /* Default is hh:mm{am,pm}. Damn SCCS */ - (void)strftime(buf, sizeof(buf), "%l:%" "M%p", tp); + /* Default is hh:mm{am,pm}. */ + (void)strftime(buf, sizeof(buf), "%l:%M%p", tp); } buf[sizeof(buf) - 1] = '\0'; Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.90 src/usr.bin/w/w.c:1.91 --- src/usr.bin/w/w.c:1.90 Sat Aug 1 17:53:38 2020 +++ src/usr.bin/w/w.c Sat Apr 17 06:14:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $ */ +/* $NetBSD: w.c,v 1.91 2021/04/17 06:14:15 maya Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.91 2021/04/17 06:14:15 maya Exp $"); #endif #endif /* not lint */ @@ -465,11 +465,8 @@ pr_header(time_t *nowp, int nusers) /* * Print time of day. - * - * SCCS forces the string manipulation below, as it replaces - * %, M, and % in a character string with the file name. */ - (void)strftime(buf, sizeof(buf), "%l:%" "M%p", localtime(nowp)); + (void)strftime(buf, sizeof(buf), "%l:%M%p", localtime(nowp)); buf[sizeof(buf) - 1] = '\0'; (void)printf("%s ", buf);
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Sat Aug 1 17:53:38 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Skip bracket processing if -n is used. XXX: This could be improved to skip even more processing. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.89 src/usr.bin/w/w.c:1.90 --- src/usr.bin/w/w.c:1.89 Sat Aug 1 17:25:57 2020 +++ src/usr.bin/w/w.c Sat Aug 1 17:53:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $ */ +/* $NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $"); #endif #endif /* not lint */ @@ -654,7 +654,7 @@ fixhost(struct entry *ep) * Leading '[' indicates an IP address inside brackets. */ b = NULL; - if (*p == '[') { + if (!nflag && (*p == '[')) { for (b = p++; b < _buf[sizeof(host_buf)]; b++) if (*b == '\0' || *b == ']') break;
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Sat Aug 1 17:25:57 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Restore ']' if not using a result from an address lookup. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.88 src/usr.bin/w/w.c:1.89 --- src/usr.bin/w/w.c:1.88 Sat Aug 1 15:52:50 2020 +++ src/usr.bin/w/w.c Sat Aug 1 17:25:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $ */ +/* $NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $"); #endif #endif /* not lint */ @@ -621,7 +621,7 @@ static void fixhost(struct entry *ep) { char host_buf[sizeof(ep->host)]; - char *p, *r, *x, *m; + char *b, *m, *p, *r, *x; struct hostent *hp; union { struct in_addr l4; @@ -653,19 +653,20 @@ fixhost(struct entry *ep) /* * Leading '[' indicates an IP address inside brackets. */ + b = NULL; if (*p == '[') { - for (p++; p < _buf[sizeof(host_buf)]; p++) - if (*p == '\0' || *p == ']') + for (b = p++; b < _buf[sizeof(host_buf)]; b++) + if (*b == '\0' || *b == ']') break; - if (p < _buf[sizeof(host_buf)] && *p == ']') { - *p = '\0'; - for (x = ++p; x < _buf[sizeof(host_buf)]; x++) + if (b < _buf[sizeof(host_buf)] && *b == ']') { + *b = '\0'; + for (x = b + 1; x < _buf[sizeof(host_buf)]; x++) if (*x == '\0' || *x == ':') break; if (x < _buf[sizeof(host_buf)] && *x == ':') *x++ = '\0'; - } - p = host_buf + 1; + } else + b = NULL; } int af = m ? AF_INET6 : AF_INET; @@ -673,8 +674,11 @@ fixhost(struct entry *ep) if (!nflag && inet_pton(af, p, ) && (hp = gethostbyaddr((char *), alen, af))) r = hp->h_name; - else + else { + if (b) + *b = ']'; r = host_buf; + } if (domain[0] != '\0') { p = r;
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Sat Aug 1 15:52:50 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.87 src/usr.bin/w/w.c:1.88 --- src/usr.bin/w/w.c:1.87 Sat Jul 4 23:30:31 2020 +++ src/usr.bin/w/w.c Sat Aug 1 15:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $ */ +/* $NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $"); #endif #endif /* not lint */ @@ -650,6 +650,24 @@ fixhost(struct entry *ep) x = NULL; } + /* + * Leading '[' indicates an IP address inside brackets. + */ + if (*p == '[') { + for (p++; p < _buf[sizeof(host_buf)]; p++) + if (*p == '\0' || *p == ']') +break; + if (p < _buf[sizeof(host_buf)] && *p == ']') { + *p = '\0'; + for (x = ++p; x < _buf[sizeof(host_buf)]; x++) +if (*x == '\0' || *x == ':') + break; + if (x < _buf[sizeof(host_buf)] && *x == ':') +*x++ = '\0'; + } + p = host_buf + 1; + } + int af = m ? AF_INET6 : AF_INET; size_t alen = m ? sizeof(l.l6) : sizeof(l.l4); if (!nflag && inet_pton(af, p, ) &&
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Sat Jul 4 23:30:32 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Don't overwrite host_buf as x might be pointing to wanted data in it To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.86 src/usr.bin/w/w.c:1.87 --- src/usr.bin/w/w.c:1.86 Tue Jun 30 15:02:55 2020 +++ src/usr.bin/w/w.c Sat Jul 4 23:30:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.86 2020/06/30 15:02:55 kim Exp $ */ +/* $NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.86 2020/06/30 15:02:55 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $"); #endif #endif /* not lint */ @@ -621,7 +621,7 @@ static void fixhost(struct entry *ep) { char host_buf[sizeof(ep->host)]; - char *p, *x, *m; + char *p, *r, *x, *m; struct hostent *hp; union { struct in_addr l4; @@ -649,26 +649,28 @@ fixhost(struct entry *ep) } else x = NULL; } + int af = m ? AF_INET6 : AF_INET; size_t alen = m ? sizeof(l.l6) : sizeof(l.l4); if (!nflag && inet_pton(af, p, ) && (hp = gethostbyaddr((char *), alen, af))) - strlcpy(host_buf, hp->h_name, sizeof(host_buf)); + r = hp->h_name; + else + r = host_buf; if (domain[0] != '\0') { - p = host_buf; - p += strlen(host_buf); + p = r; + p += strlen(r); p -= strlen(domain); - if (p > host_buf && + if (p > r && strcasecmp(p, domain) == 0) *p = '\0'; } if (x) - (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", host_buf, - x); + (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", r, x); else - strlcpy(ep->host, host_buf, sizeof(ep->host)); + strlcpy(ep->host, r, sizeof(ep->host)); } static void
CVS commit: src/usr.bin/w
Module Name:src Committed By: martin Date: Wed Jul 1 06:31:18 UTC 2020 Modified Files: src/usr.bin/w: Makefile Log Message: Forbid gcc to whine about intended format truncation To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/w/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/Makefile diff -u src/usr.bin/w/Makefile:1.21 src/usr.bin/w/Makefile:1.22 --- src/usr.bin/w/Makefile:1.21 Fri Oct 21 02:26:09 2011 +++ src/usr.bin/w/Makefile Wed Jul 1 06:31:18 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2011/10/21 02:26:09 christos Exp $ +# $NetBSD: Makefile,v 1.22 2020/07/01 06:31:18 martin Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include @@ -14,5 +14,6 @@ CPPFLAGS+= -DSUPPORT_UTMP -DSUPPORT_UTMP .PATH: ${NETBSDSRCDIR}/bin/ps COPTS.pr_time.c += -Wno-format-y2k +COPTS.w.c += ${GCC_NO_FORMAT_TRUNCATION} .include
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Tue Jun 30 15:02:55 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Remove local domain always, not just when looking up addresses To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.85 src/usr.bin/w/w.c:1.86 --- src/usr.bin/w/w.c:1.85 Tue Jun 30 14:57:25 2020 +++ src/usr.bin/w/w.c Tue Jun 30 15:02:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.85 2020/06/30 14:57:25 kim Exp $ */ +/* $NetBSD: w.c,v 1.86 2020/06/30 15:02:55 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.85 2020/06/30 14:57:25 kim Exp $"); +__RCSID("$NetBSD: w.c,v 1.86 2020/06/30 15:02:55 kim Exp $"); #endif #endif /* not lint */ @@ -652,23 +652,23 @@ fixhost(struct entry *ep) int af = m ? AF_INET6 : AF_INET; size_t alen = m ? sizeof(l.l6) : sizeof(l.l4); if (!nflag && inet_pton(af, p, ) && - (hp = gethostbyaddr((char *), alen, af))) { - if (domain[0] != '\0') { - p = hp->h_name; - p += strlen(hp->h_name); - p -= strlen(domain); - if (p > hp->h_name && - strcasecmp(p, domain) == 0) -*p = '\0'; - } - p = hp->h_name; + (hp = gethostbyaddr((char *), alen, af))) + strlcpy(host_buf, hp->h_name, sizeof(host_buf)); + + if (domain[0] != '\0') { + p = host_buf; + p += strlen(host_buf); + p -= strlen(domain); + if (p > host_buf && + strcasecmp(p, domain) == 0) + *p = '\0'; } if (x) - (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", p, x); + (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", host_buf, + x); else - - strlcpy(ep->host, p, sizeof(ep->host)); + strlcpy(ep->host, host_buf, sizeof(ep->host)); } static void
CVS commit: src/usr.bin/w
Module Name:src Committed By: kim Date: Tue Jun 30 14:57:25 UTC 2020 Modified Files: src/usr.bin/w: w.c Log Message: Compute a value for domain before comparing against it To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.84 src/usr.bin/w/w.c:1.85 --- src/usr.bin/w/w.c:1.84 Tue Oct 30 21:15:09 2018 +++ src/usr.bin/w/w.c Tue Jun 30 14:57:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.84 2018/10/30 21:15:09 kre Exp $ */ +/* $NetBSD: w.c,v 1.85 2020/06/30 14:57:25 kim Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.84 2018/10/30 21:15:09 kre Exp $"); +__RCSID("$NetBSD: w.c,v 1.85 2020/06/30 14:57:25 kim Exp $"); #endif #endif /* not lint */ @@ -205,6 +205,18 @@ main(int argc, char **argv) curtain = 0; } + if (!nflag) { + int rv; + char *p; + + rv = gethostname(domain, sizeof(domain)); + domain[sizeof(domain) - 1] = '\0'; + if (rv < 0 || (p = strchr(domain, '.')) == 0) + domain[0] = '\0'; + else + memmove(domain, p, strlen(p) + 1); + } + #ifdef SUPPORT_UTMPX setutxent(); #endif @@ -388,18 +400,6 @@ main(int argc, char **argv) } #endif - if (!nflag) { - int rv; - char *p; - - rv = gethostname(domain, sizeof(domain)); - domain[sizeof(domain) - 1] = '\0'; - if (rv < 0 || (p = strchr(domain, '.')) == 0) - domain[0] = '\0'; - else - memmove(domain, p, strlen(p) + 1); - } - for (ep = ehead; ep != NULL; ep = ep->next) { if (ep->tp != NULL) kp = ep->tp;
CVS commit: src/usr.bin/w
Module Name:src Committed By: sevan Date: Thu Dec 6 19:15:35 UTC 2018 Modified Files: src/usr.bin/w: uptime.1 w.1 Log Message: Document the source of load average figures. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/w/uptime.1 cvs rdiff -u -r1.18 -r1.19 src/usr.bin/w/w.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/uptime.1 diff -u src/usr.bin/w/uptime.1:1.11 src/usr.bin/w/uptime.1:1.12 --- src/usr.bin/w/uptime.1:1.11 Thu Dec 6 19:01:53 2018 +++ src/usr.bin/w/uptime.1 Thu Dec 6 19:15:35 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: uptime.1,v 1.11 2018/12/06 19:01:53 sevan Exp $ +.\" $NetBSD: uptime.1,v 1.12 2018/12/06 19:15:35 sevan Exp $ .\" .\" Copyright (c) 1980, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -46,6 +46,8 @@ utility. .Nm displays the current time, the length of time the system has been up, the number of users, and the load average of the system over the last 1, 5, and 15 minutes. +The load average is obtained using +.Xr getloadavg 3 . .Sh FILES .Bl -tag -width /netbsd .It Pa /netbsd @@ -53,7 +55,8 @@ system name list .El .Sh SEE ALSO .Xr top 1 , -.Xr w 1 +.Xr w 1 , +.Xr getloadavg 3 .Sh HISTORY The .Nm Index: src/usr.bin/w/w.1 diff -u src/usr.bin/w/w.1:1.18 src/usr.bin/w/w.1:1.19 --- src/usr.bin/w/w.1:1.18 Tue Jan 11 09:39:12 2005 +++ src/usr.bin/w/w.1 Thu Dec 6 19:15:35 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: w.1,v 1.18 2005/01/11 09:39:12 wiz Exp $ +.\" $NetBSD: w.1,v 1.19 2018/12/06 19:15:35 sevan Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)w.1 8.1 (Berkeley) 6/6/93 .\" -.Dd January 11, 2005 +.Dd December 6, 2018 .Dt W 1 .Os .Sh NAME @@ -51,6 +51,8 @@ been running, the number of users logged averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5, and 15 minutes. +The load average is obtained using +.Xr getloadavg 3 . .Pp The fields output are the user's login name, the name of the terminal the user is on, the host from which the user is logged in, the time the user @@ -91,7 +93,8 @@ list of users on the system .Xr finger 1 , .Xr ps 1 , .Xr uptime 1 , -.Xr who 1 +.Xr who 1 , +.Xr getloadavg 3 .Sh HISTORY The .Nm
CVS commit: src/usr.bin/w
Module Name:src Committed By: sevan Date: Thu Dec 6 19:01:53 UTC 2018 Modified Files: src/usr.bin/w: uptime.1 Log Message: Add a statement about uptime's relation to w(1). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/w/uptime.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/uptime.1 diff -u src/usr.bin/w/uptime.1:1.10 src/usr.bin/w/uptime.1:1.11 --- src/usr.bin/w/uptime.1:1.10 Thu Aug 7 11:17:13 2003 +++ src/usr.bin/w/uptime.1 Thu Dec 6 19:01:53 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: uptime.1,v 1.10 2003/08/07 11:17:13 agc Exp $ +.\" $NetBSD: uptime.1,v 1.11 2018/12/06 19:01:53 sevan Exp $ .\" .\" Copyright (c) 1980, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)uptime.1 8.2 (Berkeley) 4/18/94 .\" -.Dd April 18, 1994 +.Dd December 6, 2018 .Dt UPTIME 1 .Os .Sh NAME @@ -40,16 +40,19 @@ .Sh DESCRIPTION The .Nm -utility displays the current time, -the length of time the system has been up, -the number of users, and the load average of the system over the last -1, 5, and 15 minutes. +utility presents a subset of the information obtained by the +.Xr w 1 +utility. +.Nm +displays the current time, the length of time the system has been up, the number +of users, and the load average of the system over the last 1, 5, and 15 minutes. .Sh FILES .Bl -tag -width /netbsd .It Pa /netbsd system name list .El .Sh SEE ALSO +.Xr top 1 , .Xr w 1 .Sh HISTORY The
CVS commit: src/usr.bin/w
Module Name:src Committed By: christos Date: Wed Nov 16 02:03:30 UTC 2016 Modified Files: src/usr.bin/w: w.c Log Message: if there is more than one : it is not an X display, it is a v6 address To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.82 src/usr.bin/w/w.c:1.83 --- src/usr.bin/w/w.c:1.82 Mon Dec 22 10:24:14 2014 +++ src/usr.bin/w/w.c Tue Nov 15 21:03:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $ */ +/* $NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94"; #else -__RCSID("$NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $"); +__RCSID("$NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $"); #endif #endif /* not lint */ @@ -621,27 +621,38 @@ static void fixhost(struct entry *ep) { char host_buf[sizeof(ep->host)]; - char *p, *x; + char *p, *x, *m; struct hostent *hp; - struct in_addr l; + union { + struct in_addr l4; + struct in6_addr l6; + } l; strlcpy(host_buf, *ep->host ? ep->host : "-", sizeof(host_buf)); p = host_buf; /* - * XXX: Historical behavior, ':' in hostname means X display number, - * IPv6 not handled. + * One ':' in hostname means X display number, more is IPv6. */ for (x = p; x < _buf[sizeof(host_buf)]; x++) if (*x == '\0' || *x == ':') break; if (x == p + sizeof(host_buf) || *x != ':') - x = NULL; - else - *x++ = '\0'; - - if (!nflag && inet_aton(p, ) && - (hp = gethostbyaddr((char *), sizeof(l), AF_INET))) { + m = x = NULL; + else { + for (m = x + 1; m < _buf[sizeof(host_buf)]; m++) + if (*m == '\0' || *m == ':') +break; + if (m == p + sizeof(host_buf) || *m != ':') { + *x++ = '\0'; + m = NULL; + } else + x = NULL; + } + int af = m ? AF_INET6 : AF_INET; + size_t alen = m ? sizeof(l.l6) : sizeof(l.l4); + if (!nflag && inet_pton(af, p, ) && + (hp = gethostbyaddr((char *), alen, af))) { if (domain[0] != '\0') { p = hp->h_name; p += strlen(hp->h_name);
CVS commit: src/usr.bin/w
Module Name:src Committed By: dennis Date: Mon Dec 22 15:24:14 UTC 2014 Modified Files: src/usr.bin/w: w.c Log Message: Move enough additional 'w' code into 'uptime' to keep the latter from double-counting utmp users. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.81 src/usr.bin/w/w.c:1.82 --- src/usr.bin/w/w.c:1.81 Wed Dec 3 06:12:19 2014 +++ src/usr.bin/w/w.c Mon Dec 22 15:24:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $ */ +/* $NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $); +__RCSID($NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $); #endif #endif /* not lint */ @@ -222,18 +222,26 @@ main(int argc, char **argv) continue; ++nusers; +#ifndef SUPPORT_UTMP if (wcmd == 0) continue; +#endif /* !SUPPORT_UTMP */ if (sel_user strncmp(utx-ut_name, sel_user, sizeof(utx-ut_name)) != 0) continue; if ((ep = calloc(1, sizeof(struct entry))) == NULL) err(1, NULL); - (void)memcpy(ep-name, utx-ut_name, sizeof(utx-ut_name)); (void)memcpy(ep-line, utx-ut_line, sizeof(utx-ut_line)); - ep-name[sizeof(utx-ut_name)] = '\0'; ep-line[sizeof(utx-ut_line)] = '\0'; + *nextp = ep; + nextp = (ep-next); + + if (wcmd == 0) + continue; + + (void)memcpy(ep-name, utx-ut_name, sizeof(utx-ut_name)); + ep-name[sizeof(utx-ut_name)] = '\0'; if (!nflag || getnameinfo((struct sockaddr *)utx-ut_ss, utx-ut_ss.ss_len, ep-host, sizeof(ep-host), NULL, 0, NI_NUMERICHOST) != 0) { @@ -245,10 +253,7 @@ main(int argc, char **argv) ep-type[0] = 'x'; ep-tv = utx-ut_tv; ep-pid = utx-ut_pid; - *nextp = ep; - nextp = (ep-next); - if (wcmd != 0) - process(ep); + process(ep); } #endif
CVS commit: src/usr.bin/w
Module Name:src Committed By: christos Date: Tue Dec 2 22:19:19 UTC 2014 Modified Files: src/usr.bin/w: w.c Log Message: if doing uptime, don't bother resolving names. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.79 src/usr.bin/w/w.c:1.80 --- src/usr.bin/w/w.c:1.79 Wed Feb 26 19:49:46 2014 +++ src/usr.bin/w/w.c Tue Dec 2 17:19:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.79 2014/02/27 00:49:46 joerg Exp $ */ +/* $NetBSD: w.c,v 1.80 2014/12/02 22:19:19 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.79 2014/02/27 00:49:46 joerg Exp $); +__RCSID($NetBSD: w.c,v 1.80 2014/12/02 22:19:19 christos Exp $); #endif #endif /* not lint */ @@ -156,6 +156,7 @@ main(int argc, char **argv) if (*progname == 'u') { wcmd = 0; options = ; + nflag = 1; } else { wcmd = 1; options = hiM:N:nw;
CVS commit: src/usr.bin/w
Module Name:src Committed By: mrg Date: Wed Dec 3 06:12:19 UTC 2014 Modified Files: src/usr.bin/w: w.c Log Message: redo the previous; avoid a bunch of processing when running as uptime, and as a side effect, avoid any name lookups. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.80 src/usr.bin/w/w.c:1.81 --- src/usr.bin/w/w.c:1.80 Tue Dec 2 22:19:19 2014 +++ src/usr.bin/w/w.c Wed Dec 3 06:12:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.80 2014/12/02 22:19:19 christos Exp $ */ +/* $NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.80 2014/12/02 22:19:19 christos Exp $); +__RCSID($NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $); #endif #endif /* not lint */ @@ -156,7 +156,6 @@ main(int argc, char **argv) if (*progname == 'u') { wcmd = 0; options = ; - nflag = 1; } else { wcmd = 1; options = hiM:N:nw; @@ -222,6 +221,10 @@ main(int argc, char **argv) if (utx-ut_type != USER_PROCESS) continue; ++nusers; + + if (wcmd == 0) + continue; + if (sel_user strncmp(utx-ut_name, sel_user, sizeof(utx-ut_name)) != 0) continue; @@ -268,6 +271,10 @@ main(int argc, char **argv) continue; ++nusers; + + if (wcmd == 0) + continue; + if ((ep = calloc(1, sizeof(struct entry))) == NULL) err(1, NULL); (void)memcpy(ep-name, ut-ut_name, sizeof(ut-ut_name)); @@ -280,8 +287,7 @@ main(int argc, char **argv) ep-tv.tv_sec = ut-ut_time; *nextp = ep; nextp = (ep-next); - if (wcmd != 0) - process(ep); + process(ep); } #endif
CVS commit: src/usr.bin/w
Module Name:src Committed By: joerg Date: Thu Feb 27 00:49:46 UTC 2014 Modified Files: src/usr.bin/w: w.c Log Message: struct member can't be null, if the pointer itself is valid. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.78 src/usr.bin/w/w.c:1.79 --- src/usr.bin/w/w.c:1.78 Wed Feb 19 20:42:14 2014 +++ src/usr.bin/w/w.c Thu Feb 27 00:49:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.78 2014/02/19 20:42:14 dsl Exp $ */ +/* $NetBSD: w.c,v 1.79 2014/02/27 00:49:46 joerg Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.78 2014/02/19 20:42:14 dsl Exp $); +__RCSID($NetBSD: w.c,v 1.79 2014/02/27 00:49:46 joerg Exp $); #endif #endif /* not lint */ @@ -426,14 +426,10 @@ pr_args(struct kinfo_proc2 *kp) left = argwidth; argv = kvm_getargv2(kd, kp, (argwidth 0) ? 0 : argwidth); if (argv == 0) { - if (kp-p_comm == 0) { - goto nothing; - } else { - fmt_putc('(', left); - fmt_puts((char *)kp-p_comm, left); - fmt_putc(')', left); - return; - } + fmt_putc('(', left); + fmt_puts((char *)kp-p_comm, left); + fmt_putc(')', left); + return; } while (*argv) { fmt_puts(*argv, left);
CVS commit: src/usr.bin/w
Module Name:src Committed By: christos Date: Mon Sep 9 19:20:38 UTC 2013 Modified Files: src/usr.bin/w: w.c Log Message: Expand ep-host to contain the final string that we are going to print before computing the width of the host column. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.76 src/usr.bin/w/w.c:1.77 --- src/usr.bin/w/w.c:1.76 Thu Oct 20 22:26:09 2011 +++ src/usr.bin/w/w.c Mon Sep 9 15:20:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.76 2011/10/21 02:26:09 christos Exp $ */ +/* $NetBSD: w.c,v 1.77 2013/09/09 19:20:38 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.76 2011/10/21 02:26:09 christos Exp $); +__RCSID($NetBSD: w.c,v 1.77 2013/09/09 19:20:38 christos Exp $); #endif #endif /* not lint */ @@ -126,17 +126,16 @@ static int proc_compare_wrapper(const st static int ttystat(const char *, struct stat *); static void process(struct entry *); #endif +static void fixhost(struct entry *ep); __dead static void usage(int); int main(int argc, char **argv) { struct kinfo_proc2 *kp; - struct hostent *hp; - struct in_addr l; struct entry *ep; int ch, i, nentries, nusers, wcmd, curtain, use_sysctl; - char *memf, *nlistf, *p, *x, *usrnp; + char *memf, *nlistf, *usrnp; const char *options; time_t then; size_t len; @@ -147,7 +146,7 @@ main(int argc, char **argv) struct utmpx *utx; #endif const char *progname; - char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX]; + char errbuf[_POSIX2_LINE_MAX]; setprogname(argv[0]); @@ -239,6 +238,7 @@ main(int argc, char **argv) sizeof(utx-ut_host)); ep-host[sizeof(utx-ut_host)] = '\0'; } + fixhost(ep); ep-type[0] = 'x'; ep-tv = utx-ut_tv; ep-pid = utx-ut_pid; @@ -276,6 +276,7 @@ main(int argc, char **argv) ep-name[sizeof(ut-ut_name)] = '\0'; ep-line[sizeof(ut-ut_line)] = '\0'; ep-host[sizeof(ut-ut_host)] = '\0'; + fixhost(ep); ep-tv.tv_sec = ut-ut_time; *nextp = ep; nextp = (ep-next); @@ -378,6 +379,7 @@ main(int argc, char **argv) if (!nflag) { int rv; + char *p; rv = gethostname(domain, sizeof(domain)); domain[sizeof(domain) - 1] = '\0'; @@ -388,36 +390,6 @@ main(int argc, char **argv) } for (ep = ehead; ep != NULL; ep = ep-next) { - char host_buf[MAXHOSTNAMELEN + 1]; - - strlcpy(host_buf, *ep-host ? ep-host : -, sizeof(host_buf)); - p = host_buf; - - for (x = p; x p + MAXHOSTNAMELEN; x++) - if (*x == '\0' || *x == ':') -break; - if (x == p + MAXHOSTNAMELEN || *x != ':') - x = NULL; - else - *x++ = '\0'; - - if (!nflag inet_aton(p, l) - (hp = gethostbyaddr((char *)l, sizeof(l), AF_INET))) { - if (domain[0] != '\0') { -p = hp-h_name; -p += strlen(hp-h_name); -p -= strlen(domain); -if (p hp-h_name -strcasecmp(p, domain) == 0) - *p = '\0'; - } - p = hp-h_name; - } - if (x) { - (void)snprintf(buf, sizeof(buf), %s:%s, p, x); - p = buf; - } - if (ep-tp != NULL) kp = ep-tp; else if (ep-pp != NULL) @@ -434,7 +406,7 @@ main(int argc, char **argv) usrnp = (kp == NULL) ? ep-name : kp-p_login; (void)printf(%-*s %-7.7s %-*.*s , maxname, usrnp, ep-line, - maxhost, maxhost, *p ? p : -); + maxhost, maxhost, ep-host); then = (time_t)ep-tv.tv_sec; pr_attime(then, now); pr_idle(ep-idle); @@ -639,6 +611,49 @@ proc_compare_wrapper(const struct kinfo_ } static void +fixhost(struct entry *ep) +{ + char host_buf[sizeof(ep-host)]; + char *p, *x; + struct hostent *hp; + struct in_addr l; + + strlcpy(host_buf, *ep-host ? ep-host : -, sizeof(host_buf)); + p = host_buf; + + /* + * XXX: Historical behavior, ':' in hostname means X display number, + * IPv6 not handled. + */ + for (x = p; x host_buf[sizeof(host_buf)]; x++) + if (*x == '\0' || *x == ':') + break; + if (x == p + sizeof(host_buf) || *x != ':') + x = NULL; + else + *x++ = '\0'; + + if (!nflag inet_aton(p, l) + (hp = gethostbyaddr((char *)l, sizeof(l), AF_INET))) { + if (domain[0] != '\0') { + p = hp-h_name; + p += strlen(hp-h_name); + p -= strlen(domain); + if (p hp-h_name + strcasecmp(p, domain) == 0) +*p = '\0'; + } + p = hp-h_name; + } + + if (x) + (void)snprintf(ep-host, sizeof(ep-host), %s:%s, p, x); + else + + strlcpy(ep-host, p, sizeof(ep-host)); +} + +static void usage(int wcmd) {
CVS commit: src/usr.bin/w
Module Name:src Committed By: christos Date: Fri Oct 21 02:26:09 UTC 2011 Modified Files: src/usr.bin/w: Makefile extern.h w.c Removed Files: src/usr.bin/w: proc_compare.c Log Message: Remove stale proc_compare code and use the shared one in libutil. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/w/Makefile cvs rdiff -u -r1.6 -r1.7 src/usr.bin/w/extern.h cvs rdiff -u -r1.14 -r0 src/usr.bin/w/proc_compare.c cvs rdiff -u -r1.75 -r1.76 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/Makefile diff -u src/usr.bin/w/Makefile:1.20 src/usr.bin/w/Makefile:1.21 --- src/usr.bin/w/Makefile:1.20 Wed Aug 17 09:48:11 2011 +++ src/usr.bin/w/Makefile Thu Oct 20 22:26:09 2011 @@ -1,13 +1,13 @@ -# $NetBSD: Makefile,v 1.20 2011/08/17 13:48:11 christos Exp $ +# $NetBSD: Makefile,v 1.21 2011/10/21 02:26:09 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk PROG= w -SRCS= fmt.c pr_time.c proc_compare.c w.c +SRCS= fmt.c pr_time.c w.c MAN= w.1 uptime.1 -DPADD= ${LIBKVM} -LDADD= -lkvm +DPADD= ${LIBKVM} ${LIBUTIL} +LDADD= -lkvm -lutil LINKS= ${BINDIR}/w ${BINDIR}/uptime CPPFLAGS+= -DSUPPORT_UTMP -DSUPPORT_UTMPX Index: src/usr.bin/w/extern.h diff -u src/usr.bin/w/extern.h:1.6 src/usr.bin/w/extern.h:1.7 --- src/usr.bin/w/extern.h:1.6 Thu Aug 7 07:17:12 2003 +++ src/usr.bin/w/extern.h Thu Oct 20 22:26:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.6 2003/08/07 11:17:12 agc Exp $ */ +/* $NetBSD: extern.h,v 1.7 2011/10/21 02:26:09 christos Exp $ */ /*- * Copyright (c) 1993 @@ -36,4 +36,3 @@ void fmt_puts(char *, int *); void fmt_putc(int, int *); void pr_attime(time_t *, time_t *); void pr_idle(time_t); -int proc_compare(struct kinfo_proc2 *, struct kinfo_proc2 *); Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.75 src/usr.bin/w/w.c:1.76 --- src/usr.bin/w/w.c:1.75 Fri Sep 16 11:39:30 2011 +++ src/usr.bin/w/w.c Thu Oct 20 22:26:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.75 2011/09/16 15:39:30 joerg Exp $ */ +/* $NetBSD: w.c,v 1.76 2011/10/21 02:26:09 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.75 2011/09/16 15:39:30 joerg Exp $); +__RCSID($NetBSD: w.c,v 1.76 2011/10/21 02:26:09 christos Exp $); #endif #endif /* not lint */ @@ -120,6 +120,8 @@ struct entry { static void pr_args(struct kinfo_proc2 *); static void pr_header(time_t *, int); +static int proc_compare_wrapper(const struct kinfo_proc2 *, +const struct kinfo_proc2 *); #if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX) static int ttystat(const char *, struct stat *); static void process(struct entry *); @@ -302,9 +304,6 @@ main(int argc, char **argv) /* Include trailing space because TTY header starts one column early. */ for (i = 0; i nentries; i++, kp++) { - if (kp-p_stat == SIDL || kp-p_stat == SZOMB) - continue; - for (ep = ehead; ep != NULL; ep = ep-next) { if (ep-tdev != 0 ep-tdev == kp-p_tdev kp-p__pgid == kp-p_tpgid) { @@ -312,7 +311,7 @@ main(int argc, char **argv) * Proc is in foreground of this * terminal */ -if (proc_compare(ep-tp, kp)) +if (proc_compare_wrapper(ep-tp, kp)) ep-tp = kp; break; } @@ -618,6 +617,27 @@ process(struct entry *ep) } #endif +static int +proc_compare_wrapper(const struct kinfo_proc2 *p1, +const struct kinfo_proc2 *p2) +{ + struct kinfo_lwp *l1, *l2; + int cnt; + + if (p1 == NULL) + return 1; + + l1 = kvm_getlwps(kd, p1-p_pid, 0, sizeof(*l1), cnt); + if (l1 == NULL || cnt == 0) + return 1; + + l2 = kvm_getlwps(kd, p2-p_pid, 0, sizeof(*l1), cnt); + if (l2 == NULL || cnt == 0) + return 0; + + return proc_compare(p1, l1, p2, l2); +} + static void usage(int wcmd) {
CVS commit: src/usr.bin/w
Module Name:src Committed By: christos Date: Wed Aug 17 13:48:11 UTC 2011 Modified Files: src/usr.bin/w: Makefile pr_time.c Log Message: Eliminate non-literal format strings, and now that gcc warns, kill y2k format warning. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.bin/w/Makefile cvs rdiff -u -r1.17 -r1.18 src/usr.bin/w/pr_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/Makefile diff -u src/usr.bin/w/Makefile:1.19 src/usr.bin/w/Makefile:1.20 --- src/usr.bin/w/Makefile:1.19 Wed Feb 26 10:01:09 2003 +++ src/usr.bin/w/Makefile Wed Aug 17 09:48:11 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.19 2003/02/26 15:01:09 christos Exp $ +# $NetBSD: Makefile,v 1.20 2011/08/17 13:48:11 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk @@ -13,4 +13,6 @@ .PATH: ${NETBSDSRCDIR}/bin/ps +COPTS.pr_time.c += -Wno-format-y2k + .include bsd.prog.mk Index: src/usr.bin/w/pr_time.c diff -u src/usr.bin/w/pr_time.c:1.17 src/usr.bin/w/pr_time.c:1.18 --- src/usr.bin/w/pr_time.c:1.17 Tue Apr 14 03:41:36 2009 +++ src/usr.bin/w/pr_time.c Wed Aug 17 09:48:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_time.c,v 1.17 2009/04/14 07:41:36 lukem Exp $ */ +/* $NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)pr_time.c 8.2 (Berkeley) 4/4/94; #else -__RCSID($NetBSD: pr_time.c,v 1.17 2009/04/14 07:41:36 lukem Exp $); +__RCSID($NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $); #endif #endif /* not lint */ @@ -62,25 +62,22 @@ int tnow_yday; struct tm *tp; time_t diff; - const char *fmt; tnow_yday = localtime(now)-tm_yday; tp = localtime(started); diff = *now - *started; - /* If more than a week, use day-month-year. */ - if (diff SECSPERDAY * DAYSPERWEEK) - fmt = %d%b%y; - - /* If not today, use day-hour-am/pm. */ - else if (tp-tm_yday != tnow_yday) - fmt = %a% I%p; - - /* Default is hh:mm{am,pm}. */ - else - fmt = %l:% M%p; + if (diff SECSPERDAY * DAYSPERWEEK) { + /* If more than a week, use day-month-year. */ + (void)strftime(buf, sizeof(buf), %d%b%y, tp); + } else if (tp-tm_yday != tnow_yday) { + /* If not today, use day-hour-am/pm. Damn SCCS */ + (void)strftime(buf, sizeof(buf), %a% I%p, tp); + } else { + /* Default is hh:mm{am,pm}. Damn SCCS */ + (void)strftime(buf, sizeof(buf), %l:% M%p, tp); + } - (void)strftime(buf, sizeof(buf), fmt, tp); buf[sizeof(buf) - 1] = '\0'; (void)fputs(buf, stdout); }
CVS commit: src/usr.bin/w
Module Name:src Committed By: lukem Date: Tue Apr 14 07:37:32 UTC 2009 Modified Files: src/usr.bin/w: w.c To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/usr.bin/w/w.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/w/w.c diff -u src/usr.bin/w/w.c:1.73 src/usr.bin/w/w.c:1.74 --- src/usr.bin/w/w.c:1.73 Mon Jul 21 14:19:27 2008 +++ src/usr.bin/w/w.c Tue Apr 14 07:37:31 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: w.c,v 1.73 2008/07/21 14:19:27 lukem Exp $ */ +/* $NetBSD: w.c,v 1.74 2009/04/14 07:37:31 lukem Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = @(#)w.c 8.6 (Berkeley) 6/30/94; #else -__RCSID($NetBSD: w.c,v 1.73 2008/07/21 14:19:27 lukem Exp $); +__RCSID($NetBSD: w.c,v 1.74 2009/04/14 07:37:31 lukem Exp $); #endif #endif /* not lint */ @@ -91,7 +91,6 @@ struct winsize ws; kvm_t *kd; time_t now; /* the current time of day */ -time_t uptime; /* time of last reboot elapsed time since */ int ttywidth; /* width of tty */ int argwidth; /* width of tty left to print process args */ int header = 1; /* true if -h flag: don't print heading */ @@ -117,7 +116,7 @@ struct kinfo_proc2 *tp; /* `most interesting' tty proc */ struct kinfo_proc2 *pp; /* pid proc */ pid_t pid; /* pid or ~0 if not known */ -} *ep, *ehead = NULL, **nextp = ehead; +} *ehead = NULL, **nextp = ehead; static void pr_args(struct kinfo_proc2 *); static void pr_header(time_t *, int); @@ -135,8 +134,10 @@ struct kinfo_proc2 *kp; struct hostent *hp; struct in_addr l; + struct entry *ep; int ch, i, nentries, nusers, wcmd, curtain, use_sysctl; char *memf, *nlistf, *p, *x, *usrnp; + const char *options; time_t then; size_t len; #ifdef SUPPORT_UTMP @@ -156,14 +157,14 @@ progname++; if (*progname == 'u') { wcmd = 0; - p = ; + options = ; } else { wcmd = 1; - p = hiM:N:nw; + options = hiM:N:nw; } memf = nlistf = NULL; - while ((ch = getopt(argc, argv, p)) != -1) + while ((ch = getopt(argc, argv, options)) != -1) switch (ch) { case 'h': header = 0; @@ -392,8 +393,8 @@ for (ep = ehead; ep != NULL; ep = ep-next) { char host_buf[MAXHOSTNAMELEN + 1]; - strlcpy(host_buf, ep-host, sizeof(host_buf)); - p = *host_buf ? host_buf : -; + strlcpy(host_buf, *ep-host ? ep-host : -, sizeof(host_buf)); + p = host_buf; for (x = p; x p + MAXHOSTNAMELEN; x++) if (*x == '\0' || *x == ':') @@ -481,9 +482,9 @@ { double avenrun[3]; time_t uptime; - int days, hrs, i, mins; + int days, hrs, mins; int mib[2]; - size_t size; + size_t size, i; char buf[256]; /*