summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2007-06-28 02:07:04 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2007-06-28 02:07:04 +0800
commit23a562db77e7431c5b33cfda38ce3fc698d24a57 (patch)
treeff43b34845a469d09446be3b7ab23ce5d377b3ec
parent165d03e534de97d12ed074932c05bd700d454a08 (diff)
downloadmarcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar.gz
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar.bz2
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar.lz
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar.xz
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.tar.zst
marcuscom-ports-23a562db77e7431c5b33cfda38ce3fc698d24a57.zip
Update to 2.19.4, and add an lsof wrapper so that we can provide the list
of open files and the process's working directory. git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@9083 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r--devel/libgtop/Makefile5
-rw-r--r--devel/libgtop/distinfo6
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in30
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.c57
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.h43
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c161
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_procwd.c95
7 files changed, 367 insertions, 30 deletions
diff --git a/devel/libgtop/Makefile b/devel/libgtop/Makefile
index cdc1eda59..b4d50860b 100644
--- a/devel/libgtop/Makefile
+++ b/devel/libgtop/Makefile
@@ -3,11 +3,11 @@
# Whom: Joe Marcus Clarke <marcus@FreeBSD.org>
#
# $FreeBSD$
-# $MCom: ports/devel/libgtop/Makefile,v 1.5 2006/10/02 23:26:51 ahze Exp $
+# $MCom: ports/devel/libgtop/Makefile,v 1.16 2007/06/09 00:04:02 marcus Exp $
#
PORTNAME= libgtop
-PORTVERSION= 2.19.3
+PORTVERSION= 2.19.4
CATEGORIES= devel gnome
MASTER_SITES= ${MASTER_SITE_GNOME}
MASTER_SITE_SUBDIR= sources/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}
@@ -17,6 +17,7 @@ MAINTAINER= gnome@FreeBSD.org
COMMENT= GNOME 2 top library
LIB_DEPENDS= popt.0:${PORTSDIR}/devel/popt
+RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof
USE_BZIP2= yes
USE_PERL5_BUILD=yes
diff --git a/devel/libgtop/distinfo b/devel/libgtop/distinfo
index 996eef81f..1e80151e7 100644
--- a/devel/libgtop/distinfo
+++ b/devel/libgtop/distinfo
@@ -1,3 +1,3 @@
-MD5 (gnome2/libgtop-2.19.3.tar.bz2) = 1f10944bcae67d9ae8888041ec2ae0e2
-SHA256 (gnome2/libgtop-2.19.3.tar.bz2) = 5bd6a42a81f4d2630a6d044e4b6428cab75c2d807f9c3dfa40b0c9bb814b80a8
-SIZE (gnome2/libgtop-2.19.3.tar.bz2) = 761240
+MD5 (gnome2/libgtop-2.19.4.tar.bz2) = 1cea9b7a17e90187dad9f6ed46173c85
+SHA256 (gnome2/libgtop-2.19.4.tar.bz2) = 71cb75d66c360f4ad480474fd515850ed3f38aa6fda5556341db2e0164d4b869
+SIZE (gnome2/libgtop-2.19.4.tar.bz2) = 761096
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in
index f5fe43c48..e5bba3d58 100644
--- a/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in
@@ -1,25 +1,33 @@
---- sysdeps/freebsd/Makefile.in.orig Fri Jun 8 19:56:49 2007
-+++ sysdeps/freebsd/Makefile.in Fri Jun 8 19:57:08 2007
-@@ -61,7 +61,7 @@ libgtop_sysdeps_suid_2_0_la_DEPENDENCIES
+--- sysdeps/freebsd/Makefile.in.orig 2007-06-26 00:49:06.000000000 -0400
++++ sysdeps/freebsd/Makefile.in 2007-06-26 17:59:28.000000000 -0400
+@@ -61,7 +61,8 @@ libgtop_sysdeps_suid_2_0_la_DEPENDENCIES
am_libgtop_sysdeps_suid_2_0_la_OBJECTS = open.lo close.lo swap.lo \
proclist.lo procstate.lo procuid.lo proctime.lo procmem.lo \
procsignal.lo prockernel.lo procsegment.lo procargs.lo \
- procmap.lo netload.lo ppp.lo procopenfiles.lo
-+ procmap.lo netload.lo ppp.lo procopenfiles.lo procwd.lo
++ procmap.lo netload.lo ppp.lo procopenfiles.lo procwd.lo \
++ glibtop_private.lo
libgtop_sysdeps_suid_2_0_la_OBJECTS = \
$(am_libgtop_sysdeps_suid_2_0_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
-@@ -305,7 +305,8 @@ libgtop_sysdeps_suid_2_0_la_SOURCES = op
+@@ -305,13 +306,15 @@ libgtop_sysdeps_suid_2_0_la_SOURCES = op
proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c \
prockernel.c procsegment.c procargs.c \
- procmap.c netload.c ppp.c procopenfiles.c
+ procmap.c netload.c ppp.c procopenfiles.c \
-+ procwd.c
++ procwd.c glibtop_private.c
libgtop_sysdeps_suid_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h \
-@@ -382,6 +383,7 @@ distclean-compile:
+ glibtop_suid.h
+
+ libgtopincludedir = $(includedir)/libgtop-2.0
++noinst_HEADERS = glibtop_private.h
+ all: all-am
+
+ .SUFFIXES:
+@@ -382,6 +385,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procmap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procmem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procopenfiles.Plo@am__quote@
@@ -27,3 +35,11 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procsegment.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procsignal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procstate.Plo@am__quote@
+@@ -393,6 +397,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swap.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysinfo.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uptime.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glibtop_private.Plo@am__quote@
+
+ .c.o:
+ @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.c b/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.c
new file mode 100644
index 000000000..2487d0208
--- /dev/null
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.c
@@ -0,0 +1,57 @@
+--- sysdeps/freebsd/glibtop_private.c.orig 2007-06-26 18:07:59.000000000 -0400
++++ sysdeps/freebsd/glibtop_private.c 2007-06-27 00:07:50.000000000 -0400
+@@ -0,0 +1,54 @@
++#include <config.h>
++#include <glibtop.h>
++#include <glibtop/error.h>
++
++#include "glibtop_private.h"
++
++#include <sys/types.h>
++#include <unistd.h>
++#include <string.h>
++#include <glib.h>
++#include <errno.h>
++
++char *
++execute_lsof(pid_t pid) {
++ char *output = NULL;
++ char *lsof;
++ char *command;
++ int exit_status;
++
++ lsof = g_find_program_in_path("lsof");
++ if (lsof == NULL)
++ return NULL;
++
++ command = g_strdup_printf("%s -n -P -Fftn -p %d", lsof, pid);
++ g_free(lsof);
++
++ if (g_spawn_command_line_sync (command, &output, NULL, &exit_status, NULL)) {
++ if (exit_status != 0) {
++ g_warning("Could not execute \"%s\" (%i)", command,
++ exit_status);
++ output = NULL;
++ }
++ }
++
++ g_free(command);
++ return output;
++}
++
++/* Ported from linux/glibtop_private.c */
++gboolean
++safe_readlink(const char *path, char *buf, int bufsiz)
++{
++ int ret;
++
++ ret = readlink(path, buf, bufsiz - 1);
++
++ if (ret == -1) {
++ g_warning("Could not read link %s : %s", path, strerror(errno));
++ return FALSE;
++ }
++
++ buf[ret] = '\0';
++ return TRUE;
++}
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.h b/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.h
new file mode 100644
index 000000000..d59068b8a
--- /dev/null
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_private.h
@@ -0,0 +1,43 @@
+--- sysdeps/freebsd/glibtop_private.h.orig 2007-06-27 14:01:07.000000000 -0400
++++ sysdeps/freebsd/glibtop_private.h 2007-06-27 14:02:44.000000000 -0400
+@@ -0,0 +1,40 @@
++/* Copyright (C) 2007 Joe Marcus Clarke
++ This file is part of LibGTop 2.0.
++
++ LibGTop is free software; you can redistribute it and/or modify it
++ under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License,
++ or (at your option) any later version.
++
++ LibGTop is distributed in the hope that it will be useful, but WITHOUT
++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with LibGTop; see the file COPYING. If not, write to the
++ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA.
++*/
++
++#ifndef __FREEBSD__GLIBTOP_PRIVATE_H__
++#define __FREEBSD__GLIBTOP_PRIVATE_H__
++
++#include <glibtop.h>
++#include <glibtop/error.h>
++
++#include <glib.h>
++
++#include <sys/types.h>
++#include <unistd.h>
++#include <string.h>
++#include <errno.h>
++
++G_BEGIN_DECLS
++
++char *execute_lsof(pid_t pid);
++gboolean safe_readlink(const char *path, char *buf, int bufsiz);
++
++G_END_DECLS
++
++#endif /* __FREEBSD__GLIBTOP_PRIVATE_H__ */
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c b/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
index bd14241d5..2cac4ca80 100644
--- a/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c
@@ -1,23 +1,158 @@
---- sysdeps/freebsd/procopenfiles.c.orig Fri Jun 8 19:58:17 2007
-+++ sysdeps/freebsd/procopenfiles.c Fri Jun 8 19:59:15 2007
-@@ -27,12 +27,7 @@
+--- sysdeps/freebsd/procopenfiles.c.orig 2007-05-13 06:02:49.000000000 -0400
++++ sysdeps/freebsd/procopenfiles.c 2007-06-26 18:04:13.000000000 -0400
+@@ -1,5 +1,6 @@
+ /* Copyright (C) 1998-99 Martin Baulig
+ Copyright (C) 2004 Nicolás Lichtmaier
++ Copyright (C) 2007 Joe Marcus Clarke
+ This file is part of LibGTop 1.0.
+
+ Modified by Nicolás Lichtmaier to give a process open files.
+@@ -26,8 +27,11 @@
+ #include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/procopenfiles.h>
++#include <sys/types.h>
++#include <string.h>
++#include <stdlib.h>
-#include <glibtop_suid.h>
--
--static const unsigned long _glibtop_sysdeps_proc_open_files =
--(1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)|
--(1L << GLIBTOP_PROC_OPEN_FILES_TOTAL)|
--(1L << GLIBTOP_PROC_OPEN_FILES_SIZE);
-+static const unsigned long _glibtop_sysdeps_proc_open_files = 0;
++#include "glibtop_private.h"
+
+ static const unsigned long _glibtop_sysdeps_proc_open_files =
+ (1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)|
+@@ -42,10 +46,133 @@ _glibtop_init_proc_open_files_s (glibtop
+ server->sysdeps.proc_open_files = _glibtop_sysdeps_proc_open_files;
+ }
- /* Init function. */
++static GArray *
++parse_output(const char *output) {
++ GArray *entries;
++ char **lines;
++ char *ftype = NULL;
++ char *fname = NULL;
++ guint i;
++ guint len;
++ int fd = -1;
++
++ entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
++
++ lines = g_strsplit(output, "\n", 0);
++ len = g_strv_length(lines);
++
++ for (i = 0; i < len && lines[i]; i++) {
++ glibtop_open_files_entry entry = {0};
++
++ if (strlen(lines[i]) < 2)
++ continue;
++
++ if (!g_str_has_prefix(lines[i], "f") &&
++ !g_str_has_prefix(lines[i], "t") &&
++ !g_str_has_prefix(lines[i], "n"))
++ continue;
++
++ if (g_str_has_prefix(lines[i], "f")) {
++ if (!g_ascii_isdigit(*(lines[i] + 1)))
++ i += 2;
++ else
++ fd = atoi(lines[i] + 1);
++ continue;
++ }
++
++ if (g_str_has_prefix(lines[i], "t")) {
++ ftype = lines[i];
++ ftype++;
++ continue;
++ } else {
++ fname = lines[i];
++ fname++;
++ }
++
++ if (ftype == NULL || fname == NULL)
++ continue;
++
++ if (!strcmp(ftype, "unix")) {
++ entry.type = GLIBTOP_FILE_TYPE_LOCALSOCKET;
++ g_strlcpy(entry.info.localsock.name, fname,
++ sizeof(entry.info.localsock.name));
++ } else if (!strcmp(ftype, "PIPE")) {
++ entry.type = GLIBTOP_FILE_TYPE_PIPE;
++ } else if (!strcmp(ftype, "VREG") ||
++ !strcmp(ftype, "GDIR") ||
++ !strcmp(ftype, "GREG") ||
++ !strcmp(ftype, "VDIR")) {
++ entry.type = GLIBTOP_FILE_TYPE_FILE;
++ g_strlcpy(entry.info.file.name, fname,
++ sizeof(entry.info.file.name));
++ } else if (!strcmp(ftype, "IPv4")) {
++ char **hosts;
++ char **remote_host;
++
++ if (!strstr(fname, "->")) {
++ remote_host = g_strsplit(fname, ":", 0);
++ } else {
++ hosts = g_strsplit(fname, "->", 0);
++ if (g_strv_length(hosts) < 2) {
++ g_strfreev(hosts);
++ continue;
++ }
++
++ remote_host = g_strsplit(hosts[1], ":", 0);
++ g_strfreev(hosts);
++ }
++
++ if (g_strv_length(remote_host) < 2) {
++ g_strfreev(remote_host);
++ continue;
++ }
++
++ entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
++ if (!strcmp(remote_host[0], "*"))
++ g_strlcpy(entry.info.sock.dest_host, "0.0.0.0",
++ sizeof(entry.info.sock.dest_host));
++ else
++ g_strlcpy(entry.info.sock.dest_host,
++ remote_host[0],
++ sizeof(entry.info.sock.dest_host));
++ entry.info.sock.dest_port = atoi(remote_host[1]);
++
++ g_strfreev(remote_host);
++ }
++
++ entry.fd = fd;
++
++ fd = -1;
++ ftype = NULL;
++ fname = NULL;
++
++ g_array_append_val(entries, entry);
++ }
++
++ g_strfreev(lines);
++
++ return entries;
++}
-@@ -47,5 +42,6 @@ _glibtop_init_proc_open_files_s (glibtop
+-/* XXX Unimplemented on FreeBSD */
glibtop_open_files_entry *
glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid)
{
-+ memset(buf, 0, sizeof(glibtop_proc_open_files));
- return NULL;
+- return NULL;
++ char *output;
++ GArray *entries;
++
++ memset(buf, 0, sizeof (glibtop_proc_open_files));
++
++ output = execute_lsof(pid);
++ if (output == NULL) return NULL;
++
++ entries = parse_output(output);
++
++ g_free(output);
++
++ buf->flags = _glibtop_sysdeps_proc_open_files;
++ buf->number = entries->len;
++ buf->size = sizeof(glibtop_open_files_entry);
++ buf->total = buf->number * buf->size;
++
++ return (glibtop_open_files_entry*)g_array_free(entries, FALSE);
}
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c b/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c
index 0e03ce2f6..4b97a149e 100644
--- a/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c
@@ -1,7 +1,7 @@
---- sysdeps/freebsd/procwd.c.orig Fri Jun 8 19:55:15 2007
-+++ sysdeps/freebsd/procwd.c Fri Jun 8 19:59:35 2007
-@@ -0,0 +1,37 @@
-+/* Copyright (C) 2007 Benoît Dejean
+--- sysdeps/freebsd/procwd.c.orig 2007-06-26 00:49:06.000000000 -0400
++++ sysdeps/freebsd/procwd.c 2007-06-27 13:57:10.000000000 -0400
+@@ -0,0 +1,122 @@
++/* Copyright (C) 2007 Joe Marcus Clarke
+ This file is part of LibGTop 2.
+
+ LibGTop is free software; you can redistribute it and/or modify it
@@ -24,7 +24,16 @@
+#include <glibtop/procwd.h>
+#include <glibtop/error.h>
+
-+static const unsigned long _glibtop_sysdeps_proc_wd = 0;
++#include <glibtop_private.h>
++
++#include <sys/types.h>
++#include <sys/param.h>
++#include <string.h>
++
++static const unsigned long _glibtop_sysdeps_proc_wd =
++(1 << GLIBTOP_PROC_WD_EXE) |
++(1 << GLIBTOP_PROC_WD_ROOT) |
++(1 << GLIBTOP_PROC_WD_NUMBER);
+
+void
+_glibtop_init_proc_wd_s(glibtop *server)
@@ -32,9 +41,85 @@
+ server->sysdeps.proc_wd = _glibtop_sysdeps_proc_wd;
+}
+
++static GPtrArray *
++parse_output(const char *output, glibtop_proc_wd *buf)
++{
++ GPtrArray *dirs;
++ char **lines;
++ gboolean nextwd = FALSE;
++ gboolean nextrtd = FALSE;
++ gboolean havertd = FALSE;
++ guint i;
++ guint len;
++
++ dirs = g_ptr_array_sized_new(1);
++
++ lines = g_strsplit(output, "\n", 0);
++ len = g_strv_length(lines);
++
++ for (i = 0; i < len && lines[i]; i++) {
++
++ if (strlen(lines[i]) < 2)
++ continue;
++
++ if (!g_str_has_prefix(lines[i], "f") &&
++ !g_str_has_prefix(lines[i], "n"))
++ continue;
++
++ if (!strcmp(lines[i], "fcwd")) {
++ nextwd = TRUE;
++ continue;
++ }
++
++ if (!strcmp(lines[i], "frtd")) {
++ nextrtd = TRUE;
++ continue;
++ }
++
++ if (nextwd) {
++ g_ptr_array_add(dirs, g_strdup(lines[i] + 1));
++ nextwd = FALSE;
++ }
++
++ if (nextrtd && !havertd) {
++ g_strlcpy(buf->root, lines[i] + 1,
++ sizeof(buf->root));
++ buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
++ nextrtd = FALSE;
++ havertd = TRUE;
++ }
++ }
++
++ g_strfreev(lines);
++
++ return dirs;
++}
++
+char**
+glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
+{
++ char path[MAXPATHLEN];
++ char *output;
++
+ memset (buf, 0, sizeof (glibtop_proc_wd));
++
++ g_snprintf(path, sizeof(path), "/proc/%u/file", pid);
++ if (safe_readlink(path, buf->exe, sizeof(buf->exe)))
++ buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
++
++ output = execute_lsof(pid);
++ if (output != NULL) {
++ GPtrArray *dirs;
++
++ dirs = parse_output(output, buf);
++
++ buf->number = dirs->len;
++ buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
++
++ g_ptr_array_add(dirs, NULL);
++
++ return (char **)g_ptr_array_free(dirs, FALSE);
++ }
++
+ return NULL;
+}