Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.bin/w Pull up revs 1.38-1.40:



details:   https://anonhg.NetBSD.org/src/rev/886a5b9b6f82
branches:  netbsd-1-5
changeset: 488630:886a5b9b6f82
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sat Jul 22 04:47:54 2000 +0000

description:
Pull up revs 1.38-1.40:
Summary of changes are:
 + Use KERN_CONSDEV for determining the console device.
 + Set minimum width for login name properly.

diffstat:

 usr.bin/w/w.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (70 lines):

diff -r 9430af617c31 -r 886a5b9b6f82 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Sat Jul 22 04:40:39 2000 +0000
+++ b/usr.bin/w/w.c     Sat Jul 22 04:47:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.36.2.1 2000/06/26 00:45:30 simonb Exp $        */
+/*     $NetBSD: w.c,v 1.36.2.2 2000/07/22 04:47:54 simonb Exp $        */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.36.2.1 2000/06/26 00:45:30 simonb Exp $");
+__RCSID("$NetBSD: w.c,v 1.36.2.2 2000/07/22 04:47:54 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -94,7 +94,7 @@
 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 */
+int            argwidth;       /* width of tty left to print process args */
 int            header = 1;     /* true if -h flag: don't print heading */
 int            nflag;          /* true if -n flag: don't convert addrs */
 int            sortidle;       /* sort bu idle time */
@@ -201,7 +201,6 @@
                if (!(stp = ttystat(ep->utmp.ut_line)))
                        continue;
                ep->tdev = stp->st_rdev;
-#ifdef CPU_CONSDEV
                /*
                 * If this is the console device, attempt to ascertain
                 * the true console device dev_t.
@@ -210,12 +209,11 @@
                        int mib[2];
                        size_t size;
 
-                       mib[0] = CTL_MACHDEP;
-                       mib[1] = CPU_CONSDEV;
+                       mib[0] = CTL_KERN;
+                       mib[1] = KERN_CONSDEV;
                        size = sizeof(dev_t);
                        (void) sysctl(mib, 2, &ep->tdev, &size, NULL, 0);
                }
-#endif
                if ((ep->idle = now - stp->st_atime) < 0)
                        ep->idle = 0;
        }
@@ -230,7 +228,9 @@
        if ((kp = kvm_getproc2(kd, KERN_PROC_ALL, 0,
            sizeof(struct kinfo_proc2), &nentries)) == NULL)
                errx(1, "%s", kvm_geterr(kd));
-       lognamelen = 0;
+
+       /* Include trailing space because TTY header starts one column early. */
+       lognamelen = sizeof("USER ") - 1 /* NUL */;
        for (i = 0; i < nentries; i++, kp++) {
 
                if (kp->p_stat == SIDL || kp->p_stat == SZOMB)
@@ -254,7 +254,7 @@
        argwidth = printf("%-*sTTY %-*s %*s  IDLE WHAT\n",
            lognamelen, "USER", UT_HOSTSIZE, "FROM",
            7 /* "dddhhXm" */, "LOGIN@");
-       argwidth -= sizeof("WHAT\n");
+       argwidth -= sizeof("WHAT\n") - 1 /* NUL */;
 
        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 &&
             ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 &&



Home | Main Index | Thread Index | Old Index