The diff below completely removes the KERN_PROC sysctl() and the 
kvm_getprocs(), kvm_getargv(), and kvm_getenvv() functions.  The former 
has been superseded by KERN_PROC2 while the later have been superseded by 
kvm_getproc2(), kvm_getargv2(), and kvm_getenvv2().  I proposed doing this 
back in July and, IIRC, got mildly positive feedback.

This mainly affects ports, so if you guys think we need to wait, please 
say so.  I'll note again that the whole point of the new calls is that 
they are stable ABIs while the kernel changes: the ABIs for the calls 
being removed changed at least once before 4.7 and again before 4.8...and 
can't even get to the full process information in 4.8!

Note that this bumps the libkvm major.

oks?

Philip Guenther


Index: sys/sys/sysctl.h
===================================================================
RCS file: /cvs/src/sys/sys/sysctl.h,v
retrieving revision 1.106
diff -u -p -r1.106 sysctl.h
--- sys/sys/sysctl.h    19 Aug 2010 18:14:13 -0000      1.106
+++ sys/sys/sysctl.h    24 Oct 2010 07:02:11 -0000
@@ -42,8 +42,6 @@
  * These are for the eproc structure defined below.
  */
 #ifndef _KERNEL
-#include <sys/time.h>
-#include <sys/ucred.h>
 #include <sys/proc.h>
 #include <sys/resource.h>
 #endif
@@ -126,9 +124,7 @@ struct ctlname {
 #define        KERN_HOSTID             11      /* int: host identifier */
 #define        KERN_CLOCKRATE          12      /* struct: struct clockinfo */
 #define        KERN_VNODE              13      /* struct: vnode structures */
-#if defined(_KERNEL) || defined(_LIBKVM)
-#define        KERN_PROC               14      /* struct: process entries */
-#endif
+/*define gap: was KERN_PROC    14      */
 #define        KERN_FILE               15      /* struct: file entries */
 #define        KERN_PROF               16      /* node: kernel profiling info 
*/
 #define        KERN_POSIX1             17      /* int: POSIX.1 version */
@@ -281,7 +277,7 @@ struct ctlname {
 
 
 /*
- * KERN_PROC subtypes
+ * KERN_PROC2 subtypes
  */
 #define        KERN_PROC_ALL           0       /* everything but kernel 
threads */
 #define        KERN_PROC_PID           1       /* by process id */
@@ -308,42 +304,6 @@ struct ctlname {
 #define KERN_PROC_NENV         4
 
 /*
- * KERN_PROC subtype ops return arrays of augmented proc structures:
- */
-struct kinfo_proc {
-       struct  proc kp_proc;                   /* proc structure */
-       struct  eproc {
-               struct  proc *e_paddr;          /* address of proc */
-               struct  session *e_sess;        /* session pointer */
-               struct  pcred e_pcred;          /* process credentials */
-               struct  ucred e_ucred;          /* current credentials */
-               struct  vmspace e_vm;           /* address space */
-               struct  pstats e_pstats;        /* process stats */
-               int     e_pstats_valid;         /* pstats valid? */
-               pid_t   e_ppid;                 /* parent process id */
-               pid_t   e_pgid;                 /* process group id */
-               short   e_jobc;                 /* job control counter */
-               dev_t   e_tdev;                 /* controlling tty dev */
-               pid_t   e_tpgid;                /* tty process group id */
-               struct  session *e_tsess;       /* tty session pointer */
-#define        WMESGLEN        7
-               char    e_wmesg[WMESGLEN+1];    /* wchan message */
-               segsz_t e_xsize;                /* text size */
-               short   e_xrssize;              /* text rss */
-               short   e_xccount;              /* text references */
-               short   e_xswrss;
-               long    e_flag;
-#define        EPROC_CTTY      0x01    /* controlling tty vnode active */
-#define        EPROC_SLEADER   0x02    /* session leader */
-               char    e_login[MAXLOGNAME];    /* setlogin() name */
-#define        EMULNAMELEN     7
-               char    e_emul[EMULNAMELEN+1];  /* syscall emulation name */
-               rlim_t  e_maxrss;
-               struct plimit *e_limit;
-       } kp_eproc;
-};
-
-/*
  * KERN_PROC2 subtype ops return arrays of relatively fixed size
  * structures of process info.   Use 8 byte alignment, and new
  * elements should only be added to the end of this structure so
@@ -373,6 +333,8 @@ struct kinfo_proc2 {
        u_int64_t p_ru;                 /* PTR: Exit information. XXX */
 
        int32_t p_eflag;                /* LONG: extra kinfo_proc2 flags */
+#define        EPROC_CTTY      0x01    /* controlling tty vnode active */
+#define        EPROC_SLEADER   0x02    /* session leader */
        int32_t p_exitsig;              /* INT: signal to sent to parent on 
exit */
        int32_t p_flag;                 /* INT: P_* flags. */
 
@@ -955,8 +917,6 @@ int sysctl_vnode(char *, size_t *, struc
 int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
 #endif
 int sysctl_dopool(int *, u_int, char *, size_t *);
-
-void fill_eproc(struct proc *, struct eproc *);
 
 void fill_file2(struct kinfo_file2 *, struct file *, struct filedesc *,
     int, struct vnode *, struct proc *, struct proc *);
Index: sys/kern/kern_sysctl.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.193
diff -u -p -r1.193 kern_sysctl.c
--- sys/kern/kern_sysctl.c      23 Sep 2010 13:24:22 -0000      1.193
+++ sys/kern/kern_sysctl.c      24 Oct 2010 07:02:17 -0000
@@ -273,7 +273,6 @@ kern_sysctl(int *name, u_int namelen, vo
        /* all sysctl names at this level are terminal except a ton of them */
        if (namelen != 1) {
                switch (name[0]) {
-               case KERN_PROC:
                case KERN_PROC2:
                case KERN_PROF:
                case KERN_MALLOCSTATS:
@@ -360,9 +359,8 @@ kern_sysctl(int *name, u_int namelen, vo
        case KERN_VNODE:
                return (sysctl_vnode(oldp, oldlenp, p));
 #ifndef SMALL_KERNEL
-       case KERN_PROC:
        case KERN_PROC2:
-               return (sysctl_doproc(name, namelen, oldp, oldlenp));
+               return (sysctl_doproc(name + 1, namelen - 1, oldp, oldlenp));
        case KERN_PROC_ARGS:
                return (sysctl_proc_args(name + 1, namelen - 1, oldp, oldlenp,
                     p));
@@ -1317,42 +1315,33 @@ sysctl_file2(int *name, u_int namelen, c
 /*
  * try over estimating by 5 procs
  */
-#define KERN_PROCSLOP  (5 * sizeof (struct kinfo_proc))
+#define KERN_PROCSLOP  5
 
 int
 sysctl_doproc(int *name, u_int namelen, char *where, size_t *sizep)
 {
        struct kinfo_proc2 *kproc2 = NULL;
-       struct eproc *eproc = NULL;
        struct proc *p;
        struct process *pr;
        char *dp;
        int arg, buflen, doingzomb, elem_size, elem_count;
-       int error, needed, type, op;
+       int error, needed, op;
 
        dp = where;
        buflen = where != NULL ? *sizep : 0;
        needed = error = 0;
-       type = name[0];
 
-       if (type == KERN_PROC) {
-               if (namelen != 3 && !(namelen == 2 &&
-                   (name[1] == KERN_PROC_ALL || name[1] == KERN_PROC_KTHREAD)))
-                       return (EINVAL);
-               op = name[1];
-               arg = op == KERN_PROC_ALL ? 0 : name[2];
-               elem_size = elem_count = 0;
-               eproc = malloc(sizeof(struct eproc), M_TEMP, M_WAITOK);
-       } else /* if (type == KERN_PROC2) */ {
-               if (namelen != 5 || name[3] < 0 || name[4] < 0 ||
-                   name[3] > sizeof(*kproc2))
-                       return (EINVAL);
-               op = name[1];
-               arg = name[2];
-               elem_size = name[3];
-               elem_count = name[4];
+       if (namelen != 4 || name[2] < 0 || name[3] < 0 ||
+           name[2] > sizeof(*kproc2))
+               return (EINVAL);
+       op = name[0];
+       arg = name[1];
+       elem_size = name[2];
+       elem_count = name[3];
+
+       if (where != NULL)
                kproc2 = malloc(sizeof(struct kinfo_proc2), M_TEMP, M_WAITOK);
-       }
+
        p = LIST_FIRST(&allproc);
        doingzomb = 0;
 again:
@@ -1412,47 +1401,31 @@ again:
                        if (p->p_flag & P_SYSTEM)
                                continue;
                        break;
+
                case KERN_PROC_KTHREAD:
                        /* no filtering */
                        break;
+
                default:
                        error = EINVAL;
                        goto err;
                }
-               if (type == KERN_PROC) {
-                       if (buflen >= sizeof(struct kinfo_proc)) {
-                               fill_eproc(p, eproc);
-                               error = copyout((caddr_t)p,
-                                   &((struct kinfo_proc *)dp)->kp_proc,
-                                   sizeof(struct proc));
-                               if (error)
-                                       goto err;
-                               error = copyout((caddr_t)eproc,
-                                   &((struct kinfo_proc *)dp)->kp_eproc,
-                                   sizeof(*eproc));
-                               if (error)
-                                       goto err;
-                               dp += sizeof(struct kinfo_proc);
-                               buflen -= sizeof(struct kinfo_proc);
-                       }
-                       needed += sizeof(struct kinfo_proc);
-               } else /* if (type == KERN_PROC2) */ {
-                       if (buflen >= elem_size && elem_count > 0) {
-                               fill_kproc2(p, kproc2);
-                               /*
-                                * Copy out elem_size, but not larger than
-                                * the size of a struct kinfo_proc2.
-                                */
-                               error = copyout(kproc2, dp,
-                                   min(sizeof(*kproc2), elem_size));
-                               if (error)
-                                       goto err;
-                               dp += elem_size;
-                               buflen -= elem_size;
-                               elem_count--;
-                       }
-                       needed += elem_size;
+
+               if (buflen >= elem_size && elem_count > 0) {
+                       fill_kproc2(p, kproc2);
+                       /*
+                        * Copy out elem_size, but not larger than
+                        * the size of a struct kinfo_proc2.
+                        */
+                       error = copyout(kproc2, dp,
+                           min(sizeof(*kproc2), elem_size));
+                       if (error)
+                               goto err;
+                       dp += elem_size;
+                       buflen -= elem_size;
+                       elem_count--;
                }
+               needed += elem_size;
        }
        if (doingzomb == 0) {
                p = LIST_FIRST(&zombproc);
@@ -1466,72 +1439,13 @@ again:
                        goto err;
                }
        } else {
-               needed += KERN_PROCSLOP;
+               needed += KERN_PROCSLOP * elem_size;
                *sizep = needed;
        }
 err:
-       if (eproc)
-               free(eproc, M_TEMP);
        if (kproc2)
                free(kproc2, M_TEMP);
        return (error);
-}
-
-/*
- * Fill in an eproc structure for the specified process.
- */
-void
-fill_eproc(struct proc *p, struct eproc *ep)
-{
-       struct tty *tp;
-
-       ep->e_paddr = p;
-       ep->e_sess = p->p_p->ps_pgrp->pg_session;
-       ep->e_pcred = *p->p_cred;
-       ep->e_ucred = *p->p_ucred;
-       if (p->p_stat == SIDL || P_ZOMBIE(p)) {
-               ep->e_vm.vm_rssize = 0;
-               ep->e_vm.vm_tsize = 0;
-               ep->e_vm.vm_dsize = 0;
-               ep->e_vm.vm_ssize = 0;
-               bzero(&ep->e_pstats, sizeof(ep->e_pstats));
-               ep->e_pstats_valid = 0;
-       } else {
-               struct vmspace *vm = p->p_vmspace;
-
-               ep->e_vm.vm_rssize = vm_resident_count(vm);
-               ep->e_vm.vm_tsize = vm->vm_tsize;
-               ep->e_vm.vm_dsize = vm->vm_dused;
-               ep->e_vm.vm_ssize = vm->vm_ssize;
-               ep->e_pstats = *p->p_stats;
-               ep->e_pstats_valid = 1;
-       }
-       if (p->p_p->ps_pptr)
-               ep->e_ppid = p->p_p->ps_pptr->ps_pid;
-       else
-               ep->e_ppid = 0;
-       ep->e_pgid = p->p_p->ps_pgrp->pg_id;
-       ep->e_jobc = p->p_p->ps_pgrp->pg_jobc;
-       if ((p->p_p->ps_flags & PS_CONTROLT) &&
-            (tp = ep->e_sess->s_ttyp)) {
-               ep->e_tdev = tp->t_dev;
-               ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
-               ep->e_tsess = tp->t_session;
-       } else
-               ep->e_tdev = NODEV;
-       ep->e_flag = ep->e_sess->s_ttyvp ? EPROC_CTTY : 0;
-       if (SESS_LEADER(p->p_p))
-               ep->e_flag |= EPROC_SLEADER;
-       strncpy(ep->e_wmesg, p->p_wmesg ? p->p_wmesg : "", WMESGLEN);
-       ep->e_wmesg[WMESGLEN] = '\0';
-       ep->e_xsize = ep->e_xrssize = 0;
-       ep->e_xccount = ep->e_xswrss = 0;
-       strncpy(ep->e_login, ep->e_sess->s_login, MAXLOGNAME-1);
-       ep->e_login[MAXLOGNAME-1] = '\0';
-       strncpy(ep->e_emul, p->p_emul->e_name, EMULNAMELEN);
-       ep->e_emul[EMULNAMELEN] = '\0';
-       ep->e_maxrss = p->p_rlimit ? p->p_rlimit[RLIMIT_RSS].rlim_cur : 0;
-       ep->e_limit = p->p_p->ps_limit;
 }
 
 /*
Index: include/kvm.h
===================================================================
RCS file: /cvs/src/include/kvm.h,v
retrieving revision 1.14
diff -u -p -r1.14 kvm.h
--- include/kvm.h       7 Jun 2009 03:09:34 -0000       1.14
+++ include/kvm.h       24 Oct 2010 07:21:02 -0000
@@ -53,23 +53,18 @@ __BEGIN_DECLS
 
 typedef struct __kvm kvm_t;
 
-struct kinfo_proc;
 struct kinfo_proc2;
 int      kvm_close(kvm_t *);
 int      kvm_dump_inval(kvm_t *);
 int      kvm_dump_mkheader(kvm_t *, off_t);
 int      kvm_dump_wrtheader(kvm_t *, FILE *, int);
-char   **kvm_getargv(kvm_t *, const struct kinfo_proc *, int);
 char   **kvm_getargv2(kvm_t *, const struct kinfo_proc2 *, int);
-char   **kvm_getenvv(kvm_t *, const struct kinfo_proc *, int);
 char   **kvm_getenvv2(kvm_t *, const struct kinfo_proc2 *, int);
 char    *kvm_geterr(kvm_t *);
 int      kvm_getloadavg(kvm_t *, double [], int);
 char    *kvm_getfiles(kvm_t *, int, int, int *);
 struct kinfo_file2 *
          kvm_getfile2(kvm_t *, int, int, size_t, int *);
-struct kinfo_proc *
-         kvm_getprocs(kvm_t *, int, int, int *);
 struct kinfo_proc2 *
          kvm_getproc2(kvm_t *, int, int, size_t, int *);
 int      kvm_nlist(kvm_t *, struct nlist *);
Index: lib/libkvm/Makefile
===================================================================
RCS file: /cvs/src/lib/libkvm/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- lib/libkvm/Makefile 3 Feb 2010 20:49:00 -0000       1.14
+++ lib/libkvm/Makefile 24 Oct 2010 07:02:19 -0000
@@ -24,11 +24,9 @@ SRCS+=       kvm.c kvm_file.c kvm_file2.c kvm_
        kvm_cd9660.c kvm_udf.c kvm_ntfs.c
 
 MAN=   kvm.3 kvm_dump.3 kvm_geterr.3 kvm_getfiles.3 kvm_getloadavg.3 \
-       kvm_getprocs.3 kvm_nlist.3 kvm_open.3 kvm_read.3
+       kvm_getproc2.3 kvm_nlist.3 kvm_open.3 kvm_read.3
 
-MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm_getprocs.3 kvm_getenvv.3
-MLINKS+=kvm_getprocs.3 kvm_getproc2.3
-MLINKS+=kvm_getprocs.3 kvm_getargv2.3 kvm_getprocs.3 kvm_getenvv2.3
+MLINKS+=kvm_getproc2.3 kvm_getargv2.3 kvm_getproc2.3 kvm_getenvv2.3
 MLINKS+=kvm_getfiles.3 kvm_getfile2.3
 MLINKS+=kvm_open.3 kvm_openfiles.3 kvm_open.3 kvm_close.3
 MLINKS+=kvm_read.3 kvm_write.3
Index: lib/libkvm/kvm.3
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm.3,v
retrieving revision 1.7
diff -u -p -r1.7 kvm.3
--- lib/libkvm/kvm.3    31 May 2007 19:19:35 -0000      1.7
+++ lib/libkvm/kvm.3    24 Oct 2010 07:02:19 -0000
@@ -67,7 +67,7 @@ interface to physical memory
 .Xr kvm_getenvv 3 ,
 .Xr kvm_geterr 3 ,
 .Xr kvm_getloadavg 3 ,
-.Xr kvm_getprocs 3 ,
+.Xr kvm_getproc2 3 ,
 .Xr kvm_nlist 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3 ,
Index: lib/libkvm/kvm.c
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm.c,v
retrieving revision 1.48
diff -u -p -r1.48 kvm.c
--- lib/libkvm/kvm.c    27 Oct 2009 23:59:28 -0000      1.48
+++ lib/libkvm/kvm.c    24 Oct 2010 07:02:20 -0000
@@ -177,7 +177,6 @@ _kvm_open(kvm_t *kd, const char *uf, con
        kd->nlfd = -1;
        kd->alive = 0;
        kd->filebase = 0;
-       kd->procbase = 0;
        kd->procbase2 = 0;
        kd->nbpg = getpagesize();
        kd->swapspc = 0;
@@ -636,8 +635,6 @@ kvm_close(kvm_t *kd)
                free((void *)kd->kcore_hdr);
        if (kd->filebase != 0)
                free((void *)kd->filebase);
-       if (kd->procbase != 0)
-               free((void *)kd->procbase);
        if (kd->procbase2 != 0)
                free(kd->procbase2);
        if (kd->swapspc != 0)
Index: lib/libkvm/kvm_geterr.3
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_geterr.3,v
retrieving revision 1.7
diff -u -p -r1.7 kvm_geterr.3
--- lib/libkvm/kvm_geterr.3     31 May 2007 19:19:35 -0000      1.7
+++ lib/libkvm/kvm_geterr.3     24 Oct 2010 07:02:20 -0000
@@ -57,9 +57,9 @@ so the message should be copied out and 
 .Sh SEE ALSO
 .Xr kvm 3 ,
 .Xr kvm_close 3 ,
-.Xr kvm_getargv 3 ,
-.Xr kvm_getenvv 3 ,
-.Xr kvm_getprocs 3 ,
+.Xr kvm_getargv2 3 ,
+.Xr kvm_getenvv2 3 ,
+.Xr kvm_getproc2 3 ,
 .Xr kvm_nlist 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3 ,
Index: lib/libkvm/kvm_getproc2.3
===================================================================
RCS file: lib/libkvm/kvm_getproc2.3
diff -N lib/libkvm/kvm_getproc2.3
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/libkvm/kvm_getproc2.3   24 Oct 2010 07:02:20 -0000
@@ -0,0 +1,196 @@
+.\"    $OpenBSD: kvm_getprocs.3,v 1.13 2007/05/31 19:19:35 jmc Exp $
+.\"    $NetBSD: kvm_getprocs.3,v 1.13 2003/08/07 16:44:37 agc Exp $
+.\"
+.\" Copyright (c) 1992, 1993
+.\"    The Regents of the University of California.  All rights reserved.
+.\"
+.\" This code is derived from software developed by the Computer Systems
+.\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
+.\" BG 91-66 and contributed to Berkeley.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)kvm_getproc2.3     8.1 (Berkeley) 6/4/93
+.\"
+.Dd $Mdocdate: May 31 2007 $
+.Dt KVM_GETPROC2 3
+.Os
+.Sh NAME
+.Nm kvm_getproc2 ,
+.Nm kvm_getargv2 ,
+.Nm kvm_getenvv2
+.Nd access user process state
+.Sh SYNOPSIS
+.Fd #include <sys/param.h>
+.Fd #include <sys/sysctl.h>
+.Fd #include <kvm.h>
+.Ft struct kinfo_proc2 *
+.Fn kvm_getproc2 "kvm_t *kd" "int op" "int arg" "size_t elemsize" "int *cnt"
+.Ft char **
+.Fn kvm_getargv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
+.Ft char **
+.Fn kvm_getenvv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
+.Sh DESCRIPTION
+.Fn kvm_getproc2
+returns a (sub-)set of active processes in the kernel indicated by
+.Fa kd .
+The
+.Fa op
+and
+.Fa arg
+arguments constitute a predicate which limits the set of processes returned.
+The value of
+.Fa op
+describes the filtering predicate as follows:
+.Pp
+.Bl -tag -width 20n -offset indent -compact
+.It Dv KERN_PROC_KTHREAD
+all processes (user-level plus kernel threads)
+.It Dv KERN_PROC_ALL
+all user-level processes
+.It Dv KERN_PROC_PID
+processes with process ID
+.Fa arg
+.It Dv KERN_PROC_PGRP
+processes with process group
+.Fa arg
+.It Dv KERN_PROC_SESSION
+processes with session
+.Fa arg
+.It Dv KERN_PROC_TTY
+processes with
+.Xr tty 4
+.Fa arg
+.It Dv KERN_PROC_UID
+processes with effective user ID
+.Fa arg
+.It Dv KERN_PROC_RUID
+processes with real user ID
+.Fa arg
+.El
+The
+.Fa elemsize
+argument specifies how large the
+.Vt kinfo_proc2
+structure expected by the caller is.
+If the size of that structure increases in size in a future release of
+.Ox ,
+the kernel will only return the requested amount of data for
+each array entry and programs that use
+.Fn kvm_getproc2
+will continue to function without the need for recompilation.
+.Pp
+The number of processes found is returned in the reference parameter
+.Fa cnt .
+The processes are returned as a contiguous array of
+.Vt kinfo_proc2
+structures, the definition for which is available in
+.Aq Pa sys/sysctl.h .
+This memory is locally allocated, and subsequent calls to
+.Fn kvm_getproc2
+and
+.Xr kvm_close 3
+will overwrite this storage.
+.Pp
+.Fn kvm_getargv2
+returns a null-terminated argument vector that corresponds to the
+command line arguments passed to process indicated by
+.Fa p .
+Most likely, these arguments correspond to the values passed to
+.Xr exec 3
+on process creation.
+This information is, however,
+deliberately under control of the process itself.
+Note that the original command name can be found, unaltered,
+in the
+.Va p_comm
+field of the process structure returned by
+.Fn kvm_getproc2 .
+.Pp
+The
+.Fa nchr
+argument indicates the maximum number of characters, including null bytes,
+to use in building the strings.
+If this amount is exceeded, the string
+causing the overflow is truncated and the partial result is returned.
+This is handy for programs like
+.Xr ps 1
+and
+.Xr w 1
+that print only a one line summary of a command and should not copy
+out large amounts of text only to ignore it.
+If
+.Fa nchr
+is zero, no limit is imposed and all argument strings are returned in
+their entirety.
+.Pp
+The memory allocated to the
+.Li argv
+pointers and string storage is owned by the
+.Xr kvm 3
+library.
+Subsequent
+.Fn kvm_getproc2
+and
+.Xr kvm_close 3
+calls will clobber this storage.
+.Pp
+The
+.Fn kvm_getenvv2
+function is similar to
+.Fn kvm_getargv2
+but returns the vector of environment strings.
+This data is also alterable by the process.
+.Sh RETURN VALUES
+.Fn kvm_getproc2 ,
+.Fn kvm_getargv2 ,
+and
+.Fn kvm_getenvv2
+all return
+.Dv NULL
+on failure.
+.Sh SEE ALSO
+.Xr kvm 3 ,
+.Xr kvm_close 3 ,
+.Xr kvm_geterr 3 ,
+.Xr kvm_nlist 3 ,
+.Xr kvm_open 3 ,
+.Xr kvm_openfiles 3 ,
+.Xr kvm_read 3 ,
+.Xr kvm_write 3
+.Sh HISTORY
+These routines where designed as replacements for the defunct
+.Fn kvm_getprocs ,
+.Fn kvm_getargv ,
+and
+.Fn kvm_getenvv
+functions.
+Those functions used the kernel's own structures in their interfaces,
+so their ABIs changed whenever those structures changed in the
+kernel.
+.Sh BUGS
+These routines do not belong in the
+.Xr kvm 3
+interface.
Index: lib/libkvm/kvm_getprocs.3
===================================================================
RCS file: lib/libkvm/kvm_getprocs.3
diff -N lib/libkvm/kvm_getprocs.3
--- lib/libkvm/kvm_getprocs.3   31 May 2007 19:19:35 -0000      1.13
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,217 +0,0 @@
-.\"    $OpenBSD: kvm_getprocs.3,v 1.13 2007/05/31 19:19:35 jmc Exp $
-.\"    $NetBSD: kvm_getprocs.3,v 1.13 2003/08/07 16:44:37 agc Exp $
-.\"
-.\" Copyright (c) 1992, 1993
-.\"    The Regents of the University of California.  All rights reserved.
-.\"
-.\" This code is derived from software developed by the Computer Systems
-.\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
-.\" BG 91-66 and contributed to Berkeley.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     @(#)kvm_getprocs.3     8.1 (Berkeley) 6/4/93
-.\"
-.Dd $Mdocdate: May 31 2007 $
-.Dt KVM_GETPROCS 3
-.Os
-.Sh NAME
-.Nm kvm_getprocs ,
-.Nm kvm_getargv ,
-.Nm kvm_getenvv ,
-.Nm kvm_getproc2 ,
-.Nm kvm_getargv2 ,
-.Nm kvm_getenvv2
-.Nd access user process state
-.Sh SYNOPSIS
-.Fd #include <sys/param.h>
-.Fd #include <sys/sysctl.h>
-.Fd #include <kvm.h>
-.Ft struct kinfo_proc *
-.Fn kvm_getprocs "kvm_t *kd" "int op" "int arg" "int *cnt"
-.Ft char **
-.Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
-.Ft char **
-.Fn kvm_getenvv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
-.Ft struct kinfo_proc2 *
-.Fn kvm_getproc2 "kvm_t *kd" "int op" "int arg" "size_t elemsize" "int *cnt"
-.Ft char **
-.Fn kvm_getargv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
-.Ft char **
-.Fn kvm_getenvv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
-.Sh DESCRIPTION
-.Fn kvm_getprocs
-returns a (sub-)set of active processes in the kernel indicated by
-.Fa kd .
-The
-.Fa op
-and
-.Fa arg
-arguments constitute a predicate which limits the set of processes returned.
-The value of
-.Fa op
-describes the filtering predicate as follows:
-.Pp
-.Bl -tag -width 20n -offset indent -compact
-.It Dv KERN_PROC_KTHREAD
-all processes (user-level plus kernel threads)
-.It Dv KERN_PROC_ALL
-all user-level processes
-.It Dv KERN_PROC_PID
-processes with process ID
-.Fa arg
-.It Dv KERN_PROC_PGRP
-processes with process group
-.Fa arg
-.It Dv KERN_PROC_SESSION
-processes with session
-.Fa arg
-.It Dv KERN_PROC_TTY
-processes with
-.Xr tty 4
-.Fa arg
-.It Dv KERN_PROC_UID
-processes with effective user ID
-.Fa arg
-.It Dv KERN_PROC_RUID
-processes with real user ID
-.Fa arg
-.El
-.Pp
-The number of processes found is returned in the reference parameter
-.Fa cnt .
-The processes are returned as a contiguous array of
-.Vt kinfo_proc
-structures, the definition for which is available in
-.Aq Pa sys/sysctl.h .
-This memory is locally allocated, and subsequent calls to
-.Fn kvm_getprocs
-and
-.Fn kvm_close
-will overwrite this storage.
-.Pp
-.Fn kvm_getargv
-returns a null-terminated argument vector that corresponds to the
-command line arguments passed to process indicated by
-.Fa p .
-Most likely, these arguments correspond to the values passed to
-.Xr exec 3
-on process creation.
-This information is, however,
-deliberately under control of the process itself.
-Note that the original command name can be found, unaltered,
-in the
-.Va p_comm
-field of the process structure returned by
-.Fn kvm_getprocs .
-.Pp
-The
-.Fa nchr
-argument indicates the maximum number of characters, including null bytes,
-to use in building the strings.
-If this amount is exceeded, the string
-causing the overflow is truncated and the partial result is returned.
-This is handy for programs like
-.Xr ps 1
-and
-.Xr w 1
-that print only a one line summary of a command and should not copy
-out large amounts of text only to ignore it.
-If
-.Fa nchr
-is zero, no limit is imposed and all argument strings are returned in
-their entirety.
-.Pp
-The memory allocated to the
-.Li argv
-pointers and string storage is owned by the
-.Xr kvm 3
-library.
-Subsequent
-.Fn kvm_getprocs
-and
-.Xr kvm_close 3
-calls will clobber this storage.
-.Pp
-The
-.Fn kvm_getenvv
-function is similar to
-.Fn kvm_getargv
-but returns the vector of environment strings.
-This data is also alterable by the process.
-.Pp
-.Fn kvm_getproc2
-is similar to
-.Fn kvm_getprocs
-but returns an array of
-.Vt kinfo_proc2
-structures.
-Additionally, only the first
-.Fa elemsize
-bytes of each array entry are returned.
-If the size of the
-.Vt kinfo_proc2
-structure increases in size in a future release of
-.Ox ,
-the kernel will only return the requested amount of data for
-each array entry and programs that use
-.Fn kvm_getproc2
-will continue to function without the need for recompilation.
-.Pp
-The
-.Fn kvm_getargv2
-and
-.Fn kvm_getenvv2
-functions are equivalents to the
-.Fn kvm_getargv
-and
-.Fn kvm_getenvv
-functions that use a
-.Vt kinfo_proc2
-structure to specify the process.
-.Sh RETURN VALUES
-.Fn kvm_getprocs ,
-.Fn kvm_getargv ,
-.Fn kvm_getenvv ,
-.Fn kvm_getproc2 ,
-.Fn kvm_getargv2 ,
-and
-.Fn kvm_getenvv2
-all return
-.Dv NULL
-on failure.
-.Sh SEE ALSO
-.Xr kvm 3 ,
-.Xr kvm_close 3 ,
-.Xr kvm_geterr 3 ,
-.Xr kvm_nlist 3 ,
-.Xr kvm_open 3 ,
-.Xr kvm_openfiles 3 ,
-.Xr kvm_read 3 ,
-.Xr kvm_write 3
-.Sh BUGS
-These routines do not belong in the
-.Xr kvm 3
-interface.
Index: lib/libkvm/kvm_nlist.3
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_nlist.3,v
retrieving revision 1.8
diff -u -p -r1.8 kvm_nlist.3
--- lib/libkvm/kvm_nlist.3      31 May 2007 19:19:35 -0000      1.8
+++ lib/libkvm/kvm_nlist.3      24 Oct 2010 07:02:20 -0000
@@ -85,10 +85,10 @@ If the kernel symbol table was unreadabl
 .Sh SEE ALSO
 .Xr kvm 3 ,
 .Xr kvm_close 3 ,
-.Xr kvm_getargv 3 ,
-.Xr kvm_getenvv 3 ,
+.Xr kvm_getargv2 3 ,
+.Xr kvm_getenvv2 3 ,
 .Xr kvm_geterr 3 ,
-.Xr kvm_getprocs 3 ,
+.Xr kvm_getproc2 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3 ,
 .Xr kvm_read 3 ,
Index: lib/libkvm/kvm_open.3
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_open.3,v
retrieving revision 1.13
diff -u -p -r1.13 kvm_open.3
--- lib/libkvm/kvm_open.3       21 Jan 2009 22:18:00 -0000      1.13
+++ lib/libkvm/kvm_open.3       24 Oct 2010 07:02:21 -0000
@@ -188,10 +188,10 @@ function returns 0 on success and \-1 on
 .Sh SEE ALSO
 .Xr open 2 ,
 .Xr kvm 3 ,
-.Xr kvm_getargv 3 ,
-.Xr kvm_getenvv 3 ,
+.Xr kvm_getargv2 3 ,
+.Xr kvm_getenvv2 3 ,
 .Xr kvm_geterr 3 ,
-.Xr kvm_getprocs 3 ,
+.Xr kvm_getproc2 3 ,
 .Xr kvm_nlist 3 ,
 .Xr kvm_read 3 ,
 .Xr kvm_write 3
Index: lib/libkvm/kvm_private.h
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_private.h,v
retrieving revision 1.16
diff -u -p -r1.16 kvm_private.h
--- lib/libkvm/kvm_private.h    12 Jan 2010 08:15:51 -0000      1.16
+++ lib/libkvm/kvm_private.h    24 Oct 2010 07:02:21 -0000
@@ -49,7 +49,6 @@ struct __kvm {
        int     vmfd;           /* virtual memory file (-1 if crashdump) */
        int     swfd;           /* swap file (e.g., /dev/drum) */
        int     nlfd;           /* namelist file (e.g., /vmunix) */
-       struct kinfo_proc *procbase;
        struct kinfo_proc2 *procbase2;
        struct kinfo_file *filebase;
        int     nbpg;           /* page size */
@@ -93,7 +92,6 @@ struct __kvm {
  */
 void    _kvm_err(kvm_t *kd, const char *program, const char *fmt, ...);
 int     _kvm_dump_mkheader(kvm_t *kd_live, kvm_t *kd_dump);
-void    _kvm_freeprocs(kvm_t *kd);
 void    _kvm_freevtop(kvm_t *);
 int     _kvm_initvtop(kvm_t *);
 int     _kvm_kvatop(kvm_t *, u_long, paddr_t *);
Index: lib/libkvm/kvm_proc.c
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_proc.c,v
retrieving revision 1.41
diff -u -p -r1.41 kvm_proc.c
--- lib/libkvm/kvm_proc.c       26 Jul 2010 01:56:27 -0000      1.41
+++ lib/libkvm/kvm_proc.c       24 Oct 2010 07:02:21 -0000
@@ -69,7 +69,6 @@
  * most other applications are interested only in open/close/read/nlist).
  */
 
-#define __need_process
 #include <sys/param.h>
 #include <sys/user.h>
 #include <sys/proc.h>
@@ -107,24 +106,8 @@ struct miniproc {
 };
 
 /*
- * Convert from struct proc and kinfo_proc{,2} to miniproc.
+ * Convert from struct kinfo_proc2 to miniproc.
  */
-#define PTOMINI(kp, p) \
-       do { \
-               (p)->p_stat = (kp)->p_stat; \
-               (p)->p_pid = (kp)->p_pid; \
-               (p)->p_paddr = NULL; \
-               (p)->p_vmspace = (kp)->p_vmspace; \
-       } while (/*CONSTCOND*/0);
-
-#define KPTOMINI(kp, p) \
-       do { \
-               (p)->p_stat = (kp)->kp_proc.p_stat; \
-               (p)->p_pid = (kp)->kp_proc.p_pid; \
-               (p)->p_paddr = (kp)->kp_eproc.e_paddr; \
-               (p)->p_vmspace = (kp)->kp_proc.p_vmspace; \
-       } while (/*CONSTCOND*/0);
-
 #define KP2TOMINI(kp, p) \
        do { \
                (p)->p_stat = (kp)->p_stat; \
@@ -134,18 +117,13 @@ struct miniproc {
        } while (/*CONSTCOND*/0);
 
 
-ssize_t                kvm_uread(kvm_t *, const struct proc *, u_long, char *, 
size_t);
-
 static char    *_kvm_ureadm(kvm_t *, const struct miniproc *, u_long, u_long 
*);
 static ssize_t kvm_ureadm(kvm_t *, const struct miniproc *, u_long, char *, 
size_t);
 
 static char    **kvm_argv(kvm_t *, const struct miniproc *, u_long, int, int);
 
-static int     kvm_deadprocs(kvm_t *, int, int, u_long, u_long, int);
 static char    **kvm_doargv(kvm_t *, const struct miniproc *, int,
                    void (*)(struct ps_strings *, u_long *, int *));
-static int     kvm_proclist(kvm_t *, int, int, struct proc *,
-                   struct kinfo_proc *, int);
 static int     proc_verify(kvm_t *, const struct miniproc *);
 static void    ps_str_a(struct ps_strings *, u_long *, int *);
 static void    ps_str_e(struct ps_strings *, u_long *, int *);
@@ -231,261 +209,6 @@ _kvm_ureadm(kvm_t *kd, const struct mini
        return (&kd->swapspc[offset]);
 }
 
-char *
-_kvm_uread(kvm_t *kd, const struct proc *p, u_long va, u_long *cnt)
-{
-       struct miniproc mp;
-
-       PTOMINI(p, &mp);
-       return (_kvm_ureadm(kd, &mp, va, cnt));
-}
-
-/*
- * Read proc's from memory file into buffer bp, which has space to hold
- * at most maxcnt procs.
- */
-static int
-kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
-    struct kinfo_proc *bp, int maxcnt)
-{
-       struct session sess;
-       struct eproc eproc;
-       struct proc proc;
-       struct process process;
-       struct pgrp pgrp;
-       struct tty tty;
-       int cnt = 0;
-
-       for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) {
-               if (KREAD(kd, (u_long)p, &proc)) {
-                       _kvm_err(kd, kd->program, "can't read proc at %x", p);
-                       return (-1);
-               }
-               if (KREAD(kd, (u_long)proc.p_p, &process)) {
-                       _kvm_err(kd, kd->program, "can't read process at %x", 
proc.p_p);
-                       return (-1);
-               }
-               if (KREAD(kd, (u_long)process.ps_cred, &eproc.e_pcred) == 0)
-                       KREAD(kd, (u_long)eproc.e_pcred.pc_ucred,
-                           &eproc.e_ucred);
-
-               switch (what) {
-               case KERN_PROC_PID:
-                       if (proc.p_pid != (pid_t)arg)
-                               continue;
-                       break;
-
-               case KERN_PROC_UID:
-                       if (eproc.e_ucred.cr_uid != (uid_t)arg)
-                               continue;
-                       break;
-
-               case KERN_PROC_RUID:
-                       if (eproc.e_pcred.p_ruid != (uid_t)arg)
-                               continue;
-                       break;
-
-               case KERN_PROC_ALL:
-                       if (proc.p_flag & P_SYSTEM)
-                               continue;
-                       break;
-               }
-               /*
-                * We're going to add another proc to the set.  If this
-                * will overflow the buffer, assume the reason is because
-                * nprocs (or the proc list) is corrupt and declare an error.
-                */
-               if (cnt >= maxcnt) {
-                       _kvm_err(kd, kd->program, "nprocs corrupt");
-                       return (-1);
-               }
-               /*
-                * gather eproc
-                */
-               eproc.e_paddr = p;
-               if (KREAD(kd, (u_long)process.ps_pgrp, &pgrp)) {
-                       _kvm_err(kd, kd->program, "can't read pgrp at %x",
-                           process.ps_pgrp);
-                       return (-1);
-               }
-               eproc.e_sess = pgrp.pg_session;
-               eproc.e_pgid = pgrp.pg_id;
-               eproc.e_jobc = pgrp.pg_jobc;
-               if (KREAD(kd, (u_long)pgrp.pg_session, &sess)) {
-                       _kvm_err(kd, kd->program, "can't read session at %x",
-                           pgrp.pg_session);
-                       return (-1);
-               }
-               if ((process.ps_flags & PS_CONTROLT) && sess.s_ttyp != NULL) {
-                       if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) {
-                               _kvm_err(kd, kd->program,
-                                   "can't read tty at %x", sess.s_ttyp);
-                               return (-1);
-                       }
-                       eproc.e_tdev = tty.t_dev;
-                       eproc.e_tsess = tty.t_session;
-                       if (tty.t_pgrp != NULL) {
-                               if (KREAD(kd, (u_long)tty.t_pgrp, &pgrp)) {
-                                       _kvm_err(kd, kd->program,
-                                           "can't read tpgrp at &x",
-                                           tty.t_pgrp);
-                                       return (-1);
-                               }
-                               eproc.e_tpgid = pgrp.pg_id;
-                       } else
-                               eproc.e_tpgid = -1;
-               } else
-                       eproc.e_tdev = NODEV;
-               eproc.e_flag = sess.s_ttyvp ? EPROC_CTTY : 0;
-               if (sess.s_leader == proc.p_p)
-                       eproc.e_flag |= EPROC_SLEADER;
-               if (proc.p_wmesg)
-                       (void)kvm_read(kd, (u_long)proc.p_wmesg,
-                           eproc.e_wmesg, WMESGLEN);
-
-               (void)kvm_read(kd, (u_long)proc.p_vmspace,
-                   &eproc.e_vm, sizeof(eproc.e_vm));
-
-               eproc.e_xsize = eproc.e_xrssize = 0;
-               eproc.e_xccount = eproc.e_xswrss = 0;
-
-               switch (what) {
-               case KERN_PROC_PGRP:
-                       if (eproc.e_pgid != (pid_t)arg)
-                               continue;
-                       break;
-
-               case KERN_PROC_TTY:
-                       if ((process.ps_flags & PS_CONTROLT) == 0 ||
-                           eproc.e_tdev != (dev_t)arg)
-                               continue;
-                       break;
-               }
-               proc.p_flag |= process.ps_flags;
-               bcopy(&proc, &bp->kp_proc, sizeof(proc));
-               bcopy(&eproc, &bp->kp_eproc, sizeof(eproc));
-               ++bp;
-               ++cnt;
-       }
-       return (cnt);
-}
-
-/*
- * Build proc info array by reading in proc list from a crash dump.
- * Return number of procs read.  maxcnt is the max we will read.
- */
-static int
-kvm_deadprocs(kvm_t *kd, int what, int arg, u_long a_allproc,
-    u_long a_zombproc, int maxcnt)
-{
-       struct kinfo_proc *bp = kd->procbase;
-       struct proc *p;
-       int acnt, zcnt;
-
-       if (KREAD(kd, a_allproc, &p)) {
-               _kvm_err(kd, kd->program, "cannot read allproc");
-               return (-1);
-       }
-       acnt = kvm_proclist(kd, what, arg, p, bp, maxcnt);
-       if (acnt < 0)
-               return (acnt);
-
-       if (KREAD(kd, a_zombproc, &p)) {
-               _kvm_err(kd, kd->program, "cannot read zombproc");
-               return (-1);
-       }
-       zcnt = kvm_proclist(kd, what, arg, p, bp + acnt, maxcnt - acnt);
-       if (zcnt < 0)
-               zcnt = 0;
-
-       return (acnt + zcnt);
-}
-
-struct kinfo_proc *
-kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
-{
-       int mib[4], st, nprocs;
-       size_t size;
-
-       if (kd->procbase != 0) {
-               free((void *)kd->procbase);
-               /*
-                * Clear this pointer in case this call fails.  Otherwise,
-                * kvm_close() will free it again.
-                */
-               kd->procbase = 0;
-       }
-       if (ISALIVE(kd)) {
-               size = 0;
-               mib[0] = CTL_KERN;
-               mib[1] = KERN_PROC;
-               mib[2] = op;
-               mib[3] = arg;
-               st = sysctl(mib, 4, NULL, &size, NULL, 0);
-               if (st == -1) {
-                       _kvm_syserr(kd, kd->program, "kvm_getprocs");
-                       return (0);
-               }
-               kd->procbase = _kvm_malloc(kd, size);
-               if (kd->procbase == 0)
-                       return (0);
-               st = sysctl(mib, 4, kd->procbase, &size, NULL, 0);
-               if (st == -1) {
-                       _kvm_syserr(kd, kd->program, "kvm_getprocs");
-                       return (0);
-               }
-               if (size % sizeof(struct kinfo_proc) != 0) {
-                       _kvm_err(kd, kd->program,
-                           "proc size mismatch (%d total, %d chunks)",
-                           size, sizeof(struct kinfo_proc));
-                       return (0);
-               }
-               nprocs = size / sizeof(struct kinfo_proc);
-       } else {
-               struct nlist nl[4], *p;
-
-               memset(nl, 0, sizeof(nl));
-               nl[0].n_name = "_nprocs";
-               nl[1].n_name = "_allproc";
-               nl[2].n_name = "_zombproc";
-               nl[3].n_name = NULL;
-
-               if (kvm_nlist(kd, nl) != 0) {
-                       for (p = nl; p->n_type != 0; ++p)
-                               ;
-                       _kvm_err(kd, kd->program,
-                           "%s: no such symbol", p->n_name);
-                       return (0);
-               }
-               if (KREAD(kd, nl[0].n_value, &nprocs)) {
-                       _kvm_err(kd, kd->program, "can't read nprocs");
-                       return (0);
-               }
-               size = nprocs * sizeof(struct kinfo_proc);
-               kd->procbase = _kvm_malloc(kd, size);
-               if (kd->procbase == 0)
-                       return (0);
-
-               nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value,
-                   nl[2].n_value, nprocs);
-#ifdef notdef
-               size = nprocs * sizeof(struct kinfo_proc);
-               (void)realloc(kd->procbase, size);
-#endif
-       }
-       *cnt = nprocs;
-       return (kd->procbase);
-}
-
-void
-_kvm_freeprocs(kvm_t *kd)
-{
-       if (kd->procbase) {
-               free(kd->procbase);
-               kd->procbase = 0;
-       }
-}
-
 void *
 _kvm_realloc(kvm_t *kd, void *p, size_t n)
 {
@@ -511,7 +234,7 @@ kvm_argv(kvm_t *kd, const struct minipro
        int len, cc;
 
        /*
-        * Check that there aren't an unreasonable number of agruments,
+        * Check that there aren't an unreasonable number of arguments,
         * and that the address is in user space.
         */
        if (narg > ARG_MAX || addr < VM_MIN_ADDRESS || addr >= 
VM_MAXUSER_ADDRESS)
@@ -740,28 +463,6 @@ again:
  * Get the command args.  This code is now machine independent.
  */
 char **
-kvm_getargv(kvm_t *kd, const struct kinfo_proc *kp, int nchr)
-{
-       struct miniproc p;
-
-       if (ISALIVE(kd))
-               return (kvm_arg_sysctl(kd, kp->kp_proc.p_pid, nchr, 0));
-       KPTOMINI(kp, &p);
-       return (kvm_doargv(kd, &p, nchr, ps_str_a));
-}
-
-char **
-kvm_getenvv(kvm_t *kd, const struct kinfo_proc *kp, int nchr)
-{
-       struct miniproc p;
-
-       if (ISALIVE(kd))
-               return (kvm_arg_sysctl(kd, kp->kp_proc.p_pid, nchr, 1));
-       KPTOMINI(kp, &p);
-       return (kvm_doargv(kd, &p, nchr, ps_str_e));
-}
-
-char **
 kvm_getargv2(kvm_t *kd, const struct kinfo_proc2 *kp, int nchr)
 {
        struct miniproc p;
@@ -809,14 +510,4 @@ kvm_ureadm(kvm_t *kd, const struct minip
                len -= cc;
        }
        return (ssize_t)(cp - buf);
-}
-
-ssize_t
-kvm_uread(kvm_t *kd, const struct proc *p, u_long uva, char *buf,
-    size_t len)
-{
-       struct miniproc mp;
-
-       PTOMINI(p, &mp);
-       return (kvm_ureadm(kd, &mp, uva, buf, len));
 }
Index: lib/libkvm/kvm_read.3
===================================================================
RCS file: /cvs/src/lib/libkvm/kvm_read.3,v
retrieving revision 1.7
diff -u -p -r1.7 kvm_read.3
--- lib/libkvm/kvm_read.3       31 May 2007 19:19:35 -0000      1.7
+++ lib/libkvm/kvm_read.3       24 Oct 2010 07:02:21 -0000
@@ -84,10 +84,10 @@ Otherwise, \-1 is returned.
 .Sh SEE ALSO
 .Xr kvm 3 ,
 .Xr kvm_close 3 ,
-.Xr kvm_getargv 3 ,
-.Xr kvm_getenvv 3 ,
+.Xr kvm_getargv2 3 ,
+.Xr kvm_getenvv2 3 ,
 .Xr kvm_geterr 3 ,
-.Xr kvm_getprocs 3 ,
+.Xr kvm_getproc2 3 ,
 .Xr kvm_nlist 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3
Index: lib/libkvm/shlib_version
===================================================================
RCS file: /cvs/src/lib/libkvm/shlib_version,v
retrieving revision 1.9
diff -u -p -r1.9 shlib_version
--- lib/libkvm/shlib_version    7 Jun 2009 03:09:34 -0000       1.9
+++ lib/libkvm/shlib_version    24 Oct 2010 07:02:21 -0000
@@ -1,2 +1,2 @@
-major=9
-minor=1
+major=10
+minor=0
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.173
diff -u -p -r1.173 sysctl.c
--- sbin/sysctl/sysctl.c        19 Aug 2010 18:14:14 -0000      1.173
+++ sbin/sysctl/sysctl.c        24 Oct 2010 07:02:23 -0000
@@ -391,7 +392,6 @@ parse(char *string, int flags)
                                return;
                        warnx("use pstat to view %s information", string);
                        return;
-               case KERN_PROC:
                case KERN_PROC2:
                        if (flags == 0)
                                return;

Reply via email to