summaryrefslogtreecommitdiffstats
path: root/usr.bin/systat
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-12-05 20:52:11 +0000
committered <ed@FreeBSD.org>2009-12-05 20:52:11 +0000
commit5a04e9b9a2677076f770006fa2c2f92aa85e6539 (patch)
tree5da985f2ac4a90fe59b2c02e8fc0f038a256013e /usr.bin/systat
parent0ff95c5da21b0086da5db4bd1b324f1ab3cc1500 (diff)
downloadFreeBSD-src-5a04e9b9a2677076f770006fa2c2f92aa85e6539.zip
FreeBSD-src-5a04e9b9a2677076f770006fa2c2f92aa85e6539.tar.gz
Let systat's vmstat use utmpx.
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/Makefile4
-rw-r--r--usr.bin/systat/vmstat.c21
2 files changed, 9 insertions, 16 deletions
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index 49bb998..d89399c 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -14,7 +14,7 @@ SRCS+= icmp6.c ip6.c
CFLAGS+= -DINET6
.endif
-DPADD= ${LIBCURSES} ${LIBM} ${LIBDEVSTAT} ${LIBKVM}
-LDADD= -lcursesw -lm -ldevstat -lkvm
+DPADD= ${LIBCURSES} ${LIBM} ${LIBDEVSTAT} ${LIBKVM} ${LIBULOG}
+LDADD= -lcursesw -lm -ldevstat -lkvm -lulog
.include <bsd.prog.mk>
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 3866438..742e2f7 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -65,8 +65,9 @@ static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#define _ULOG_POSIX_NAMES
+#include <ulog.h>
#include <unistd.h>
-#include <utmp.h>
#include <devstat.h>
#include "systat.h"
#include "extern.h"
@@ -141,7 +142,6 @@ static void putlongdouble(long double, int, int, int, int, int);
static int ucount(void);
static int ncpu;
-static int ut;
static char buf[26];
static time_t t;
static double etime;
@@ -150,16 +150,10 @@ static long *intrloc;
static char **intrname;
static int nextintsrow;
-struct utmp utmp;
-
-
WINDOW *
openkre(void)
{
- ut = open(_PATH_UTMP, O_RDONLY);
- if (ut < 0)
- error("No utmp");
return (stdscr);
}
@@ -167,7 +161,6 @@ void
closekre(WINDOW *w)
{
- (void) close(ut);
if (w == NULL)
return;
wclear(w);
@@ -634,14 +627,14 @@ static int
ucount(void)
{
int nusers = 0;
+ struct utmpx *ut;
- if (ut < 0)
- return (0);
- while (read(ut, &utmp, sizeof(utmp)))
- if (utmp.ut_name[0] != '\0')
+ setutxent();
+ while ((ut = getutxent()) != NULL)
+ if (ut->ut_type == USER_PROCESS)
nusers++;
+ endutxent();
- lseek(ut, 0L, L_SET);
return (nusers);
}
OpenPOWER on IntegriCloud