openbsd-ports/x11/gnome/tracker/patches/patch-src_libtracker-common_tracker-dbus_c
2011-10-16 08:54:53 +00:00

57 lines
1.2 KiB
Plaintext

$OpenBSD: patch-src_libtracker-common_tracker-dbus_c,v 1.5 2011/10/16 08:54:53 ajacoutot Exp $
--- src/libtracker-common/tracker-dbus.c.orig Sun Oct 16 09:32:47 2011
+++ src/libtracker-common/tracker-dbus.c Sun Oct 16 09:36:54 2011
@@ -23,6 +23,14 @@
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdio.h>
+#include <kvm.h>
+#endif
+
#include "tracker-dbus.h"
#include "tracker-log.h"
@@ -139,6 +147,7 @@ client_data_new (gchar *sender)
}
if (get_binary) {
+#ifndef __OpenBSD__
gchar *filename;
gchar *pid_str;
gchar *contents = NULL;
@@ -171,6 +180,29 @@ client_data_new (gchar *sender)
g_strfreev (strv);
g_free (contents);
+#else
+ int nproc;
+ struct kinfo_proc *kp;
+ kvm_t *kd;
+ char **pargv;
+
+ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL)) == NULL)
+ return cd;
+
+ if ((kp = kvm_getprocs(kd, KERN_PROC_PID, cd->pid, sizeof(*kp), &nproc)) == NULL)
+ goto out;
+
+ if ((kp->p_flag & P_SYSTEM) != 0)
+ goto out;
+
+ if ((pargv = kvm_getargv(kd, kp, 0)) == NULL)
+ goto out;
+
+ cd->binary = g_path_get_basename(pargv[0]);
+
+out:
+ kvm_close(kd);
+#endif
}
return cd;