summaryrefslogtreecommitdiff
path: root/sysutils/libgtop/patches/patch-sysdeps_freebsd_procwd.c
blob: f1794bd9b0875af1f58a6eb55d67ca0895dc171b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$NetBSD: patch-sysdeps_freebsd_procwd.c,v 1.1 2012/03/23 17:29:52 marino Exp $

--- sysdeps/freebsd/procwd.c.orig	2012-03-23 16:53:25.085432000 +0000
+++ sysdeps/freebsd/procwd.c
@@ -100,8 +100,6 @@ parse_output(const char *output, glibtop
 char**
 glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
 {
-	int exe_mib[4];
-	size_t len;
 #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
 	struct kinfo_file *freep, *kif;
 	GPtrArray *dirs;
@@ -116,6 +114,16 @@ glibtop_get_proc_wd_s(glibtop *server, g
 #endif
 
 	memset (buf, 0, sizeof (glibtop_proc_wd));
+#if defined(__DragonFly__)
+	char path[MAXPATHLEN];
+
+	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);
+#else
+	int exe_mib[4];
+	size_t len;
+
 	len = 0;
 
 	exe_mib[0] = CTL_KERN;
@@ -129,6 +137,7 @@ glibtop_get_proc_wd_s(glibtop *server, g
 		if (sysctl(exe_mib, 4, buf->exe, &len, NULL, 0) == 0)
 			buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
 	}
+#endif
 
 #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104)
 #ifndef HAVE_KINFO_GETFILE