summaryrefslogtreecommitdiff
path: root/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
diff options
context:
space:
mode:
authorJoe Marcus Clarke <marcus@FreeBSD.org>2009-01-10 05:22:13 +0000
committerJoe Marcus Clarke <marcus@FreeBSD.org>2009-01-10 05:22:13 +0000
commit610ae5681637c1051a0c17b54e29d97f53da2f3a (patch)
treec231a1eb74b07e444fa7363012cb84bf23d83ce0 /devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
parentAdd a new framework for browser plugins, USE_WEBPLUGINS. It is for which foo (diff)
Presenting GNOME 2.24 for FreeBSD.
See http://library.gnome.org/misc/release-notes/2.24/ for the general release notes. On the FreeBSD front, this release introduces Fuse support in HAL, adds multi-CPU support to libgtop, WebKit updates, and fixes some long-standing seahorse and gnome-keyring bugs. The documentation updates to the website are forthcoming. This release features commits by adamw, ahze, kwm, mezz, and myself. It would not have been possible without are contributors and testers: Alexander Loginov Craig Butler [1] Dmitry Marakasov [6] Eric L. Chen Joseph S. Atkinson Kris Moore Lapo Luchini [7] Nikos Ntarmos Pawel Worach Romain Tartiere TAOKA Fumiyoshi [3] Yasuda Keisuke Zyl aZ [4] bf [2] [5] Florent Thoumie Peter Wemm pluknet PR: 125857 [1] 126993 [2] 130031 [3] 127399 [4] 127661 [5] 124302 [6] 129570 [7] 129936 123790
Notes
Notes: svn path=/head/; revision=225629
Diffstat (limited to 'devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c')
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c210
1 files changed, 31 insertions, 179 deletions
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c b/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
index 9ca014c1b508..e14dd39bdbe2 100644
--- a/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
@@ -1,136 +1,50 @@
---- sysdeps/freebsd/procopenfiles.c.orig 2008-12-06 20:43:44.256309000 -0500
-+++ sysdeps/freebsd/procopenfiles.c 2008-12-06 20:44:45.000000000 -0500
-@@ -28,6 +28,16 @@
- #include <glibtop/error.h>
- #include <glibtop/procopenfiles.h>
- #include <sys/types.h>
-+#include <sys/socket.h>
-+#include <sys/param.h>
-+#include <sys/sysctl.h>
-+#include <sys/un.h>
-+#include <sys/user.h>
-+#include <netinet/in.h>
-+#include <arpa/inet.h>
-+#ifdef HAVE_KINFO_GETFILE
+--- sysdeps/freebsd/procopenfiles.c.orig 2008-08-18 11:23:36.000000000 -0400
++++ sysdeps/freebsd/procopenfiles.c 2008-12-07 00:17:26.000000000 -0500
+@@ -35,6 +35,9 @@
+ #include <sys/user.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#ifdef HAVE_KINFO_PROC
+#include <libutil.h>
+#endif
#include <string.h>
#include <stdlib.h>
-@@ -46,6 +56,63 @@ _glibtop_init_proc_open_files_s (glibtop
- server->sysdeps.proc_open_files = _glibtop_sysdeps_proc_open_files;
- }
-
-+#if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
-+static char *
-+addr_to_string(struct sockaddr_storage *ss)
-+{
-+ char *buffer;
-+ char buffer2[INET6_ADDRSTRLEN];
-+ struct sockaddr_in6 *sin6;
-+ struct sockaddr_in *sin;
-+ struct sockaddr_un *sun;
-+
-+ switch (ss->ss_family) {
-+ case AF_LOCAL:
-+ sun = (struct sockaddr_un *)ss;
-+ if (strlen(sun->sun_path) == 0)
-+ buffer = g_strdup("-");
-+ else
-+ buffer = g_strdup(sun->sun_path);
-+ break;
-+ case AF_INET:
-+ sin = (struct sockaddr_in *)ss;
-+ buffer = g_strdup(inet_ntoa(sin->sin_addr));
-+ break;
-+ case AF_INET6:
-+ sin6 = (struct sockaddr_in6 *)ss;
-+ if (inet_ntop(AF_INET6, &sin6->sin6_addr, buffer2,
-+ sizeof(buffer2)) != NULL)
-+ buffer = g_strdup(buffer2);
-+ else
-+ buffer = g_strdup("-");
-+ break;
-+ }
-+
-+ return buffer;
-+}
-+
-+static int
-+addr_to_port(struct sockaddr_storage *ss)
-+{
-+ int port;
-+ struct sockaddr_in6 *sin6;
-+ struct sockaddr_in *sin;
-+
-+ switch (ss->ss_family) {
-+ case AF_INET:
-+ sin = (struct sockaddr_in *)ss;
-+ port = ntohs(sin->sin_port);
-+ break;
-+ case AF_INET6:
-+ sin6 = (struct sockaddr_in6 *)ss;
-+ port = ntohs(sin6->sin6_port);
-+ break;
-+ }
-+
-+ return port;
-+}
-+#else
-+
- static GArray *
- parse_output(const char *output) {
- GArray *entries;
-@@ -159,21 +226,123 @@ parse_output(const char *output) {
-
- return entries;
- }
-+#endif
-
- glibtop_open_files_entry *
- glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid)
+@@ -263,8 +266,12 @@ glibtop_get_proc_open_files_s (glibtop *
{
-+#if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
-+ struct kinfo_file *freep, *kif;
+ #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
+ struct kinfo_file *freep, *kif;
+#ifndef HAVE_KINFO_GETFILE
-+ int name[4];
-+ size_t len;
+ int name[4];
+ size_t len;
+#else
+ int cnt;
+#endif
-+ int i;
-+#else
+ size_t i;
+ #else
char *output;
-+#endif
- GArray *entries;
-
+@@ -274,6 +281,7 @@ glibtop_get_proc_open_files_s (glibtop *
memset(buf, 0, sizeof (glibtop_proc_open_files));
-+#if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
+ #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
+#ifndef HAVE_KINFO_GETFILE
-+ name[0] = CTL_KERN;
-+ name[1] = KERN_PROC;
-+ name[2] = KERN_PROC_FILEDESC;
-+ name[3] = pid;
-+
-+ if (sysctl(name, 4, NULL, &len, NULL, 0) < 0)
-+ return NULL;
-+
-+ freep = kif = g_malloc(len);
-+ if (sysctl(name, 4, kif, &len, NULL, 0) < 0) {
-+ g_free(freep);
-+ return NULL;
-+ }
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_FILEDESC;
+@@ -287,12 +295,25 @@ glibtop_get_proc_open_files_s (glibtop *
+ g_free(freep);
+ return NULL;
+ }
+#else
+ freep = kinfo_getfile(pid, &cnt);
+#endif
-+
-+ entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
-+
+
+ entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
+
+#ifndef HAVE_KINFO_GETFILE
-+ for (i = 0; i < len / sizeof(*kif); i++, kif++) {
-+ glibtop_open_files_entry entry = {0};
-+
+ for (i = 0; i < len / sizeof(*kif); i++, kif++) {
+ glibtop_open_files_entry entry = {0};
+
+ if (kif->kf_structsize != sizeof(*kif))
+ continue;
+#else
@@ -140,68 +54,6 @@
+ kif = &freep[i];
+#endif
+
-+ if (kif->kf_fd < 0)
-+ continue;
-+
-+ if (kif->kf_type == KF_TYPE_SOCKET) {
-+ if (kif->kf_sock_domain == AF_LOCAL) {
-+ struct sockaddr_un *sun;
-+
-+ entry.type = GLIBTOP_FILE_TYPE_LOCALSOCKET;
-+ sun = (struct sockaddr_un *)&kif->kf_sa_local;
-+
-+ if (sun->sun_path[0]) {
-+ char *addrstr;
-+
-+ addrstr = addr_to_string(&kif->kf_sa_local);
-+ g_strlcpy(entry.info.localsock.name,
-+ addrstr,
-+ sizeof(entry.info.localsock.name));
-+ g_free(addrstr);
-+ } else {
-+ char *addrstr;
-+
-+ addrstr = addr_to_string(&kif->kf_sa_peer);
-+ g_strlcpy(entry.info.localsock.name,
-+ addrstr,
-+ sizeof(entry.info.localsock.name));
-+ g_free(addrstr);
-+ }
-+ } else if (kif->kf_sock_domain == AF_INET ||
-+ kif->kf_sock_domain == AF_INET6) {
-+ char *addrstr;
-+
-+ entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
-+ addrstr = addr_to_string(&kif->kf_sa_peer);
-+ g_strlcpy(entry.info.sock.dest_host,
-+ addrstr,
-+ sizeof(entry.info.sock.dest_host));
-+ g_free(addrstr);
-+ entry.info.sock.dest_port = addr_to_port(&kif->kf_sa_peer);
-+ }
-+ } else if (kif->kf_type == KF_TYPE_PIPE) {
-+ entry.type = GLIBTOP_FILE_TYPE_PIPE;
-+ } else if (kif->kf_type == KF_TYPE_VNODE) {
-+ entry.type = GLIBTOP_FILE_TYPE_FILE;
-+ g_strlcpy(entry.info.file.name, kif->kf_path,
-+ sizeof(entry.info.file.name));
-+ } else
-+ continue;
-+
-+ entry.fd = kif->kf_fd;
-+
-+ g_array_append_val(entries, entry);
-+ }
-+ g_free(freep);
-+#else
-+
- output = execute_lsof(pid);
- if (output == NULL) return NULL;
-
- entries = parse_output(output);
-
- g_free(output);
-+#endif
+ if (kif->kf_fd < 0)
+ continue;
- buf->flags = _glibtop_sysdeps_proc_open_files;
- buf->number = entries->len;