aboutsummaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorHajimu UMEMOTO <ume@FreeBSD.org>2010-01-19 11:25:22 +0000
committerHajimu UMEMOTO <ume@FreeBSD.org>2010-01-19 11:25:22 +0000
commit04bdb5a1f9b33243d6745ded9e41e31e619b6a7d (patch)
tree6511bf021f34c5f9c129906908de006d13218947 /sysutils
parenta8bef818e979a2424d7cec7e9a41fe0688e79f81 (diff)
downloadports-04bdb5a1f9b33243d6745ded9e41e31e619b6a7d.tar.gz
ports-04bdb5a1f9b33243d6745ded9e41e31e619b6a7d.zip
Notes
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/gkrellm2/files/patch-src::sysdeps::freebsd.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/sysutils/gkrellm2/files/patch-src::sysdeps::freebsd.c b/sysutils/gkrellm2/files/patch-src::sysdeps::freebsd.c
new file mode 100644
index 000000000000..8ec53cd393c5
--- /dev/null
+++ b/sysutils/gkrellm2/files/patch-src::sysdeps::freebsd.c
@@ -0,0 +1,71 @@
+Index: src/sysdeps/freebsd.c
+diff -u -p src/sysdeps/freebsd.c.orig src/sysdeps/freebsd.c
+--- src/sysdeps/freebsd.c.orig 2010-01-05 08:12:21.000000000 +0900
++++ src/sysdeps/freebsd.c 2010-01-19 20:13:55.380695497 +0900
+@@ -255,7 +255,11 @@ pcpu_probe_done:
+
+ #include <limits.h>
+ #include <paths.h>
++#if __FreeBSD_version < 900007
+ #include <utmp.h>
++#else
++#include <utmpx.h>
++#endif
+
+ static int oid_v_forks[CTL_MAXNAME + 2];
+ static int oid_v_vforks[CTL_MAXNAME + 2];
+@@ -364,12 +368,20 @@ gkrellm_sys_proc_read_users(void)
+ gint n_users;
+ struct stat sb, s;
+ gchar ttybuf[MAXPATHLEN];
++#ifdef _PATH_UTMP
+ FILE *ut;
+ struct utmp utmp;
++#define UTMP_FILE _PATH_UTMP
++#else
++ struct utmpx *utmp;
++#define UTMP_FILE "/var/run/utx.active"
++#endif
+ static time_t utmp_mtime;
+
+- if (stat(_PATH_UTMP, &s) != 0 || s.st_mtime == utmp_mtime)
++ if (stat(UTMP_FILE, &s) != 0 || s.st_mtime == utmp_mtime)
+ return;
++
++#ifdef _PATH_UTMP
+ if ((ut = fopen(_PATH_UTMP, "r")) != NULL)
+ {
+ n_users = 0;
+@@ -379,14 +391,30 @@ gkrellm_sys_proc_read_users(void)
+ continue;
+ (void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s",
+ _PATH_DEV, utmp.ut_line);
+- /* corrupted record */
+ if (stat(ttybuf, &sb))
+- continue;
++ continue; /* corrupted record */
+ ++n_users;
+ }
+ (void)fclose(ut);
+ gkrellm_proc_assign_users(n_users);
+ }
++#else
++ setutxent();
++ n_users = 0;
++ while ((utmp = getutxent()) != NULL)
++ {
++ if (utmp->ut_type != USER_PROCESS)
++ continue;
++ (void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s",
++ _PATH_DEV, utmp->ut_line);
++ if (stat(ttybuf, &sb))
++ continue; /* corrupted record */
++ ++n_users;
++ }
++ endutxent();
++ gkrellm_proc_assign_users(n_users);
++#endif
++
+ utmp_mtime = s.st_mtime;
+ }
+