summaryrefslogtreecommitdiff
path: root/sysutils/libgtop/patches/patch-ao
blob: 8f75d1e6e87475d7734c624bbfd4f990b9b7952c (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
$NetBSD: patch-ao,v 1.4 2007/11/05 19:06:05 drochner Exp $

--- sysdeps/bsd/procuid.c.orig	2007-04-27 00:27:34.000000000 +0200
+++ sysdeps/bsd/procuid.c
@@ -28,6 +28,7 @@
 
 static const unsigned long _glibtop_sysdeps_proc_uid =
 (1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) +
+(1L << GLIBTOP_PROC_UID_GID) +
 (1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_PID) +
 (1L << GLIBTOP_PROC_UID_PPID) + (1L << GLIBTOP_PROC_UID_PGRP) +
 (1L << GLIBTOP_PROC_UID_TPGID) + (1L << GLIBTOP_PROC_UID_PRIORITY) +
@@ -51,15 +52,21 @@ void
 glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
 			pid_t pid)
 {
+#if defined (__NetBSD__)
+	struct kinfo_proc2 *pinfo;
+#else
 	struct kinfo_proc *pinfo;
+#endif
 	int count = 0;
 
+#if 0
 #if LIBGTOP_VERSION_CODE >= 1001000
 #if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
 	struct ucred ucred;
 	void *ucred_ptr;
 #endif
 #endif
+#endif /* 0 */
 
 	glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
 
@@ -69,7 +76,12 @@ glibtop_get_proc_uid_p (glibtop *server,
 	if (pid == 0) return;
 
 	/* Get the process information */
+#if defined (__NetBSD__)
+	pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+			      sizeof (*pinfo), &count);
+#else
 	pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
+#endif
 	if ((pinfo == NULL) || (count != 1)) {
 		glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
 		return;
@@ -86,6 +98,20 @@ glibtop_get_proc_uid_p (glibtop *server,
 #define	PROC_TPGID	ki_tpgid
 #define	PROC_NICE	ki_nice
 #define	PROC_PRIORITY	ki_pri.pri_user
+
+#elif defined (__NetBSD__)
+
+#define PROC_RUID	p_ruid
+#define PROC_SVUID	p_svuid
+#define PROC_RGID	p_rgid
+#define PROC_SVGID	p_svgid
+#define PROC_PID	p_pid
+#define PROC_PPID	p_ppid
+#define PROC_PGID	p__pgid
+#define PROC_TPGID	p_tpgid
+#define PROC_NICE	p_nice
+#define PROC_PRIORITY	p_priority
+
 #else
 
 #define	PROC_RUID	kp_eproc.e_pcred.p_ruid
@@ -105,6 +131,7 @@ glibtop_get_proc_uid_p (glibtop *server,
 	buf->gid  = pinfo [0].PROC_RGID;
 	buf->egid = pinfo [0].PROC_SVGID;
 
+	buf->pid   = pinfo [0].PROC_PID;
 	buf->ppid  = pinfo [0].PROC_PPID;
 	buf->pgrp  = pinfo [0].PROC_PGID;
 	buf->tpgid = pinfo [0].PROC_TPGID;