summaryrefslogtreecommitdiff
path: root/sysutils/libgtop2/patches/patch-ab
blob: 8cf6050d38de35d49854cf1ce7afa19124719c17 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
$NetBSD: patch-ab,v 1.5 2006/06/26 12:14:25 drochner Exp $

--- sysdeps/freebsd/proctime.c.orig	2005-12-12 11:09:39.000000000 +0100
+++ sysdeps/freebsd/proctime.c
@@ -32,6 +32,10 @@
 #include <osreldate.h>
 #endif
 
+#ifdef __NetBSD__
+#include <sys/resourcevar.h>
+#endif
+
 static const unsigned long _glibtop_sysdeps_proc_time =
 (1L << GLIBTOP_PROC_TIME_RTIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY);
 
@@ -58,7 +62,7 @@ glibtop_init_proc_time_p (glibtop *serve
  * system, and interrupt time usage.
  */
 
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
 
 #ifndef __FreeBSD__
 static void
@@ -138,20 +142,19 @@ glibtop_get_proc_time_p (glibtop *server
 #if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
 	if (server->sysdeps.proc_time == 0)
 		return;
-
-#ifndef __bsdi__
-	sprintf (filename, "/proc/%d/mem", (int) pid);
-	if (stat (filename, &statb)) return;
-#endif
 #endif
 
 	/* Get the process information */
 	pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
-	if ((pinfo == NULL) || (count != 1))
-		glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+	if ((pinfo == NULL) || (count != 1)) {
+		glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+		return;
+	}
 
 #if defined(__FreeBSD__) && (__FreeBSD_version >= 500013)
 	buf->rtime = pinfo [0].ki_runtime;
+#elif defined(__DragonFly__)
+	buf->rtime = pinfo[0].kp_eproc.e_uticks / 100000;
 #elif (defined __FreeBSD__) && (__FreeBSD_version <= 500013)
 	buf->rtime = pinfo [0].kp_proc.p_runtime;
 #else
@@ -194,18 +197,26 @@ glibtop_get_proc_time_p (glibtop *server
        if ((pinfo [0].ki_flag & P_INMEM)) {
 #endif
            buf->utime = pinfo [0].ki_runtime;
-           buf->stime = 0; /* XXX */
+		   buf->stime = tv2sec (pinfo [0].ki_rusage.ru_stime);
            buf->cutime = tv2sec (pinfo [0].ki_childtime);
-           buf->cstime = 0; /* XXX */
+#if __FreeBSD_version >= 600000
+		   buf->cstime = tv2sec (pinfo [0].ki_rusage_ch.ru_stime);
+#else
+		   buf->cstime = 0;
+#endif
            buf->start_time = tv2sec (pinfo [0].ki_start);
            buf->flags = _glibtop_sysdeps_proc_time_user;
        }
 
 	glibtop_suid_enter (server);
 
-#elif (__FreeBSD_version <= 500013)
+#elif defined(__DragonFly__) || (defined(__FreeBSD__) || (__FreeBSD_version <= 500013))
 
+#if defined(__DragonFly__)
+        if ((pinfo [0].kp_proc.p_flag & P_SWAPPEDOUT) == 0 &&
+#else
         if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+#endif
             kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
                        (unsigned long) &u_addr->u_stats,
                        (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
@@ -215,13 +226,21 @@ glibtop_get_proc_time_p (glibtop *server
                        buf->stime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_stime);
                        buf->cutime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_utime);
                        buf->cstime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_stime);
+#if defined(__DragonFly__)
+                       buf->start_time = tv2sec (pinfo[0].kp_thread.td_start);
+#else
                        buf->start_time = tv2sec (pinfo[0].kp_eproc.e_stats.p_start);
+#endif
                        buf->flags = _glibtop_sysdeps_proc_time_user;
                        glibtop_suid_leave (server);
 		}
 #else
 
+#if defined(__DragonFly__)
+        if ((pinfo [0].kp_proc.p_flag & P_SWAPPEDOUT) == 0 &&
+#else
 	if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+#endif
 	    kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
 		       (unsigned long) &u_addr->u_stats,
 		       (char *) &pstats, sizeof (pstats)) == sizeof (pstats))