catch up with change KERN_PROC2 -> KERN_PROC

This commit is contained in:
naddy 2012-01-08 20:56:03 +00:00
parent f768a542dd
commit 4b0fead1bd
2 changed files with 209 additions and 2 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.5 2011/09/16 08:48:03 espie Exp $
# $OpenBSD: Makefile,v 1.6 2012/01/08 20:56:03 naddy Exp $
COMMENT = top for monitoring PostgreSQL processes
DISTNAME = pg_top-3.6.2
CATEGORIES = databases sysutils
REVISION = 0
REVISION = 1
HOMEPAGE = http://ptop.projects.postgresql.org/
MASTER_SITES = http://pgfoundry.org/frs/download.php/1781/

View File

@ -0,0 +1,207 @@
$OpenBSD: patch-machine_m_openbsd_c,v 1.1 2012/01/08 20:56:03 naddy Exp $
--- machine/m_openbsd.c.orig Sat Apr 5 11:09:06 2008
+++ machine/m_openbsd.c Sun Jan 8 13:54:54 2012
@@ -51,13 +51,13 @@
#include "loadavg.h"
static long swapmode(long *, long *);
-static char *state_abbr(struct kinfo_proc2 *);
-static char *format_comm(struct kinfo_proc2 *);
+static char *state_abbr(struct kinfo_proc *);
+static char *format_comm(struct kinfo_proc *);
/* get_process_info passes back a handle. This is what it looks like: */
struct handle {
- struct kinfo_proc2 **next_proc; /* points to next valid proc pointer */
+ struct kinfo_proc **next_proc; /* points to next valid proc pointer */
int remaining; /* number of pointers remaining */
};
@@ -138,8 +138,8 @@ int (*proc_compares[]) () =
static int nproc;
static int onproc = -1;
static int pref_len;
-static struct kinfo_proc2 *pbase;
-static struct kinfo_proc2 **pref;
+static struct kinfo_proc *pbase;
+static struct kinfo_proc **pref;
/* these are for getting the memory statistics */
static int pageshift; /* log base 2 of the pagesize */
@@ -312,7 +312,7 @@ get_process_info(struct system_info *si, struct proces
{
int show_idle, show_system, show_threads, show_uid, show_cmd;
int total_procs, active_procs;
- struct kinfo_proc2 **prefp, *pp;
+ struct kinfo_proc **prefp, *pp;
int mib[6];
size_t size;
@@ -320,11 +320,11 @@ get_process_info(struct system_info *si, struct proces
PGconn *pgconn;
PGresult *pgresult = NULL;
- size = (size_t) sizeof(struct kinfo_proc2);
+ size = (size_t) sizeof(struct kinfo_proc);
mib[0] = CTL_KERN;
- mib[1] = KERN_PROC2;
+ mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
- mib[4] = sizeof(struct kinfo_proc2);
+ mib[4] = sizeof(struct kinfo_proc);
mib[5] = 1;
nproc = 0;
@@ -333,14 +333,14 @@ get_process_info(struct system_info *si, struct proces
{
pgresult = PQexec(pgconn, QUERY_PROCESSES);
nproc = PQntuples(pgresult);
- pbase = (struct kinfo_proc2 *) realloc(pbase,
- sizeof(struct kinfo_proc2 *) * nproc);
+ pbase = (struct kinfo_proc *) realloc(pbase,
+ sizeof(struct kinfo_proc *) * nproc);
}
PQfinish(pgconn);
if (nproc > onproc)
- pref = (struct kinfo_proc2 **)realloc(pref,
- sizeof(struct kinfo_proc2 *) * (onproc = nproc));
+ pref = (struct kinfo_proc **)realloc(pref,
+ sizeof(struct kinfo_proc *) * (onproc = nproc));
if (pref == NULL) {
warnx("Out of memory.");
quit(23);
@@ -392,9 +392,9 @@ get_process_info(struct system_info *si, struct proces
}
/* if requested, sort the "interesting" processes */
- if (compare_index != NULL)
+ if (compare_index != 0)
qsort((char *) pref, active_procs,
- sizeof(struct kinfo_proc2 *), proc_compares[compare_index]);
+ sizeof(struct kinfo_proc *), proc_compares[compare_index]);
/* remember active and total counts */
si->p_total = total_procs;
si->p_active = pref_len = active_procs;
@@ -408,7 +408,7 @@ get_process_info(struct system_info *si, struct proces
char fmt[MAX_COLS]; /* static area where result is built */
static char *
-state_abbr(struct kinfo_proc2 *pp)
+state_abbr(struct kinfo_proc *pp)
{
static char buf[10];
@@ -422,7 +422,7 @@ state_abbr(struct kinfo_proc2 *pp)
}
static char *
-format_comm(struct kinfo_proc2 *kp)
+format_comm(struct kinfo_proc *kp)
{
#define ARG_SIZE 60
static char **s, buf[ARG_SIZE];
@@ -457,7 +457,7 @@ char *
format_next_process(caddr_t handle, char *(*get_userid)(uid_t))
{
char *p_wait, waddr[sizeof(void *) * 2 + 3]; /* Hexify void pointer */
- struct kinfo_proc2 *pp;
+ struct kinfo_proc *pp;
struct handle *hp;
int cputime;
double pct;
@@ -541,13 +541,13 @@ compare_cpu(const void *v1, const void *v2)
{
struct proc **pp1 = (struct proc **) v1;
struct proc **pp2 = (struct proc **) v2;
- struct kinfo_proc2 *p1, *p2;
+ struct kinfo_proc *p1, *p2;
pctcpu lresult;
int result;
/* remove one level of indirection */
- p1 = *(struct kinfo_proc2 **) pp1;
- p2 = *(struct kinfo_proc2 **) pp2;
+ p1 = *(struct kinfo_proc **) pp1;
+ p2 = *(struct kinfo_proc **) pp2;
ORDERKEY_PCTCPU
ORDERKEY_CPUTIME
@@ -565,13 +565,13 @@ compare_size(const void *v1, const void *v2)
{
struct proc **pp1 = (struct proc **) v1;
struct proc **pp2 = (struct proc **) v2;
- struct kinfo_proc2 *p1, *p2;
+ struct kinfo_proc *p1, *p2;
pctcpu lresult;
int result;
/* remove one level of indirection */
- p1 = *(struct kinfo_proc2 **) pp1;
- p2 = *(struct kinfo_proc2 **) pp2;
+ p1 = *(struct kinfo_proc **) pp1;
+ p2 = *(struct kinfo_proc **) pp2;
ORDERKEY_MEM
ORDERKEY_RSSIZE
@@ -589,13 +589,13 @@ compare_res(const void *v1, const void *v2)
{
struct proc **pp1 = (struct proc **) v1;
struct proc **pp2 = (struct proc **) v2;
- struct kinfo_proc2 *p1, *p2;
+ struct kinfo_proc *p1, *p2;
pctcpu lresult;
int result;
/* remove one level of indirection */
- p1 = *(struct kinfo_proc2 **) pp1;
- p2 = *(struct kinfo_proc2 **) pp2;
+ p1 = *(struct kinfo_proc **) pp1;
+ p2 = *(struct kinfo_proc **) pp2;
ORDERKEY_RSSIZE
ORDERKEY_MEM
@@ -613,13 +613,13 @@ compare_time(const void *v1, const void *v2)
{
struct proc **pp1 = (struct proc **) v1;
struct proc **pp2 = (struct proc **) v2;
- struct kinfo_proc2 *p1, *p2;
+ struct kinfo_proc *p1, *p2;
pctcpu lresult;
int result;
/* remove one level of indirection */
- p1 = *(struct kinfo_proc2 **) pp1;
- p2 = *(struct kinfo_proc2 **) pp2;
+ p1 = *(struct kinfo_proc **) pp1;
+ p2 = *(struct kinfo_proc **) pp2;
ORDERKEY_CPUTIME
ORDERKEY_PCTCPU
@@ -637,13 +637,13 @@ compare_prio(const void *v1, const void *v2)
{
struct proc **pp1 = (struct proc **) v1;
struct proc **pp2 = (struct proc **) v2;
- struct kinfo_proc2 *p1, *p2;
+ struct kinfo_proc *p1, *p2;
pctcpu lresult;
int result;
/* remove one level of indirection */
- p1 = *(struct kinfo_proc2 **) pp1;
- p2 = *(struct kinfo_proc2 **) pp2;
+ p1 = *(struct kinfo_proc **) pp1;
+ p2 = *(struct kinfo_proc **) pp2;
ORDERKEY_PRIO
ORDERKEY_PCTCPU
@@ -667,7 +667,7 @@ compare_prio(const void *v1, const void *v2)
uid_t
proc_owner(pid_t pid)
{
- struct kinfo_proc2 **prefp, *pp;
+ struct kinfo_proc **prefp, *pp;
int cnt;
prefp = pref;