Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 2010 12:07:07 +0100 (CET)
From:      Konrad Heuer <kheuer@gwdg.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/143310: utmp.h -> utmpx.h migration in FreeBSD 9
Message-ID:  <201001281107.o0SB7788084004@gwdu60.gwdg.de>
Resent-Message-ID: <201001281140.o0SBe78m060038@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         143310
>Category:       ports
>Synopsis:       utmp.h -> utmpx.h migration in FreeBSD 9
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 28 11:40:06 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Konrad Heuer
>Release:        FreeBSD 8.0-RELEASE-p1 i386
>Organization:
GWDG
>Environment:
>Description:
	port does not build because of change in utmp interface
>How-To-Repeat:
	cd bin; make -f ../Makefile rmonitor
	cc -O2 -pipe -fno-strict-aliasing  -c ../src/rmonitor.c
	In file included from ../src/rmonitor.c:91:
	/usr/include/utmp.h:2:2: error: #error "<utmp.h> has been replaced by
	<utmpx.h>"
	../src/rmonitor.c: In function 'getstat':
	../src/rmonitor.c:314: error: storage size of 'utmprec' isn't known
	...

>Fix:

Patch was provided by Ed Schouten <ed@80386.nl> since I've no shell
access to a FreeBSD 9 system.

Thanks to him!

diff -uN gives:


Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/sysutils/rmonitor/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- Makefile	20 Feb 2009 15:06:15 -0000	1.6
+++ Makefile	28 Jan 2010 10:46:39 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	rmonitor
 PORTVERSION=	1.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 MASTER_SITES=	ftp://gwdu111.gwdg.de/pub/FreeBSD/misc/ \
 		ftp://gwdu112.gwdg.de/pub/FreeBSD/misc/
@@ -20,4 +20,10 @@
 
 #CFLAGS+=	-w
 
-.include <bsd.port.mk>
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} >= 900007
+EXTRA_PATCHES+=	${FILESDIR}/extra-patch-utmpx
+.endif
+
+.include <bsd.port.post.mk>
Index: files/extra-patch-utmpx
===================================================================
RCS file: files/extra-patch-utmpx
diff -N files/extra-patch-utmpx
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/extra-patch-utmpx	28 Jan 2010 10:46:39 -0000
@@ -0,0 +1,51 @@
+--- src/rmonitor.c
++++ src/rmonitor.c
+@@ -88,7 +88,7 @@
+ #include <sys/vmmeter.h>
+ #include <time.h>
+ #include <unistd.h>
+-#include <utmp.h>
++#include <utmpx.h>
+ 
+ 
+ #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,
>Release-Note:
>Audit-Trail:
>Unformatted:
 >System: FreeBSD 9



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001281107.o0SB7788084004>