From 31c0d6f2840ee6c0c7c098bf10c5b974938585c6 Mon Sep 17 00:00:00 2001 From: Martin Wilke Date: Thu, 28 Jan 2010 21:33:20 +0000 Subject: [PATCH] - Fix build on HEAD PR: 143310 Patched by: ed@ Submitted by: Konrad Heuer (maintainer) --- sysutils/rmonitor/Makefile | 8 +++- sysutils/rmonitor/files/extra-patch-utmpx | 51 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 sysutils/rmonitor/files/extra-patch-utmpx diff --git a/sysutils/rmonitor/Makefile b/sysutils/rmonitor/Makefile index 1ea1202e16bd..4e45d5dc9387 100644 --- a/sysutils/rmonitor/Makefile +++ b/sysutils/rmonitor/Makefile @@ -20,4 +20,10 @@ MANCOMPRESSED= yes #CFLAGS+= -w -.include +.include + +.if ${OSVERSION} >= 900007 +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-utmpx +.endif + +.include diff --git a/sysutils/rmonitor/files/extra-patch-utmpx b/sysutils/rmonitor/files/extra-patch-utmpx new file mode 100644 index 000000000000..74701016bf05 --- /dev/null +++ b/sysutils/rmonitor/files/extra-patch-utmpx @@ -0,0 +1,51 @@ +--- src/rmonitor.c ++++ src/rmonitor.c +@@ -88,7 +88,7 @@ + #include + #include + #include +-#include ++#include + + + #define DEFTOL 2.5 /* default tolerance */ +@@ -300,7 +300,7 @@ + int memfre = 0; + int memtot = 0; + int memuse = 0; +- int nu = -1; ++ int nu = 0; + int np = -1; + int openf = -1; + int pgcnt = 0; +@@ -309,9 +309,8 @@ + int pgsize = 0; + int slvl = 0; + int vn[3]; +- int utfd; + time_t ct; +- struct utmp utmprec; ++ struct utmpx *utmprec; + + union { + char buf[STRLEN]; +@@ -402,14 +401,12 @@ + + if (getloadavg(lavg, samples) != samples) errmsg("getloadavg"); + +- if ((utfd = open(_PATH_UTMP, O_RDONLY)) >= 0) { +- nu = 0; +- while (read(utfd, &utmprec, sizeof utmprec) > 0) +- if (*(utmprec.ut_name)) nu++; +- if (close(utfd) < 0) errmsg("close"); ++ setutxent(); ++ while ((utmprec = getutxent()) != NULL) { ++ if (utmprec->ut_type == USER_PROCESS) ++ nu++; + } +- else +- errmsg("open"); ++ endutxent(); + + #if __FreeBSD_version >= 420000 + snprintf(stat, STRLEN,