1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Switch back from KERN_PROC2/kinfo_proc2 to KERN_PROC/kinfo_proc now

that we've got name we want for the API we want

"ZAP!" deraadt@
This commit is contained in:
guenther 2011-04-10 03:20:58 +00:00
parent a7ad7bb714
commit 5027561d80
17 changed files with 183 additions and 183 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.13 2006/05/02 05:25:19 hugh Exp $ */
/* $OpenBSD: extern.h,v 1.14 2011/04/10 03:20:58 guenther Exp $ */
/* $NetBSD: extern.h,v 1.10 1995/05/21 13:38:27 mycroft Exp $ */
/*-
@ -44,42 +44,42 @@ extern VAR var[];
extern VARENT *vhead;
__BEGIN_DECLS
void command(const struct kinfo_proc2 *, VARENT *);
void cputime(const struct kinfo_proc2 *, VARENT *);
void command(const struct kinfo_proc *, VARENT *);
void cputime(const struct kinfo_proc *, VARENT *);
int donlist(void);
void emulname(const struct kinfo_proc2 *, VARENT *);
void emulname(const struct kinfo_proc *, VARENT *);
void fmt_puts(const char *, int *);
void fmt_putc(int, int *);
double getpcpu(const struct kinfo_proc2 *);
double getpmem(const struct kinfo_proc2 *);
void gname(const struct kinfo_proc2 *, VARENT *);
void logname(const struct kinfo_proc2 *, VARENT *);
void longtname(const struct kinfo_proc2 *, VARENT *);
void lstarted(const struct kinfo_proc2 *, VARENT *);
void maxrss(const struct kinfo_proc2 *, VARENT *);
double getpcpu(const struct kinfo_proc *);
double getpmem(const struct kinfo_proc *);
void gname(const struct kinfo_proc *, VARENT *);
void logname(const struct kinfo_proc *, VARENT *);
void longtname(const struct kinfo_proc *, VARENT *);
void lstarted(const struct kinfo_proc *, VARENT *);
void maxrss(const struct kinfo_proc *, VARENT *);
void nlisterr(struct nlist *);
void p_rssize(const struct kinfo_proc2 *, VARENT *);
void pagein(const struct kinfo_proc2 *, VARENT *);
void p_rssize(const struct kinfo_proc *, VARENT *);
void pagein(const struct kinfo_proc *, VARENT *);
void parsefmt(char *);
void pcpu(const struct kinfo_proc2 *, VARENT *);
void pmem(const struct kinfo_proc2 *, VARENT *);
void pri(const struct kinfo_proc2 *, VARENT *);
void pcpu(const struct kinfo_proc *, VARENT *);
void pmem(const struct kinfo_proc *, VARENT *);
void pri(const struct kinfo_proc *, VARENT *);
void printheader(void);
void pvar(const struct kinfo_proc2 *kp, VARENT *);
void pnice(const struct kinfo_proc2 *kp, VARENT *);
void rgname(const struct kinfo_proc2 *, VARENT *);
void rssize(const struct kinfo_proc2 *, VARENT *);
void runame(const struct kinfo_proc2 *, VARENT *);
void pvar(const struct kinfo_proc *kp, VARENT *);
void pnice(const struct kinfo_proc *kp, VARENT *);
void rgname(const struct kinfo_proc *, VARENT *);
void rssize(const struct kinfo_proc *, VARENT *);
void runame(const struct kinfo_proc *, VARENT *);
void showkey(void);
void started(const struct kinfo_proc2 *, VARENT *);
void state(const struct kinfo_proc2 *, VARENT *);
void tdev(const struct kinfo_proc2 *, VARENT *);
void tname(const struct kinfo_proc2 *, VARENT *);
void tsize(const struct kinfo_proc2 *, VARENT *);
void dsize(const struct kinfo_proc2 *, VARENT *);
void ssize(const struct kinfo_proc2 *, VARENT *);
void ucomm(const struct kinfo_proc2 *, VARENT *);
void euname(const struct kinfo_proc2 *, VARENT *);
void vsize(const struct kinfo_proc2 *, VARENT *);
void wchan(const struct kinfo_proc2 *, VARENT *);
void started(const struct kinfo_proc *, VARENT *);
void state(const struct kinfo_proc *, VARENT *);
void tdev(const struct kinfo_proc *, VARENT *);
void tname(const struct kinfo_proc *, VARENT *);
void tsize(const struct kinfo_proc *, VARENT *);
void dsize(const struct kinfo_proc *, VARENT *);
void ssize(const struct kinfo_proc *, VARENT *);
void ucomm(const struct kinfo_proc *, VARENT *);
void euname(const struct kinfo_proc *, VARENT *);
void vsize(const struct kinfo_proc *, VARENT *);
void wchan(const struct kinfo_proc *, VARENT *);
__END_DECLS

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keyword.c,v 1.31 2011/03/12 04:54:28 guenther Exp $ */
/* $OpenBSD: keyword.c,v 1.32 2011/04/10 03:20:58 guenther Exp $ */
/* $NetBSD: keyword.c,v 1.12.6.1 1996/05/30 21:25:13 cgd Exp $ */
/*-
@ -60,7 +60,7 @@ int utime(), stime(), ixrss(), idrss(), isrss();
#endif
/* Compute offset in common structures. */
#define POFF(x) offsetof(struct kinfo_proc2, x)
#define POFF(x) offsetof(struct kinfo_proc, x)
#define UIDFMT "u"
#define UIDLEN 5
@ -75,7 +75,7 @@ int utime(), stime(), ixrss(), idrss(), isrss();
#define USERLEN 8
/* Bit types must match their respective entries in struct kinfo_proc2 */
/* Bit types must match their respective entries in struct kinfo_proc */
VAR var[] = {
{"%cpu", "%CPU", NULL, NLIST, pcpu, 4},
{"%mem", "%MEM", NULL, NLIST, pmem, 4},

View File

@ -1,4 +1,4 @@
/* $OpenBSD: print.c,v 1.47 2011/03/12 04:54:28 guenther Exp $ */
/* $OpenBSD: print.c,v 1.48 2011/04/10 03:20:58 guenther Exp $ */
/* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */
/*-
@ -92,7 +92,7 @@ printheader(void)
}
void
command(const struct kinfo_proc2 *kp, VARENT *ve)
command(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
int left, wantspace = 0;
@ -109,7 +109,7 @@ command(const struct kinfo_proc2 *kp, VARENT *ve)
} else
left = -1;
if (needenv && kd != NULL) {
argv = kvm_getenvv2(kd, kp, termwidth);
argv = kvm_getenvv(kd, kp, termwidth);
if ((p = argv) != NULL) {
while (*p) {
fmt_puts(*p, &left);
@ -125,7 +125,7 @@ command(const struct kinfo_proc2 *kp, VARENT *ve)
if (needcomm) {
if (!commandonly) {
if (kd != NULL) {
argv = kvm_getargv2(kd, kp, termwidth);
argv = kvm_getargv(kd, kp, termwidth);
if ((p = argv) != NULL) {
if (wantspace) {
fmt_putc(' ', &left);
@ -169,7 +169,7 @@ command(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
ucomm(const struct kinfo_proc2 *kp, VARENT *ve)
ucomm(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -178,7 +178,7 @@ ucomm(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
logname(const struct kinfo_proc2 *kp, VARENT *ve)
logname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -195,7 +195,7 @@ logname(const struct kinfo_proc2 *kp, VARENT *ve)
#define pgtok(a) (((unsigned long long)(a)*getpagesize())/1024)
void
state(const struct kinfo_proc2 *kp, VARENT *ve)
state(const struct kinfo_proc *kp, VARENT *ve)
{
extern int ncpu;
int flag;
@ -271,7 +271,7 @@ state(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
pri(const struct kinfo_proc2 *kp, VARENT *ve)
pri(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -280,7 +280,7 @@ pri(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
pnice(const struct kinfo_proc2 *kp, VARENT *ve)
pnice(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
v = ve->var;
@ -288,7 +288,7 @@ pnice(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
euname(const struct kinfo_proc2 *kp, VARENT *ve)
euname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -298,7 +298,7 @@ euname(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
runame(const struct kinfo_proc2 *kp, VARENT *ve)
runame(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -308,7 +308,7 @@ runame(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
gname(const struct kinfo_proc2 *kp, VARENT *ve)
gname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -318,7 +318,7 @@ gname(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
rgname(const struct kinfo_proc2 *kp, VARENT *ve)
rgname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -328,7 +328,7 @@ rgname(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
tdev(const struct kinfo_proc2 *kp, VARENT *ve)
tdev(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
dev_t dev;
@ -346,7 +346,7 @@ tdev(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
tname(const struct kinfo_proc2 *kp, VARENT *ve)
tname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
dev_t dev;
@ -365,7 +365,7 @@ tname(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
longtname(const struct kinfo_proc2 *kp, VARENT *ve)
longtname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
dev_t dev;
@ -380,7 +380,7 @@ longtname(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
started(const struct kinfo_proc2 *kp, VARENT *ve)
started(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
static time_t now;
@ -408,7 +408,7 @@ started(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
lstarted(const struct kinfo_proc2 *kp, VARENT *ve)
lstarted(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
time_t startt;
@ -426,7 +426,7 @@ lstarted(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
wchan(const struct kinfo_proc2 *kp, VARENT *ve)
wchan(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -438,7 +438,7 @@ wchan(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
vsize(const struct kinfo_proc2 *kp, VARENT *ve)
vsize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -448,7 +448,7 @@ vsize(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
rssize(const struct kinfo_proc2 *kp, VARENT *ve)
rssize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -459,7 +459,7 @@ rssize(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
p_rssize(const struct kinfo_proc2 *kp, VARENT *ve)
p_rssize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -469,7 +469,7 @@ p_rssize(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
cputime(const struct kinfo_proc2 *kp, VARENT *ve)
cputime(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
long secs;
@ -505,7 +505,7 @@ cputime(const struct kinfo_proc2 *kp, VARENT *ve)
}
double
getpcpu(const struct kinfo_proc2 *kp)
getpcpu(const struct kinfo_proc *kp)
{
double d;
@ -532,7 +532,7 @@ getpcpu(const struct kinfo_proc2 *kp)
}
void
pcpu(const struct kinfo_proc2 *kp, VARENT *ve)
pcpu(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -541,7 +541,7 @@ pcpu(const struct kinfo_proc2 *kp, VARENT *ve)
}
double
getpmem(const struct kinfo_proc2 *kp)
getpmem(const struct kinfo_proc *kp)
{
double fracmem;
int szptudot;
@ -559,7 +559,7 @@ getpmem(const struct kinfo_proc2 *kp)
}
void
pmem(const struct kinfo_proc2 *kp, VARENT *ve)
pmem(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -568,7 +568,7 @@ pmem(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
pagein(const struct kinfo_proc2 *kp, VARENT *ve)
pagein(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -578,7 +578,7 @@ pagein(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
maxrss(const struct kinfo_proc2 *kp, VARENT *ve)
maxrss(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -587,7 +587,7 @@ maxrss(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
tsize(const struct kinfo_proc2 *kp, VARENT *ve)
tsize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -596,7 +596,7 @@ tsize(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
dsize(const struct kinfo_proc2 *kp, VARENT *ve)
dsize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -605,7 +605,7 @@ dsize(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
ssize(const struct kinfo_proc2 *kp, VARENT *ve)
ssize(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -665,7 +665,7 @@ printval(char *bp, VAR *v)
}
void
pvar(const struct kinfo_proc2 *kp, VARENT *ve)
pvar(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;
@ -677,7 +677,7 @@ pvar(const struct kinfo_proc2 *kp, VARENT *ve)
}
void
emulname(const struct kinfo_proc2 *kp, VARENT *ve)
emulname(const struct kinfo_proc *kp, VARENT *ve)
{
VAR *v;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ps.c,v 1.48 2010/07/02 15:43:15 guenther Exp $ */
/* $OpenBSD: ps.c,v 1.49 2011/04/10 03:20:58 guenther Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@ -91,7 +91,7 @@ int kvm_sysctl_only;
int
main(int argc, char *argv[])
{
struct kinfo_proc2 *kp, **kinfo;
struct kinfo_proc *kp, **kinfo;
struct varent *vent;
struct winsize ws;
struct passwd *pwd;
@ -313,7 +313,7 @@ main(int argc, char *argv[])
/*
* select procs
*/
kp = kvm_getproc2(kd, what, flag, sizeof(*kp), &nentries);
kp = kvm_getprocs(kd, what, flag, sizeof(*kp), &nentries);
if (kp == NULL)
errx(1, "%s", kvm_geterr(kd));
@ -378,8 +378,8 @@ scanvars(void)
static int
pscomp(const void *v1, const void *v2)
{
const struct kinfo_proc2 *kp1 = *(const struct kinfo_proc2 **)v1;
const struct kinfo_proc2 *kp2 = *(const struct kinfo_proc2 **)v2;
const struct kinfo_proc *kp1 = *(const struct kinfo_proc **)v1;
const struct kinfo_proc *kp2 = *(const struct kinfo_proc **)v2;
int i;
#define VSIZE(k) ((k)->p_vm_dsize + (k)->p_vm_ssize + (k)->p_vm_tsize)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ps.h,v 1.8 2008/03/08 19:20:12 millert Exp $ */
/* $OpenBSD: ps.h,v 1.9 2011/04/10 03:20:58 guenther Exp $ */
/* $NetBSD: ps.h,v 1.11 1995/09/29 21:57:03 cgd Exp $ */
/*-
@ -51,7 +51,7 @@ typedef struct varent {
struct var *var;
} VARENT;
struct kinfo_proc2;
struct kinfo_proc;
typedef struct var {
char *name; /* name(s) of variable */
char *header; /* default header */
@ -63,7 +63,7 @@ typedef struct var {
#define NLIST 0x10 /* needs nlist info from kernel */
u_int flag;
/* output routine */
void (*oproc)(const struct kinfo_proc2 *, struct varent *);
void (*oproc)(const struct kinfo_proc *, struct varent *);
short width; /* printing width */
char parsed; /* have we been parsed yet? (avoid dupes) */
/*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: copy.c,v 1.3 2009/02/15 13:33:22 jsing Exp $ */
/* $OpenBSD: copy.c,v 1.4 2011/04/10 03:20:59 guenther Exp $ */
/* Written by Ted Unangst 2004 Public Domain */
@ -34,7 +34,7 @@ main(int argc, char **argv)
void *goodbuf;
void *badbuf;
int mib[6];
struct kinfo_proc2 kinfo;
struct kinfo_proc kinfo;
size_t kinfosize = sizeof(kinfo);
int s, i;
struct ifreq ifrdesc;
@ -45,10 +45,10 @@ main(int argc, char **argv)
err(1, "socket");
mib[0] = CTL_KERN;
mib[1] = KERN_PROC2;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
mib[4] = sizeof(struct kinfo_proc2);
mib[4] = sizeof(struct kinfo_proc);
mib[5] = 1;
if (sysctl(mib, 6, &kinfo, &kinfosize, 0, 0))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pkill.c,v 1.18 2009/10/27 23:59:41 deraadt Exp $ */
/* $OpenBSD: pkill.c,v 1.19 2011/04/10 03:20:59 guenther Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@ -73,7 +73,7 @@ struct list {
SLIST_HEAD(listhead, list);
struct kinfo_proc2 *plist;
struct kinfo_proc *plist;
char *selected;
char *delim = "\n";
int nproc;
@ -98,8 +98,8 @@ struct listhead sidlist = SLIST_HEAD_INITIALIZER(list);
int main(int, char **);
void usage(void);
int killact(struct kinfo_proc2 *, int);
int grepact(struct kinfo_proc2 *, int);
int killact(struct kinfo_proc *, int);
int grepact(struct kinfo_proc *, int);
void makelist(struct listhead *, enum listtype, char *);
extern char *__progname;
@ -111,8 +111,8 @@ main(int argc, char **argv)
extern int optind;
char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q;
int i, j, ch, bestidx, rv, criteria;
int (*action)(struct kinfo_proc2 *, int);
struct kinfo_proc2 *kp;
int (*action)(struct kinfo_proc *, int);
struct kinfo_proc *kp;
struct list *li;
u_int32_t bestsec, bestusec;
regex_t reg;
@ -227,9 +227,9 @@ main(int argc, char **argv)
if (kd == NULL)
errx(STATUS_ERROR, "kvm_openfiles(): %s", buf);
plist = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*plist), &nproc);
plist = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*plist), &nproc);
if (plist == NULL)
errx(STATUS_ERROR, "kvm_getproc2() failed");
errx(STATUS_ERROR, "kvm_getprocs() failed");
/*
* Allocate memory which will be used to keep track of the
@ -253,7 +253,7 @@ main(int argc, char **argv)
continue;
if (matchargs) {
if ((pargv = kvm_getargv2(kd, kp, 0)) == NULL)
if ((pargv = kvm_getargv(kd, kp, 0)) == NULL)
continue;
j = 0;
@ -430,7 +430,7 @@ usage(void)
}
int
killact(struct kinfo_proc2 *kp, int dummy)
killact(struct kinfo_proc *kp, int dummy)
{
if (kill(kp->p_pid, signum) == -1 && errno != ESRCH) {
@ -441,14 +441,14 @@ killact(struct kinfo_proc2 *kp, int dummy)
}
int
grepact(struct kinfo_proc2 *kp, int printdelim)
grepact(struct kinfo_proc *kp, int printdelim)
{
char **argv;
if (printdelim)
fputs(delim, stdout);
if (longfmt && matchargs) {
if ((argv = kvm_getargv2(kd, kp, 0)) == NULL)
if ((argv = kvm_getargv(kd, kp, 0)) == NULL)
return (-1);
printf("%d ", (int)kp->p_pid);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pigs.c,v 1.24 2011/03/02 06:48:17 jasper Exp $ */
/* $OpenBSD: pigs.c,v 1.25 2011/04/10 03:20:59 guenther Exp $ */
/* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */
/*-
@ -57,7 +57,7 @@ int read_pg(void);
int select_pg(void);
void showpigs(int k);
static struct kinfo_proc2 *procbase = NULL;
static struct kinfo_proc *procbase = NULL;
static int nproc, pigs_cnt, *pb_indices = NULL;
static int onproc = -1;
@ -124,7 +124,7 @@ int
getprocs(void)
{
size_t size;
int mib[6] = {CTL_KERN, KERN_PROC2, KERN_PROC_KTHREAD, 0, sizeof(struct kinfo_proc2), 0};
int mib[6] = {CTL_KERN, KERN_PROC, KERN_PROC_KTHREAD, 0, sizeof(struct kinfo_proc), 0};
int st;
@ -139,12 +139,12 @@ getprocs(void)
if ((procbase = malloc(size + 1)) == NULL)
return (1);
mib[5] = (int)(size / sizeof(struct kinfo_proc2));
mib[5] = (int)(size / sizeof(struct kinfo_proc));
st = sysctl(mib, 6, procbase, &size, NULL, 0);
if (st == -1)
return (1);
nproc = (int)(size / sizeof(struct kinfo_proc2));
nproc = (int)(size / sizeof(struct kinfo_proc));
return (0);
}
@ -255,7 +255,7 @@ initpigs(void)
void
showpigs(int k)
{
struct kinfo_proc2 *kp;
struct kinfo_proc *kp;
double value;
char *uname, *pname;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: procname.c,v 1.6 2009/12/24 22:29:15 guenther Exp $ */
/* $OpenBSD: procname.c,v 1.7 2011/04/10 03:20:59 guenther Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -34,11 +34,11 @@
#define is_stopped(p) \
((p)->p_stat == SSTOP || (p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
struct kinfo_proc2 *cmp_procs(struct kinfo_proc2 *, struct kinfo_proc2 *);
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *get_proc_name(int, char *);
struct kinfo_proc2 *
cmp_procs(struct kinfo_proc2 *p1, struct kinfo_proc2 *p2)
struct kinfo_proc *
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
{
if (is_runnable(p1) && !is_runnable(p2))
return (p1);
@ -78,11 +78,11 @@ cmp_procs(struct kinfo_proc2 *p1, struct kinfo_proc2 *p2)
char *
get_proc_name(int fd, char *tty)
{
int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PGRP, 0,
sizeof(struct kinfo_proc2), 0 };
int mib[6] = { CTL_KERN, KERN_PROC, KERN_PROC_PGRP, 0,
sizeof(struct kinfo_proc), 0 };
struct stat sb;
size_t len;
struct kinfo_proc2 *buf, *newbuf, *bestp;
struct kinfo_proc *buf, *newbuf, *bestp;
u_int i;
char *name;
@ -102,7 +102,7 @@ retry:
goto error;
buf = newbuf;
mib[5] = (int)(len / sizeof(struct kinfo_proc2));
mib[5] = (int)(len / sizeof(struct kinfo_proc));
if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) == -1) {
if (errno == ENOMEM)
goto retry;
@ -110,7 +110,7 @@ retry:
}
bestp = NULL;
for (i = 0; i < len / sizeof (struct kinfo_proc2); i++) {
for (i = 0; i < len / sizeof (struct kinfo_proc); i++) {
if ((dev_t)buf[i].p_tdev != sb.st_rdev)
continue;
if (bestp == NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: machine.c,v 1.67 2010/04/26 00:30:58 deraadt Exp $ */
/* $OpenBSD: machine.c,v 1.68 2011/04/10 03:20:59 guenther Exp $ */
/*-
* Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com>
@ -52,13 +52,13 @@
#include "loadavg.h"
static int swapmode(int *, int *);
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 */
};
@ -123,8 +123,8 @@ char *ordernames[] = {
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 */
@ -275,13 +275,13 @@ get_system_info(struct system_info *si)
static struct handle handle;
struct kinfo_proc2 *
struct kinfo_proc *
getprocs(int op, int arg, int *cnt)
{
size_t size;
int mib[6] = {CTL_KERN, KERN_PROC2, 0, 0, sizeof(struct kinfo_proc2), 0};
int mib[6] = {CTL_KERN, KERN_PROC, 0, 0, sizeof(struct kinfo_proc), 0};
static int maxslp_mib[] = {CTL_VM, VM_MAXSLP};
static struct kinfo_proc2 *procbase;
static struct kinfo_proc *procbase;
int st;
mib[2] = op;
@ -296,21 +296,21 @@ getprocs(int op, int arg, int *cnt)
free(procbase);
st = sysctl(mib, 6, NULL, &size, NULL, 0);
if (st == -1) {
/* _kvm_syserr(kd, kd->program, "kvm_getproc2"); */
/* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */
return (0);
}
size = 5 * size / 4; /* extra slop */
if ((procbase = malloc(size)) == NULL)
return (0);
mib[5] = (int)(size / sizeof(struct kinfo_proc2));
mib[5] = (int)(size / sizeof(struct kinfo_proc));
st = sysctl(mib, 6, procbase, &size, NULL, 0);
if (st == -1) {
if (errno == ENOMEM)
goto retry;
/* _kvm_syserr(kd, kd->program, "kvm_getproc2"); */
/* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */
return (0);
}
*cnt = (int)(size / sizeof(struct kinfo_proc2));
*cnt = (int)(size / sizeof(struct kinfo_proc));
return (procbase);
}
@ -320,15 +320,15 @@ get_process_info(struct system_info *si, struct process_select *sel,
{
int show_idle, show_system, show_threads, show_uid, show_pid, show_cmd;
int total_procs, active_procs;
struct kinfo_proc2 **prefp, *pp;
struct kinfo_proc **prefp, *pp;
if ((pbase = getprocs(KERN_PROC_KTHREAD, 0, &nproc)) == NULL) {
/* warnx("%s", kvm_geterr(kd)); */
quit(23);
}
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);
@ -377,7 +377,7 @@ get_process_info(struct system_info *si, struct process_select *sel,
/* if requested, sort the "interesting" processes */
if (compare != NULL)
qsort((char *) pref, active_procs,
sizeof(struct kinfo_proc2 *), compare);
sizeof(struct kinfo_proc *), compare);
/* remember active and total counts */
si->p_total = total_procs;
si->p_active = pref_len = active_procs;
@ -391,7 +391,7 @@ get_process_info(struct system_info *si, struct process_select *sel,
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];
@ -405,7 +405,7 @@ state_abbr(struct kinfo_proc2 *pp)
}
static char *
format_comm(struct kinfo_proc2 *kp)
format_comm(struct kinfo_proc *kp)
{
static char **s, buf[MAX_COLS];
size_t siz = 100;
@ -443,7 +443,7 @@ char *
format_next_process(caddr_t handle, char *(*get_userid)(uid_t), pid_t *pid)
{
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;
@ -532,13 +532,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
@ -556,13 +556,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
@ -580,13 +580,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
@ -604,13 +604,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
@ -628,13 +628,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
@ -651,13 +651,13 @@ compare_pid(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_PID
ORDERKEY_PCTCPU
@ -675,13 +675,13 @@ compare_cmd(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_CMD
ORDERKEY_PCTCPU
@ -718,7 +718,7 @@ int (*proc_compares[])(const void *, const void *) = {
uid_t
proc_owner(pid_t pid)
{
struct kinfo_proc2 **prefp, *pp;
struct kinfo_proc **prefp, *pp;
int cnt;
prefp = pref;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: machine.h,v 1.15 2007/05/29 00:56:56 otto Exp $ */
/* $OpenBSD: machine.h,v 1.16 2011/04/10 03:20:59 guenther Exp $ */
/*
* Top users/processes display for Unix
@ -91,4 +91,4 @@ get_process_info(struct system_info *, struct process_select *,
extern char *format_next_process(caddr_t, char *(*)(uid_t), pid_t *);
extern uid_t proc_owner(pid_t);
extern struct kinfo_proc2 *getprocs(int, int, int *);
extern struct kinfo_proc *getprocs(int, int, int *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: utils.c,v 1.22 2010/01/29 00:36:09 tedu Exp $ */
/* $OpenBSD: utils.c,v 1.23 2011/04/10 03:20:59 guenther Exp $ */
/*
* Top users/processes display for Unix
@ -341,7 +341,7 @@ format_k(int amt)
int
find_pid(pid_t pid)
{
struct kinfo_proc2 *pbase, *cur;
struct kinfo_proc *pbase, *cur;
int nproc;
if ((pbase = getprocs(KERN_PROC_KTHREAD, 0, &nproc)) == NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.7 2004/09/14 22:24:24 deraadt Exp $ */
/* $OpenBSD: extern.h,v 1.8 2011/04/10 03:20:59 guenther Exp $ */
/*-
* Copyright (c) 1993
@ -31,9 +31,9 @@
* @(#)extern.h 8.1 (Berkeley) 6/6/93
*/
struct kinfo_proc2;
struct kinfo_proc;
void fmt_puts(const char *, int *);
void fmt_putc(int, int *);
void pr_attime(time_t *, time_t *);
void pr_idle(time_t);
int proc_compare(const struct kinfo_proc2 *, const struct kinfo_proc2 *);
int proc_compare(const struct kinfo_proc *, const struct kinfo_proc *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc_compare.c,v 1.11 2009/10/27 23:59:49 deraadt Exp $ */
/* $OpenBSD: proc_compare.c,v 1.12 2011/04/10 03:20:59 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -62,7 +62,7 @@
#define BOTH 3
int
proc_compare(const struct kinfo_proc2 *p1, const struct kinfo_proc2 *p2)
proc_compare(const struct kinfo_proc *p1, const struct kinfo_proc *p2)
{
if (p1 == NULL)
return (1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: w.c,v 1.47 2009/10/27 23:59:49 deraadt Exp $ */
/* $OpenBSD: w.c,v 1.48 2011/04/10 03:20:59 guenther Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -92,10 +92,10 @@ struct entry {
struct utmp utmp;
dev_t tdev; /* dev_t of terminal */
time_t idle; /* idle time of terminal in seconds */
struct kinfo_proc2 *kp; /* `most interesting' proc */
struct kinfo_proc *kp; /* `most interesting' proc */
} *ep, *ehead = NULL, **nextp = &ehead;
static void pr_args(struct kinfo_proc2 *);
static void pr_args(struct kinfo_proc *);
static void pr_header(time_t *, int);
static struct stat
*ttystat(char *);
@ -105,7 +105,7 @@ int
main(int argc, char *argv[])
{
extern char *__progname;
struct kinfo_proc2 *kp;
struct kinfo_proc *kp;
struct hostent *hp;
struct stat *stp;
FILE *ut;
@ -218,7 +218,7 @@ main(int argc, char *argv[])
#define WUSED (sizeof(HEADER) - sizeof("WHAT"))
(void)puts(HEADER);
kp = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*kp), &nentries);
kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*kp), &nentries);
if (kp == NULL)
errx(1, "%s", kvm_geterr(kd));
for (i = 0; i < nentries; i++, kp++) {
@ -324,7 +324,7 @@ main(int argc, char *argv[])
}
static void
pr_args(struct kinfo_proc2 *kp)
pr_args(struct kinfo_proc *kp)
{
char **argv, *str;
int left;
@ -332,7 +332,7 @@ pr_args(struct kinfo_proc2 *kp)
if (kp == NULL)
goto nothing; /* XXX - can this happen? */
left = argwidth;
argv = kvm_getargv2(kd, kp, argwidth+60); /* +60 for ftpd snip */
argv = kvm_getargv(kd, kp, argwidth+60); /* +60 for ftpd snip */
if (argv == NULL)
goto nothing;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: procmap.c,v 1.36 2011/04/06 11:36:26 miod Exp $ */
/* $OpenBSD: procmap.c,v 1.37 2011/04/10 03:20:59 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.1 2002/09/01 20:32:44 atatat Exp $ */
/*
@ -168,7 +168,7 @@ struct nlist nl[] = {
};
void load_symbols(kvm_t *);
void process_map(kvm_t *, pid_t, struct kinfo_proc2 *, struct sum *);
void process_map(kvm_t *, pid_t, struct kinfo_proc *, struct sum *);
size_t dump_vm_map_entry(kvm_t *, struct kbit *, struct kbit *, int,
struct sum *);
char *findname(kvm_t *, struct kbit *, struct kbit *, struct kbit *,
@ -186,7 +186,7 @@ int
main(int argc, char *argv[])
{
char errbuf[_POSIX2_LINE_MAX], *kmem = NULL, *kernel = NULL;
struct kinfo_proc2 *kproc;
struct kinfo_proc *kproc;
struct sum total_sum;
int many, ch, rc;
kvm_t *kd;
@ -294,8 +294,8 @@ main(int argc, char *argv[])
if (pid == 0)
kproc = NULL;
else {
kproc = kvm_getproc2(kd, KERN_PROC_PID, pid,
sizeof(struct kinfo_proc2), &rc);
kproc = kvm_getprocs(kd, KERN_PROC_PID, pid,
sizeof(struct kinfo_proc), &rc);
if (kproc == NULL || rc == 0) {
errno = ESRCH;
warn("%d", pid);
@ -345,7 +345,7 @@ print_sum(struct sum *sum, struct sum *total_sum)
}
void
process_map(kvm_t *kd, pid_t pid, struct kinfo_proc2 *proc, struct sum *sum)
process_map(kvm_t *kd, pid_t pid, struct kinfo_proc *proc, struct sum *sum)
{
struct kbit kbit[4], *vmspace, *vm_map, *header, *vm_map_entry;
struct vm_map_entry *last;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mib.c,v 1.43 2010/10/15 11:56:13 sthen Exp $ */
/* $OpenBSD: mib.c,v 1.44 2011/04/10 03:20:59 guenther Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@ -329,8 +329,8 @@ int mib_hrprocessor(struct oid *, struct ber_oid *, struct ber_element **);
int mib_hrswrun(struct oid *, struct ber_oid *, struct ber_element **);
int kinfo_proc_comp(const void *, const void *);
int kinfo_proc(u_int32_t, struct kinfo_proc2 **);
int kinfo_args(struct kinfo_proc2 *, char **);
int kinfo_proc(u_int32_t, struct kinfo_proc **);
int kinfo_args(struct kinfo_proc *, char **);
static struct oid hr_mib[] = {
{ MIB(host), OID_MIB },
@ -607,7 +607,7 @@ int
mib_hrswrun(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
{
struct ber_element *ber = *elm;
struct kinfo_proc2 *kinfo;
struct kinfo_proc *kinfo;
char *s;
/* Get and verify the current row index */
@ -681,20 +681,20 @@ mib_hrswrun(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
int
kinfo_proc_comp(const void *a, const void *b)
{
struct kinfo_proc2 * const *k1 = a;
struct kinfo_proc2 * const *k2 = b;
struct kinfo_proc * const *k1 = a;
struct kinfo_proc * const *k2 = b;
return (((*k1)->p_pid > (*k2)->p_pid) ? 1 : -1);
}
int
kinfo_proc(u_int32_t idx, struct kinfo_proc2 **kinfo)
kinfo_proc(u_int32_t idx, struct kinfo_proc **kinfo)
{
static struct kinfo_proc2 *kp = NULL;
static struct kinfo_proc *kp = NULL;
static size_t nkp = 0;
int mib[] = { CTL_KERN, KERN_PROC2,
int mib[] = { CTL_KERN, KERN_PROC,
KERN_PROC_ALL, 0, sizeof(*kp), 0 };
struct kinfo_proc2 **klist;
struct kinfo_proc **klist;
size_t size, count, i;
for (;;) {
@ -744,7 +744,7 @@ kinfo_proc(u_int32_t idx, struct kinfo_proc2 **kinfo)
}
int
kinfo_args(struct kinfo_proc2 *kinfo, char **s)
kinfo_args(struct kinfo_proc *kinfo, char **s)
{
static char str[128];
static char *buf = NULL;