aboutsummaryrefslogtreecommitdiff
path: root/x11-wm
diff options
context:
space:
mode:
authorStanislav Sedov <stas@FreeBSD.org>2010-03-24 10:02:38 +0000
committerStanislav Sedov <stas@FreeBSD.org>2010-03-24 10:02:38 +0000
commit49497cc6e48454e2647d79db5ce16852aac30726 (patch)
tree46f5a7aecf21a3fb999977bdba7d3dfa4e265675 /x11-wm
parenta9946dd0a79b4fb665937f013b7bdf22c1527a66 (diff)
downloadports-49497cc6e48454e2647d79db5ce16852aac30726.tar.gz
ports-49497cc6e48454e2647d79db5ce16852aac30726.zip
Notes
Diffstat (limited to 'x11-wm')
-rw-r--r--x11-wm/e17-module-uptime/Makefile4
-rw-r--r--x11-wm/e17-module-uptime/files/extra::e_mod_main.c58
2 files changed, 60 insertions, 2 deletions
diff --git a/x11-wm/e17-module-uptime/Makefile b/x11-wm/e17-module-uptime/Makefile
index 21059067e9fa..65855ebaba8c 100644
--- a/x11-wm/e17-module-uptime/Makefile
+++ b/x11-wm/e17-module-uptime/Makefile
@@ -27,8 +27,8 @@ USE_EFL= edje
.include <bsd.port.pre.mk>
-.if ${OSVERSION} > 900007
-BROKEN= fails to build with new utmpx
+.if ${OSVERSION} >= 900007
+EXTRA_PATCHES= ${FILESDIR}/extra::e_mod_main.c
.endif
.if !defined(WITHOUT_NLS)
diff --git a/x11-wm/e17-module-uptime/files/extra::e_mod_main.c b/x11-wm/e17-module-uptime/files/extra::e_mod_main.c
new file mode 100644
index 000000000000..5c67b053ff41
--- /dev/null
+++ b/x11-wm/e17-module-uptime/files/extra::e_mod_main.c
@@ -0,0 +1,58 @@
+--- e_mod_main.c
++++ e_mod_main.c
+@@ -4,7 +4,7 @@
+ #include <stdlib.h>
+ #include <stdint.h>
+ #include <sys/types.h>
+-#include <utmp.h>
++#include <utmpx.h>
+
+ #if TIME_WITH_SYS_TIME
+ # include <sys/time.h>
+@@ -445,11 +445,7 @@
+ struct timeval boottime;
+ time_t now;
+
+- FILE *utmp;
+- struct timespec tp;
+- struct utmp ut;
+- char ttybuf[MAXPATHLEN];
+- struct stat st;
++ struct utmpx *utmpstruct;
+ #endif
+
+ if (!inst)
+@@ -498,26 +494,15 @@
+ if (ret < 0)
+ warn ("getloadavg()");
+ # endif
+-
+- /* retrive number of active users */
+- utmp = fopen (_PATH_UTMP, "r");
+- if (utmp == NULL)
+- inst->nusers = -1;
+- else
++ inst->nusers = 0;
++ setutxent ();
++ while ((utmpstruct = getutxent ()))
+ {
+- for (inst->nusers = 0; fread (&ut, sizeof (ut), 1, utmp);)
+- {
+- if (ut.ut_name[0] == '\0')
+- continue;
+- (void) snprintf (ttybuf, sizeof (ttybuf), "%s%.*s", _PATH_DEV,
+- UT_LINESIZE, ut.ut_line);
+- if (stat (ttybuf, &st) != 0)
+- continue; /* broken record */
+-
+- inst->nusers++;
+- }
+- fclose (utmp);
++ if ((utmpstruct->ut_type == USER_PROCESS) &&
++ (utmpstruct->ut_user[0] != '\0'))
++ inst->nusers++;
+ }
++ endutxent ();
+ #else /* unsupported */
+ inst->uptime = -1;
+ inst->nusers = -1;