freebsd-ports/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c
Koop Mast 48e62d9a37 Presenting GNOME 2.30.1 for FreeBSD. The offical release notes for this
release can be found at http://library.gnome.org/misc/release-notes/2.30/ .

This release brings initial PackageKit support, Upower (replaces power
management part of hal), cuse4bsd integration with HAL and cheese, and a
faster Evolution.

Sadly GNOME 2.30.x will be the last release with FreeBSD 6.X support. This
will also be the last of the 2.x releases. The next release will be the
highly-anticipated GNOME 3.0 which will bring with it a new UI experience.

Currently, there are a few bugs with GNOME 2.30 that may be of note for our
users. Be sure to consult the UPGRADING note or the 2.30 upgrade FAQ at
http://www.freebsd.org/gnome/docs/faq230.html for specific upgrading
instructions, and the up-to-date list of known issues.

This release features commits by avl, ahze, bland, marcus, mezz, and myself.

The FreeBSD GNOME Team would like to thank Anders F Bjorklund for doing the
initual packagekit porting.

And the following contributors & testers for there help with this release:
Eric L. Chen
Vladimir Grebenschikov
Sergio de Almeida Lenzi
DomiX
walder
crsd
Kevin Oberman
Michal Varga
Pavel Plesov
Bapt
kevin

and ITetcu for two exp-run

PR:	ports/143852
	ports/145347
	ports/144980
	ports/145830
	ports/145511
2010-05-10 21:19:08 +00:00

89 lines
2.4 KiB
C

--- sysdeps/freebsd/procwd.c.orig 2009-04-19 19:51:00.000000000 +0200
+++ sysdeps/freebsd/procwd.c 2010-05-07 13:17:54.000000000 +0200
@@ -27,6 +27,9 @@
#include <sys/sysctl.h>
#include <sys/param.h>
#include <sys/user.h>
+#ifdef HAVE_KINFO_GETFILE
+#include <libutil.h>
+#endif
#include <string.h>
static const unsigned long _glibtop_sysdeps_proc_wd =
@@ -40,7 +43,7 @@ _glibtop_init_proc_wd_s(glibtop *server)
server->sysdeps.proc_wd = _glibtop_sysdeps_proc_wd;
}
-#if (__FreeBSD_version >= 800000 && __FreeBSD_version < 800019) || _FreeBSD_version < 700104
+#if (__FreeBSD_version >= 800000 && __FreeBSD_version < 800019) || __FreeBSD_version < 700104
static GPtrArray *
parse_output(const char *output, glibtop_proc_wd *buf)
{
@@ -97,24 +100,39 @@ parse_output(const char *output, glibtop
char**
glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
{
- char path[MAXPATHLEN];
+ int exe_mib[4];
+ size_t len;
#if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
struct kinfo_file *freep, *kif;
GPtrArray *dirs;
- size_t len;
- int i;
+#ifndef HAVE_KINFO_GETFILE
int name[4];
#else
+ int cnt;
+#endif
+ int i;
+#else
char *output;
#endif
memset (buf, 0, sizeof (glibtop_proc_wd));
+ len = 0;
- 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);
+ exe_mib[0] = CTL_KERN;
+ exe_mib[1] = KERN_PROC;
+ exe_mib[2] = KERN_PROC_PATHNAME;
+ exe_mib[3] = pid;
+
+ if (sysctl(exe_mib, 4, NULL, &len, NULL, 0) == 0) {
+ if (len > sizeof(buf->exe))
+ len = sizeof(buf->exe);
+ if (sysctl(exe_mib, 4, buf->exe, &len, NULL, 0) == 0)
+ buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
+ }
#if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
+#ifndef HAVE_KINFO_GETFILE
+ len = 0;
name[0] = CTL_KERN;
name[1] = KERN_PROC;
name[2] = KERN_PROC_FILEDESC;
@@ -127,10 +145,21 @@ glibtop_get_proc_wd_s(glibtop *server, g
g_free(freep);
return NULL;
}
+#else
+ freep = kinfo_getfile(pid, &cnt);
+#endif
dirs = g_ptr_array_sized_new(1);
+#ifndef HAVE_KINFO_GETFILE
for (i = 0; i < len / sizeof(*kif); i++, kif++) {
+ if (kif->kf_structsize != sizeof(*kif))
+ continue;
+#else
+ for (i = 0; i < cnt; i++) {
+ kif = &freep[i];
+#endif
+
switch (kif->kf_fd) {
case KF_FD_TYPE_ROOT:
g_strlcpy(buf->root, kif->kf_path,