1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00
freebsd-ports/devel/libgtop/files/patch-aj

324 lines
9.8 KiB
Plaintext

--- 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 Sat Oct 16 13:01:39 1999
+++ sysdeps/freebsd/procstate.c Fri Dec 22 18:00:55 2000
@@ -78,11 +78,29 @@
- strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1);
+#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
+
+#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
+
+#endif
+
+ strncpy (buf->cmd, pinfo [0].XXX_P_COMM, sizeof (buf->cmd)-1);
buf->cmd [sizeof (buf->cmd)-1] = 0;
- buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
- buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
+ buf->uid = pinfo [0].XXX_P_SVUID;
+ buf->gid = pinfo [0].XXX_P_SVGID;
#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;
+ buf->ruid = pinfo [0].XXX_P_RUID;
+ buf->rgid = pinfo [0].XXX_P_RGID;
#endif
@@ -94,3 +112,3 @@
#if LIBGTOP_VERSION_CODE >= 1001000
- switch (pinfo [0].kp_proc.p_stat) {
+ switch (pinfo [0].XXX_P_STAT) {
case SIDL:
@@ -114,3 +132,3 @@
#else
- switch (pinfo [0].kp_proc.p_stat) {
+ switch (pinfo [0].XXX_P_STAT) {
case SIDL:
--- 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;
}