Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/systat scan utmpx/utmp.



details:   https://anonhg.NetBSD.org/src/rev/fd0a70846aad
branches:  trunk
changeset: 534685:fd0a70846aad
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Aug 01 23:36:54 2002 +0000

description:
scan utmpx/utmp.

diffstat:

 usr.bin/systat/Makefile |   9 +++++----
 usr.bin/systat/vmstat.c |  30 ++++++++++++------------------
 2 files changed, 17 insertions(+), 22 deletions(-)

diffs (118 lines):

diff -r 1be00aeb907c -r fd0a70846aad usr.bin/systat/Makefile
--- a/usr.bin/systat/Makefile   Thu Aug 01 23:36:30 2002 +0000
+++ b/usr.bin/systat/Makefile   Thu Aug 01 23:36:54 2002 +0000
@@ -1,15 +1,16 @@
-#      $NetBSD: Makefile,v 1.24 2002/03/28 09:58:10 jmc Exp $
+#      $NetBSD: Makefile,v 1.25 2002/08/01 23:36:54 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/6/93
 
 PROG=  systat
 
-.PATH: ${.CURDIR}/../../usr.bin/vmstat
+.PATH: ${.CURDIR}/../../usr.bin/vmstat ${.CURDIR}/../../usr.bin/who
 
-CPPFLAGS+=-I${.CURDIR}/../../usr.bin/vmstat
+CPPFLAGS+=-I${.CURDIR}/../../usr.bin/vmstat -DSUPPORT_UTMP -DSUPPORT_UTMPX \
+       -I${.CURDIR}/../../usr.bin/who
 CWARNFLAGS+=    -Wno-format-y2k
 SRCS=  bufcache.c cmds.c cmdtab.c disks.c dkstats.c fetch.c globalcmds.c \
        icmp.c iostat.c ip.c keyboard.c main.c mbufs.c netcmds.c netstat.c \
-       pigs.c ps.c swap.c tcp.c vmstat.c
+       pigs.c ps.c swap.c tcp.c vmstat.c utmpentry.c
 DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM}
 LDADD= -lcurses -lm -lkvm
 BINGRP=        kmem
diff -r 1be00aeb907c -r fd0a70846aad usr.bin/systat/vmstat.c
--- a/usr.bin/systat/vmstat.c   Thu Aug 01 23:36:30 2002 +0000
+++ b/usr.bin/systat/vmstat.c   Thu Aug 01 23:36:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmstat.c,v 1.39 2002/06/30 00:10:34 sommerfeld Exp $   */
+/*     $NetBSD: vmstat.c,v 1.40 2002/08/01 23:36:55 christos Exp $     */
 
 /*-
  * Copyright (c) 1983, 1989, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 1/12/94";
 #endif
-__RCSID("$NetBSD: vmstat.c,v 1.39 2002/06/30 00:10:34 sommerfeld Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.40 2002/08/01 23:36:55 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -55,11 +55,11 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <utmp.h>
 
 #include "systat.h"
 #include "extern.h"
 #include "dkstats.h"
+#include "utmpentry.h"
 
 static struct Info {
        struct  uvmexp_sysctl uvmexp;
@@ -86,7 +86,6 @@
 static void putfloat(double, int, int, int, int, int);
 static int ucount(void);
 
-static int ut;
 static char buf[26];
 static u_int64_t t;
 static double etime;
@@ -96,15 +95,9 @@
 static char **intrname;
 static int nextintsrow;
 
-struct utmp utmp;
-
 WINDOW *
 openvmstat(void)
 {
-
-       ut = open(_PATH_UTMP, O_RDONLY);
-       if (ut < 0)
-               error("No utmp");
        return (stdscr);
 }
 
@@ -112,7 +105,6 @@
 closevmstat(WINDOW *w)
 {
 
-       (void) close(ut);
        if (w == NULL)
                return;
        wclear(w);
@@ -490,13 +482,16 @@
 static int
 ucount(void)
 {
-       int nusers = 0, onusers = -1;
+       static int onusers = -1;
+       static struct utmpentry *oehead = NULL;
+       int nusers = 0;
+       struct utmpentry *ehead;
 
-       if (ut < 0)
-               return (0);
-       while (read(ut, &utmp, sizeof(utmp)))
-               if (utmp.ut_name[0] != '\0')
-                       nusers++;
+       nusers = getutentries(NULL, &ehead);
+       if (oehead != ehead) {
+               freeutentries(oehead);
+               oehead = ehead;
+       }
 
        if (nusers != onusers) {
                if (nusers == 1)
@@ -504,7 +499,6 @@
                else
                        mvprintw(STATROW, STATCOL + 8, "s");
        }
-       lseek(ut, (off_t)0, SEEK_SET);
        onusers = nusers;
        return (nusers);
 }



Home | Main Index | Thread Index | Old Index