summaryrefslogtreecommitdiffstats
path: root/devel/libgtop2/files/patch-aj
blob: 101a29532b41a57edcc07a4cdbf89d85a9b8d44b (plain) (blame)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
--- sysdeps/freebsd/proclist.c.orig Thu May 27 09:04:05 1999
+++ sysdeps/freebsd/proclist.c  Fri Dec 22 18:02:59 2000
@@ -88,9 +88,20 @@
    for (i=j=0; i < count; i++) {
+#if __FreeBSD_version >= 500013
+#define XXX_P_STAT ki_stat
+#define XXX_P_RUID ki_ruid
+#define XXX_P_PID  ki_pid
+
+#else
+#define XXX_P_STAT kp_proc.p_stat
+#define XXX_P_RUID kp_eproc.e_pcred.p_ruid
+#define XXX_P_PID  kp_proc.p_pid
+
+#endif
        if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
-           (pinfo[i].kp_proc.p_stat != SRUN))
+           (pinfo[i].XXX_P_STAT != SRUN))
            continue;
        else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) &&
-            (pinfo[i].kp_eproc.e_pcred.p_ruid == 0))
+            (pinfo[i].XXX_P_RUID == 0))
            continue;
-       pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid;
+       pids [j++] = (unsigned) pinfo[i].XXX_P_PID;
    } /* end for */
--- sysdeps/freebsd/procstate.c.orig    Sun Feb 10 09:30:11 2002
+++ sysdeps/freebsd/procstate.c Mon Apr 29 11:42:22 2002
@@ -28,7 +28,7 @@
 #include <glibtop_suid.h>
 
 #if !defined(__OpenBSD__) 
-//&& (!defined __bsdi__)
+/*&& (!defined __bsdi__)*/
 #include <sys/user.h>
 #endif
 
@@ -37,11 +37,7 @@
 (1L << GLIBTOP_PROC_STATE_GID);
 
 static const unsigned long _glibtop_sysdeps_proc_state_new =
-#if LIBGTOP_VERSION_CODE >= 1001000
-(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID);
-#else
 0;
-#endif
 
 /* Init function. */
 
@@ -76,43 +72,35 @@
        return;
    }
 
-   strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1);
-   buf->cmd [sizeof (buf->cmd)-1] = 0;
+#if __FreeBSD_version >= 500013
+#define    XXX_P_COMM  ki_comm
+#define    XXX_P_SVUID ki_svuid
+#define    XXX_P_SVGID ki_svgid
+#define    XXX_P_RUID  ki_ruid
+#define    XXX_P_RGID  ki_rgid
+#define XXX_P_STAT ki_stat
 
-   buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
-   buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
+#else
+#define    XXX_P_COMM  kp_proc.p_comm
+#define    XXX_P_SVUID kp_eproc.e_pcred.p_svuid
+#define    XXX_P_SVGID kp_eproc.e_pcred.p_svgid
+#define    XXX_P_RUID  kp_eproc.e_pcred.p_ruid
+#define    XXX_P_RGID  kp_eproc.e_pcred.p_rgid
+#define    XXX_P_STAT  kp_proc.p_stat
 
-#if LIBGTOP_VERSION_CODE >= 1001000
-   buf->ruid = pinfo [0].kp_eproc.e_pcred.p_ruid;
-   buf->rgid = pinfo [0].kp_eproc.e_pcred.p_rgid;
 #endif
 
+   strncpy (buf->cmd, pinfo [0].XXX_P_COMM, sizeof (buf->cmd)-1);
+   buf->cmd [sizeof (buf->cmd)-1] = 0;
+
+   buf->uid = pinfo [0].XXX_P_SVUID;
+   buf->gid = pinfo [0].XXX_P_SVGID;
+
    /* Set the flags for the data we're about to return*/
    buf->flags = _glibtop_sysdeps_proc_state |
        _glibtop_sysdeps_proc_state_new;
 
-#if LIBGTOP_VERSION_CODE >= 1001000
-   switch (pinfo [0].kp_proc.p_stat) {
-   case SIDL:
-       buf->state = 0;
-       break;
-   case SRUN:
-       buf->state = GLIBTOP_PROCESS_RUNNING;
-       break;
-   case SSLEEP:
-       buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
-       break;
-   case SSTOP:
-       buf->state = GLIBTOP_PROCESS_STOPPED;
-       break;
-   case SZOMB:
-       buf->state = GLIBTOP_PROCESS_ZOMBIE;
-       break;
-   default:
-       return;
-   }
-#else
-   switch (pinfo [0].kp_proc.p_stat) {
+   switch (pinfo [0].XXX_P_STAT) {
    case SIDL:
        buf->state = 'S';
        break;
@@ -131,7 +119,6 @@
    default:
        return;
    }
-#endif
 
    buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
 }
--- sysdeps/freebsd/procuid.c.orig  Fri Sep 17 06:08:07 1999
+++ sysdeps/freebsd/procuid.c   Thu Feb 15 01:16:50 2001
@@ -86,13 +86,42 @@
 
-   buf->uid  = pinfo [0].kp_eproc.e_pcred.p_ruid;
-   buf->euid = pinfo [0].kp_eproc.e_pcred.p_svuid;
-   buf->gid  = pinfo [0].kp_eproc.e_pcred.p_rgid;
-   buf->egid = pinfo [0].kp_eproc.e_pcred.p_svgid;
-
-   buf->ppid  = pinfo [0].kp_eproc.e_ppid;
-   buf->pgrp  = pinfo [0].kp_eproc.e_pgid;
-   buf->tpgid = pinfo [0].kp_eproc.e_tpgid;
+#if __FreeBSD_version >= 500013
 
-   buf->nice     = pinfo [0].kp_proc.p_nice;
-   buf->priority = pinfo [0].kp_proc.p_priority;
+#define    XXX_P_RUID  ki_ruid
+#define    XXX_P_SVUID ki_svuid
+#define    XXX_P_RGID  ki_rgid
+#define    XXX_P_SVGID ki_svgid
+#define    XXX_E_PPID  ki_ppid
+#define    XXX_E_PGID  ki_pgid
+#define    XXX_E_TPGID ki_tpgid
+#define    XXX_P_NICE  ki_nice
+#if __FreeBSD_version >= 500013
+#define    XXX_P_PRIORITY  ki_pri.pri_user
+#else
+#define    XXX_P_PRIORITY  ki_priority
+#endif
+#else
+
+#define    XXX_P_RUID  kp_eproc.e_pcred.p_ruid
+#define    XXX_P_SVUID kp_eproc.e_pcred.p_svuid
+#define    XXX_P_RGID  kp_eproc.e_pcred.p_rgid
+#define    XXX_P_SVGID kp_eproc.e_pcred.p_svgid
+#define    XXX_E_PPID  kp_eproc.e_ppid
+#define    XXX_E_PGID  kp_eproc.e_pgid
+#define    XXX_E_TPGID kp_eproc.e_tpgid
+#define    XXX_P_NICE  kp_proc.p_nice
+#define    XXX_P_PRIORITY  kp_proc.p_priority
+
+#endif
+
+   buf->uid  = pinfo [0].XXX_P_RUID;
+   buf->euid = pinfo [0].XXX_P_SVUID;
+   buf->gid  = pinfo [0].XXX_P_RGID;
+   buf->egid = pinfo [0].XXX_P_SVGID;
+
+   buf->ppid  = pinfo [0].XXX_E_PPID;
+   buf->pgrp  = pinfo [0].XXX_E_PGID;
+   buf->tpgid = pinfo [0].XXX_E_TPGID;
+
+   buf->nice     = pinfo [0].XXX_P_NICE;
+   buf->priority = pinfo [0].XXX_P_PRIORITY;
 
--- sysdeps/freebsd/procmem.c.orig  Thu May 27 13:56:49 1999
+++ sysdeps/freebsd/procmem.c   Wed Dec 27 10:16:26 2000
@@ -139,2 +139,18 @@
 
+#if __FreeBSD_version >= 500013
+
+#define    XXX_P_VMSPACE   ki_vmspace
+
+   buf->rss_rlim = pinfo [0].ki_rssize;
+
+   buf->vsize = buf->size = (u_int64_t) pagetok
+       (pinfo [0].ki_tsize + pinfo [0].ki_dsize + pinfo[0].ki_ssize)
+           << LOG1024;
+   buf->resident = buf->rss = (u_int64_t) pagetok
+       (pinfo [0].ki_rssize) << LOG1024;
+
+#else
+
+#define    XXX_P_VMSPACE   kp_proc.p_vmspace
+
    if (kvm_read (server->machine.kd,
@@ -156,2 +172,3 @@
        (vms->vm_rssize) << LOG1024;
+#endif
 
@@ -160,3 +177,3 @@
    if (kvm_read (server->machine.kd,
-             (unsigned long) pinfo [0].kp_proc.p_vmspace,
+             (unsigned long) pinfo [0].XXX_P_VMSPACE,
              (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
--- sysdeps/freebsd/procsignal.c.orig   Sun Feb 13 15:31:39 2000
+++ sysdeps/freebsd/procsignal.c    Wed Dec 27 10:22:28 2000
@@ -69,2 +69,18 @@
 
+#if __FreeBSD_version >= 500013
+
+#define    XXX_P_SIGLIST   ki_siglist
+#define    XXX_P_SIGMASK   ki_sigmask
+#define    XXX_P_SIGIGNORE ki_sigignore
+#define    XXX_P_SIGCATCH  ki_sigcatch
+
+#else
+
+#define    XXX_P_SIGLIST   kp_proc.p_siglist
+#define    XXX_P_SIGMASK   kp_proc.p_sigmask
+#define    XXX_P_SIGIGNORE kp_proc.p_sigignore
+#define    XXX_P_SIGCATCH  kp_proc.p_sigcatch
+
+#endif
+
    /* signal: mask of pending signals.
@@ -73,3 +89,3 @@
 #if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
-   buf->signal [0] = pinfo [0].kp_proc.p_siglist.__bits[0];
+   buf->signal [0] = pinfo [0].XXX_P_SIGLIST.__bits[0];
 #else
@@ -82,3 +98,3 @@
 #if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
-   buf->blocked [0] = pinfo [0].kp_proc.p_sigmask.__bits[0];
+   buf->blocked [0] = pinfo [0].XXX_P_SIGMASK.__bits[0];
 #else
@@ -91,3 +107,3 @@
 #if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
-   buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore.__bits[0];
+   buf->sigignore [0] = pinfo [0].XXX_P_SIGIGNORE.__bits[0];
 #else
@@ -100,3 +116,3 @@
 #if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
-   buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch.__bits[0];
+   buf->sigcatch [0] = pinfo [0].XXX_P_SIGCATCH.__bits[0];
 #else
--- sysdeps/freebsd/prockernel.c.orig   Sat Oct 16 13:31:43 1999
+++ sysdeps/freebsd/prockernel.c    Wed Dec 27 10:50:19 2000
@@ -36,8 +36,2 @@
 #endif
-#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__))
-#include <machine/pcb.h>
-#endif
-#if defined(__FreeBSD__) && !defined(__alpha__)
-#include <machine/tss.h>
-#endif
 
@@ -80,10 +74,4 @@
    struct kinfo_proc *pinfo;
-   struct user *u_addr = (struct user *)USRSTACK;
-   struct pstats pstats;
-   struct pcb pcb;
    int count;
 
-   char filename [BUFSIZ];
-   struct stat statb;
-
    glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
@@ -103,7 +91,21 @@
 
-   buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
+#if __FreeBSD_version >= 500013
+
+#define    XXX_P_WCHAN ki_wchan
+#define    XXX_P_WMESG ki_wmesg
+#define    XXX_E_WMESG ki_wmesg
+
+#else
+
+#define    XXX_P_WCHAN kp_proc.p_wchan
+#define    XXX_P_WMESG kp_proc.p_wmesg
+#define    XXX_E_WMESG kp_eproc.e_wmesg
+
+#endif
+
+   buf->nwchan = (unsigned long) pinfo [0].XXX_P_WCHAN &~ KERNBASE;
    buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
 
-   if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
-       strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
+   if (pinfo [0].XXX_P_WCHAN && pinfo [0].XXX_P_WMESG) {
+       strncpy (buf->wchan, pinfo [0].XXX_E_WMESG,
             sizeof (buf->wchan) - 1);
@@ -115,70 +117,8 @@
 
-   /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */
-
-   /* [FIXME]: /usr/include/sys/user.h tells me that the user area
-    *          may or may not be at the same kernel address in all
-    *          processes, but I don't see any way to get that address.
-    *          Since `ps' simply uses its own address, I think it's
-    *          safe to do this here, too. */
-
-   /* NOTE: You need to mount the /proc filesystem to make
-    *       `kvm_uread' work. */
-
-   sprintf (filename, "/proc/%d/mem", (int) pid);
-   if (stat (filename, &statb)) return;
-
-   glibtop_suid_enter (server);
-
-   if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
-       kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
-              (unsigned long) &u_addr->u_stats,
-              (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
-       {
-           /*
-            * The u-area might be swapped out, and we can't get
-            * at it because we have a crashdump and no swap.
-            * If it's here fill in these fields, otherwise, just
-            * leave them 0.
-            */
-
-           buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt;
-           buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt;
-           buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt;
-           buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt;
-           
-           buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
-       }
-
-   if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
-       kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
-              (unsigned long) &u_addr->u_pcb,
-              (char *) &pcb, sizeof (pcb)) == sizeof (pcb))
-       {
-#ifdef __FreeBSD__
-#ifndef __alpha__
-#if (__FreeBSD_version >= 300003)
-           buf->kstk_esp = (u_int64_t) pcb.pcb_esp;
-           buf->kstk_eip = (u_int64_t) pcb.pcb_eip;
-#else
-           buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
-           buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
-#endif
-#else
-           /*xxx FreeBSD/Alpha? */
-#endif
-#else
-           buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
-#ifdef __bsdi__
-           buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
-#else
-           buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
-#endif
-
-           buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
-#endif
-       }
-
-   /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
-
-   glibtop_suid_leave (server);
+   /* XXX: the code here was, quite frankly, junk, and almost
+    * certainly wrong - remove it all, leave these fields
+    * unpopulated, and give up until such time as the right
+    * code is produced for both FreeBSD 4.x and 5.x
+    */
+   return;
 }