summaryrefslogtreecommitdiffstats
path: root/lib/libkvm
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-10-22 16:40:25 +0000
committerguenther <guenther@openbsd.org>2013-10-22 16:40:25 +0000
commitcef0bbe1cc5517635356b7faa348b466660ec603 (patch)
tree8a975e0739a2b36fd5200d33c430980754b92498 /lib/libkvm
parent- expand hardware list with iMX boards (diff)
downloadwireguard-openbsd-cef0bbe1cc5517635356b7faa348b466660ec603.tar.xz
wireguard-openbsd-cef0bbe1cc5517635356b7faa348b466660ec603.zip
- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that - delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major) - rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file and KERN_FILE2 to KERN_FILE. ok deraadt@, millert@ ports scan sthen@
Diffstat (limited to 'lib/libkvm')
-rw-r--r--lib/libkvm/Makefile5
-rw-r--r--lib/libkvm/kvm_cd9660.c4
-rw-r--r--lib/libkvm/kvm_file.c176
-rw-r--r--lib/libkvm/kvm_file2.c102
-rw-r--r--lib/libkvm/kvm_getfiles.365
-rw-r--r--lib/libkvm/kvm_ntfs.c4
-rw-r--r--lib/libkvm/kvm_private.h8
-rw-r--r--lib/libkvm/kvm_udf.c4
-rw-r--r--lib/libkvm/shlib_version2
9 files changed, 97 insertions, 273 deletions
diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile
index 7a4fd78d2fa..d8e5d4ac878 100644
--- a/lib/libkvm/Makefile
+++ b/lib/libkvm/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.16 2012/08/02 13:38:38 okan Exp $
+# $OpenBSD: Makefile,v 1.17 2013/10/22 16:40:26 guenther Exp $
# $NetBSD: Makefile,v 1.11 1996/03/18 22:33:07 thorpej Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
@@ -19,14 +19,13 @@ SRCS= kvm_${MACHINE_CPU}.c
.endif
CFLAGS+= -D_LIBKVM
-SRCS+= kvm.c kvm_file.c kvm_file2.c kvm_getloadavg.c kvm_proc.c kvm_proc2.c \
+SRCS+= kvm.c kvm_file2.c kvm_getloadavg.c kvm_proc.c kvm_proc2.c \
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
MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm_getprocs.3 kvm_getenvv.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
MLINKS+=kvm_dump.3 kvm_dump_mkheader.3 kvm_dump.3 kvm_dump_wrtheader.3
diff --git a/lib/libkvm/kvm_cd9660.c b/lib/libkvm/kvm_cd9660.c
index 27a8d823458..18218f3363c 100644
--- a/lib/libkvm/kvm_cd9660.c
+++ b/lib/libkvm/kvm_cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_cd9660.c,v 1.3 2009/10/27 23:59:28 deraadt Exp $ */
+/* $OpenBSD: kvm_cd9660.c,v 1.4 2013/10/22 16:40:26 guenther Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -35,7 +35,7 @@
#include "kvm_private.h"
int
-_kvm_stat_cd9660(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+_kvm_stat_cd9660(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct iso_node inode;
diff --git a/lib/libkvm/kvm_file.c b/lib/libkvm/kvm_file.c
deleted file mode 100644
index b0b520bcdc5..00000000000
--- a/lib/libkvm/kvm_file.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/* $OpenBSD: kvm_file.c,v 1.16 2009/10/27 23:59:28 deraadt Exp $ */
-/* $NetBSD: kvm_file.c,v 1.5 1996/03/18 22:33:18 thorpej Exp $ */
-
-/*-
- * Copyright (c) 1989, 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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.
- */
-
-/*
- * File list interface for kvm. pstat, fstat and netstat are
- * users of this code, so we've factored it out into a separate module.
- * Thus, we keep this grunge out of the other kvm applications (i.e.,
- * most other applications are interested only in open/close/read/nlist).
- */
-
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/proc.h>
-#include <sys/exec.h>
-#define _KERNEL
-#include <sys/file.h>
-#undef _KERNEL
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/tty.h>
-#include <nlist.h>
-#include <kvm.h>
-
-#include <sys/sysctl.h>
-
-#include <limits.h>
-#include <db.h>
-#include <paths.h>
-
-#include "kvm_private.h"
-
-static int kvm_deadfiles(kvm_t *kd, int op, int arg, long filehead_o,
- int nfiles);
-
-/*
- * Get file structures.
- */
-static int
-kvm_deadfiles(kvm_t *kd, int op, int arg, long filehead_o, int kvm_nfiles)
-{
- int buflen = kd->arglen, n = 0;
- char *where = kd->argspc;
- struct file *fp;
- struct filelist kvm_filehead;
-
- /*
- * first copyout filehead
- */
- if (buflen > sizeof (kvm_filehead)) {
- if (KREAD(kd, filehead_o, &kvm_filehead)) {
- _kvm_err(kd, kd->program, "can't read filehead");
- return (0);
- }
- buflen -= sizeof(kvm_filehead);
- where += sizeof(kvm_filehead);
- *(struct filelist *)kd->argspc = kvm_filehead;
- }
- /*
- * followed by an array of file structures
- */
- LIST_FOREACH(fp, &kvm_filehead, f_list) {
- if (buflen > sizeof (struct file)) {
- if (KREAD(kd, (long)fp, ((struct file *)where))) {
- _kvm_err(kd, kd->program, "can't read kfp");
- return (0);
- }
- buflen -= sizeof (struct file);
- fp = (struct file *)where;
- where += sizeof (struct file);
- n++;
- }
- }
- if (n != kvm_nfiles) {
- _kvm_err(kd, kd->program, "inconsistent nfiles");
- return (0);
- }
- return (kvm_nfiles);
-}
-
-char *
-kvm_getfiles(kvm_t *kd, int op, int arg, int *cnt)
-{
- struct filelist kvm_filehead;
- struct file *fp, *fplim;
- int mib[2], st, kvm_nfiles;
- size_t size;
-
- if (ISALIVE(kd)) {
- size = 0;
- mib[0] = CTL_KERN;
- mib[1] = KERN_FILE;
- st = sysctl(mib, 2, NULL, &size, NULL, 0);
- if (st == -1) {
- _kvm_syserr(kd, kd->program, "kvm_getfiles");
- return (0);
- }
- if (kd->argspc == 0)
- kd->argspc = (char *)_kvm_malloc(kd, size);
- else if (kd->arglen < size)
- kd->argspc = (char *)_kvm_realloc(kd, kd->argspc, size);
- if (kd->argspc == 0)
- return (0);
- kd->arglen = size;
- st = sysctl(mib, 2, kd->argspc, &size, NULL, 0);
- if (st == -1 || size < sizeof(kvm_filehead)) {
- _kvm_syserr(kd, kd->program, "kvm_getfiles");
- return (0);
- }
- kvm_filehead = *(struct filelist *)kd->argspc;
- fp = (struct file *)(kd->argspc + sizeof(kvm_filehead));
- fplim = (struct file *)(kd->argspc + size);
- for (kvm_nfiles = 0; LIST_FIRST(&kvm_filehead) && (fp < fplim);
- kvm_nfiles++, fp++)
- LIST_FIRST(&kvm_filehead) = LIST_NEXT(fp, f_list);
- } else {
- struct nlist nl[3], *p;
-
- nl[0].n_name = "_filehead";
- nl[1].n_name = "_nfiles";
- nl[2].n_name = 0;
-
- 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, &kvm_nfiles)) {
- _kvm_err(kd, kd->program, "can't read nfiles");
- return (0);
- }
- size = sizeof(kvm_filehead) + (kvm_nfiles + 10) * sizeof(struct file);
- if (kd->argspc == 0)
- kd->argspc = (char *)_kvm_malloc(kd, size);
- else if (kd->arglen < size)
- kd->argspc = (char *)_kvm_realloc(kd, kd->argspc, size);
- if (kd->argspc == 0)
- return (0);
- kd->arglen = size;
- kvm_nfiles = kvm_deadfiles(kd, op, arg, nl[1].n_value, kvm_nfiles);
- if (kvm_nfiles == 0)
- return (0);
- }
- *cnt = kvm_nfiles;
- return (kd->argspc);
-}
diff --git a/lib/libkvm/kvm_file2.c b/lib/libkvm/kvm_file2.c
index 5a5eb9efeb0..eef2c41ce32 100644
--- a/lib/libkvm/kvm_file2.c
+++ b/lib/libkvm/kvm_file2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_file2.c,v 1.27 2013/03/20 14:46:45 deraadt Exp $ */
+/* $OpenBSD: kvm_file2.c,v 1.28 2013/10/22 16:40:26 guenther Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -70,8 +70,10 @@
#include <sys/protosw.h>
#include <sys/event.h>
#include <sys/eventvar.h>
+#include <sys/un.h>
#include <sys/unpcb.h>
#include <sys/filedesc.h>
+#include <sys/mbuf.h>
#include <sys/pipe.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
@@ -105,6 +107,7 @@
#include <nlist.h>
#include <kvm.h>
#include <db.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
@@ -112,18 +115,18 @@
#include "kvm_private.h"
-static struct kinfo_file2 *kvm_deadfile2_byfile(kvm_t *, int, int,
+static struct kinfo_file *kvm_deadfile_byfile(kvm_t *, int, int,
size_t, int *);
-static struct kinfo_file2 *kvm_deadfile2_byid(kvm_t *, int, int,
+static struct kinfo_file *kvm_deadfile_byid(kvm_t *, int, int,
size_t, int *);
-static int fill_file2(kvm_t *, struct kinfo_file2 *, struct file *, u_long,
+static int fill_file(kvm_t *, struct kinfo_file *, struct file *, u_long,
struct vnode *, struct proc *, int, pid_t);
-static int filestat(kvm_t *, struct kinfo_file2 *, struct vnode *);
+static int filestat(kvm_t *, struct kinfo_file *, struct vnode *);
LIST_HEAD(proclist, proc);
-struct kinfo_file2 *
-kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
+struct kinfo_file *
+kvm_getfiles(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
{
int mib[6], rv;
size_t size;
@@ -139,7 +142,7 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (ISALIVE(kd)) {
mib[0] = CTL_KERN;
- mib[1] = KERN_FILE2;
+ mib[1] = KERN_FILE;
mib[2] = op;
mib[3] = arg;
mib[4] = esize;
@@ -150,7 +153,7 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (rv == -1) {
if (kd->vmfd != -1)
goto deadway;
- _kvm_syserr(kd, kd->program, "kvm_getfile2");
+ _kvm_syserr(kd, kd->program, "kvm_getfiles");
return (NULL);
}
kd->filebase = _kvm_malloc(kd, size);
@@ -161,15 +164,15 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
mib[5] = size / esize;
rv = sysctl(mib, 6, kd->filebase, &size, NULL, 0);
if (rv == -1) {
- _kvm_syserr(kd, kd->program, "kvm_getfile2");
+ _kvm_syserr(kd, kd->program, "kvm_getfiles");
return (NULL);
}
*cnt = size / esize;
- return ((struct kinfo_file2 *)kd->filebase);
+ return ((struct kinfo_file *)kd->filebase);
} else {
- if (esize > sizeof(struct kinfo_file2)) {
+ if (esize > sizeof(struct kinfo_file)) {
_kvm_syserr(kd, kd->program,
- "kvm_getfile2: unknown fields requested: libkvm out of date?");
+ "kvm_getfiles: unknown fields requested: libkvm out of date?");
return (NULL);
}
deadway:
@@ -180,11 +183,11 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
"%s: invalid argument");
return (NULL);
}
- return (kvm_deadfile2_byfile(kd, op, arg, esize, cnt));
+ return (kvm_deadfile_byfile(kd, op, arg, esize, cnt));
break;
case KERN_FILE_BYPID:
case KERN_FILE_BYUID:
- return (kvm_deadfile2_byid(kd, op, arg, esize, cnt));
+ return (kvm_deadfile_byid(kd, op, arg, esize, cnt));
break;
default:
return (NULL);
@@ -192,14 +195,14 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
}
}
-static struct kinfo_file2 *
-kvm_deadfile2_byfile(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
+static struct kinfo_file *
+kvm_deadfile_byfile(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
{
struct nlist nl[3], *p;
size_t buflen;
int n = 0;
char *where;
- struct kinfo_file2 kf;
+ struct kinfo_file kf;
struct file *fp, file;
struct filelist filehead;
int nfiles;
@@ -236,7 +239,7 @@ kvm_deadfile2_byfile(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
_kvm_err(kd, kd->program, "can't read kfp");
return (NULL);
}
- if (fill_file2(kd, &kf, &file, (u_long)fp, NULL, NULL, 0, 0)
+ if (fill_file(kd, &kf, &file, (u_long)fp, NULL, NULL, 0, 0)
== -1)
return (NULL);
memcpy(where, &kf, esize);
@@ -249,17 +252,17 @@ kvm_deadfile2_byfile(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
return (NULL);
}
*cnt = n;
- return ((struct kinfo_file2 *)kd->filebase);
+ return ((struct kinfo_file *)kd->filebase);
}
-static struct kinfo_file2 *
-kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
+static struct kinfo_file *
+kvm_deadfile_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
{
size_t buflen;
struct nlist nl[4], *np;
int n = 0;
char *where;
- struct kinfo_file2 kf;
+ struct kinfo_file kf;
struct file *fp, file;
struct filelist filehead;
struct filedesc0 filed0;
@@ -389,7 +392,7 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (proc.p_textvp) {
if (buflen < esize)
goto done;
- if (fill_file2(kd, &kf, NULL, 0, proc.p_textvp, &proc,
+ if (fill_file(kd, &kf, NULL, 0, proc.p_textvp, &proc,
KERN_FILE_TEXT, pid) == -1)
goto cleanup;
memcpy(where, &kf, esize);
@@ -400,7 +403,7 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (filed.fd_cdir) {
if (buflen < esize)
goto done;
- if (fill_file2(kd, &kf, NULL, 0, filed.fd_cdir, &proc,
+ if (fill_file(kd, &kf, NULL, 0, filed.fd_cdir, &proc,
KERN_FILE_CDIR, pid) == -1)
goto cleanup;
memcpy(where, &kf, esize);
@@ -411,7 +414,7 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (filed.fd_rdir) {
if (buflen < esize)
goto done;
- if (fill_file2(kd, &kf, NULL, 0, filed.fd_rdir, &proc,
+ if (fill_file(kd, &kf, NULL, 0, filed.fd_rdir, &proc,
KERN_FILE_RDIR, pid) == -1)
goto cleanup;
memcpy(where, &kf, esize);
@@ -422,7 +425,7 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if (process.ps_tracevp) {
if (buflen < esize)
goto done;
- if (fill_file2(kd, &kf, NULL, 0, process.ps_tracevp,
+ if (fill_file(kd, &kf, NULL, 0, process.ps_tracevp,
&proc, KERN_FILE_TRACE, pid) == -1)
goto cleanup;
memcpy(where, &kf, esize);
@@ -449,7 +452,7 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
_kvm_err(kd, kd->program, "can't read file");
goto cleanup;
}
- if (fill_file2(kd, &kf, &file, (u_long)fp, NULL,
+ if (fill_file(kd, &kf, &file, (u_long)fp, NULL,
&proc, i, pid) == -1)
goto cleanup;
memcpy(where, &kf, esize);
@@ -461,14 +464,14 @@ kvm_deadfile2_byid(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
done:
*cnt = n;
free(filebuf);
- return ((struct kinfo_file2 *)kd->filebase);
+ return ((struct kinfo_file *)kd->filebase);
cleanup:
free(filebuf);
return (NULL);
}
static int
-fill_file2(kvm_t *kd, struct kinfo_file2 *kf, struct file *fp, u_long fpaddr, struct vnode *vp,
+fill_file(kvm_t *kd, struct kinfo_file *kf, struct file *fp, u_long fpaddr, struct vnode *vp,
struct proc *p, int fd, pid_t pid)
{
struct ucred f_cred;
@@ -570,6 +573,8 @@ fill_file2(kvm_t *kd, struct kinfo_file2 *kf, struct file *fp, u_long fpaddr, st
return (-1);
}
kf->so_family = domain.dom_family;
+ kf->so_rcv_cc = sock.so_rcv.sb_cc;
+ kf->so_snd_cc = sock.so_snd.sb_cc;
if (sock.so_splice) {
kf->so_splice = PTRTOINT64(sock.so_splice);
kf->so_splicelen = sock.so_splicelen;
@@ -622,7 +627,30 @@ fill_file2(kvm_t *kd, struct kinfo_file2 *kf, struct file *fp, u_long fpaddr, st
_kvm_err(kd, kd->program, "can't read unpcb");
return (-1);
}
- kf->unp_conn = PTRTOINT64(unpcb.unp_conn);
+ kf->unp_conn = PTRTOINT64(unpcb.unp_conn);
+ kf->unp_refs = PTRTOINT64(unpcb.unp_refs);
+ kf->unp_nextref = PTRTOINT64(unpcb.unp_nextref);
+ kf->v_un = PTRTOINT64(unpcb.unp_vnode);
+ if (unpcb.unp_addr != NULL) {
+ struct mbuf mb;
+ struct sockaddr_un un;
+
+ if (KREAD(kd, (u_long)unpcb.unp_addr, &mb)) {
+ _kvm_err(kd, kd->program,
+ "can't read sockaddr_un mbuf");
+ return (-1);
+ }
+ if (KREAD(kd, (u_long)mb.m_data, &un)) {
+ _kvm_err(kd, kd->program,
+ "can't read sockaddr_un");
+ return (-1);
+ }
+
+ kf->unp_addr = PTRTOINT64(unpcb.unp_addr);
+ memcpy(kf->unp_path, un.sun_path, un.sun_len
+ - offsetof(struct sockaddr_un,sun_path));
+ }
+
break;
}
}
@@ -714,7 +742,7 @@ _kvm_getftype(enum vtype v_type)
}
static int
-ufs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+ufs_filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct inode inode;
struct ufs1_dinode di1;
@@ -742,7 +770,7 @@ ufs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
}
static int
-ext2fs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+ext2fs_filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct inode inode;
struct ext2fs_dinode e2di;
@@ -770,7 +798,7 @@ ext2fs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
}
static int
-msdos_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+msdos_filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct denode de;
struct msdosfsmount mp;
@@ -795,7 +823,7 @@ msdos_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
}
static int
-nfs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+nfs_filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct nfsnode nfsnode;
@@ -814,7 +842,7 @@ nfs_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
}
static int
-spec_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+spec_filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct specinfo specinfo;
struct vnode parent;
@@ -840,7 +868,7 @@ spec_filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
}
static int
-filestat(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+filestat(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
int ret = 0;
diff --git a/lib/libkvm/kvm_getfiles.3 b/lib/libkvm/kvm_getfiles.3
index 6954f5aa60b..f26818fcdc4 100644
--- a/lib/libkvm/kvm_getfiles.3
+++ b/lib/libkvm/kvm_getfiles.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kvm_getfiles.3,v 1.15 2013/08/03 06:25:32 guenther Exp $
+.\" $OpenBSD: kvm_getfiles.3,v 1.16 2013/10/22 16:40:27 guenther Exp $
.\" $NetBSD: kvm_getfiles.3,v 1.3 1996/03/18 22:33:23 thorpej Exp $
.\"
.\" Copyright (c) 1992, 1993
@@ -34,7 +34,7 @@
.\"
.\" @(#)kvm_getfiles.3 8.2 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: August 3 2013 $
+.Dd $Mdocdate: October 22 2013 $
.Dt KVM_GETFILES 3
.Os
.Sh NAME
@@ -43,14 +43,9 @@
.Sh SYNOPSIS
.In kvm.h
.In sys/types.h
-.Fd #define _KERNEL
-.In sys/file.h
-.Fd #undef _KERNEL
-.\" .Fa kvm_t *kd
-.Ft char *
-.Fn kvm_getfiles "kvm_t *kd" "int op" "int arg" "int *cnt"
-.Ft struct kinfo_file2 *
-.Fn kvm_getfile2 "kvm_t *kd" "int op" "int arg" "size_t elemsize" "int *cnt"
+.In sys/sysctl.h
+.Ft struct kinfo_file *
+.Fn kvm_getfiles "kvm_t *kd" "int op" "int arg" "size_t elemsize" "int *cnt"
.Sh DESCRIPTION
.Fn kvm_getfiles
returns a (sub-)set of the open files in the kernel indicated by
@@ -61,38 +56,6 @@ and
.Fa arg
arguments constitute a predicate which limits the set of files
returned.
-No predicates are currently defined.
-.Pp
-The number of processes found is returned in the reference parameter
-.Fa cnt .
-The files are returned as a contiguous array of file structures,
-preceded by the address of the first file entry in the kernel.
-This memory is owned by kvm and is not guaranteed to be persistent across
-subsequent kvm library calls.
-Data should be copied out if it needs to be saved.
-.Pp
-.Fn kvm_getfile2
-is similar to
-.Fn kvm_getfiles
-but returns an array of
-.Vt kinfo_file2
-structures.
-Additionally, only the first
-.Fa elemsize
-bytes of each array entry are returned.
-If the size of the
-.Vt kinfo_file2
-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_getfile2
-will continue to function without the need for recompilation.
-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:
@@ -112,20 +75,30 @@ files opened by processes with effective user ID
Files associated with a process will include information about
the process that has the file open.
.Pp
+Only the first
+.Fa elemsize
+bytes of each array entry are returned.
+If the size of the
+.Vt kinfo_file
+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_getfiles
+will continue to function without the need for recompilation.
+.Pp
The files are returned as a contiguous array of
-.Vt kinfo_file2
+.Vt kinfo_file
structures.
The number of structures found is returned in the reference parameter
.Fa cnt .
This memory is owned by kvm and will be overwritten by subsequent calls to
-.Fn kvm_getfile2
+.Fn kvm_getfiles
and destroyed by
.Fn kvm_close .
Data should be copied out if it needs to be saved.
.Sh RETURN VALUES
.Fn kvm_getfiles
-and
-.Fn kvm_getfile2
will return
.Dv NULL
on failure.
diff --git a/lib/libkvm/kvm_ntfs.c b/lib/libkvm/kvm_ntfs.c
index 53a7c19209d..f8530771ec0 100644
--- a/lib/libkvm/kvm_ntfs.c
+++ b/lib/libkvm/kvm_ntfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_ntfs.c,v 1.2 2009/10/27 23:59:28 deraadt Exp $ */
+/* $OpenBSD: kvm_ntfs.c,v 1.3 2013/10/22 16:40:27 guenther Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
extern mode_t _kvm_getftype(enum vtype);
int
-_kvm_stat_ntfs(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+_kvm_stat_ntfs(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct ntnode ntnode;
struct fnode fn;
diff --git a/lib/libkvm/kvm_private.h b/lib/libkvm/kvm_private.h
index b25b7f0804c..409bace43ad 100644
--- a/lib/libkvm/kvm_private.h
+++ b/lib/libkvm/kvm_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_private.h,v 1.17 2011/03/12 04:54:28 guenther Exp $ */
+/* $OpenBSD: kvm_private.h,v 1.18 2013/10/22 16:40:27 guenther Exp $ */
/* $NetBSD: kvm_private.h,v 1.7 1996/05/05 04:32:15 gwr Exp $ */
/*-
@@ -101,6 +101,6 @@ void *_kvm_realloc(kvm_t *kd, void *, size_t);
void _kvm_syserr(kvm_t *kd, const char *program, const char *fmt, ...);
ssize_t _kvm_pread(kvm_t *, int, void *, size_t, off_t);
ssize_t _kvm_pwrite(kvm_t *, int, const void *, size_t, off_t);
-int _kvm_stat_cd9660(kvm_t *, struct kinfo_file2 *, struct vnode *);
-int _kvm_stat_udf(kvm_t *, struct kinfo_file2 *, struct vnode *);
-int _kvm_stat_ntfs(kvm_t *, struct kinfo_file2 *, struct vnode *);
+int _kvm_stat_cd9660(kvm_t *, struct kinfo_file *, struct vnode *);
+int _kvm_stat_udf(kvm_t *, struct kinfo_file *, struct vnode *);
+int _kvm_stat_ntfs(kvm_t *, struct kinfo_file *, struct vnode *);
diff --git a/lib/libkvm/kvm_udf.c b/lib/libkvm/kvm_udf.c
index 470a4fe062e..3907ebc5c13 100644
--- a/lib/libkvm/kvm_udf.c
+++ b/lib/libkvm/kvm_udf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_udf.c,v 1.5 2013/03/23 17:11:08 deraadt Exp $ */
+/* $OpenBSD: kvm_udf.c,v 1.6 2013/10/22 16:40:27 guenther Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -67,7 +67,7 @@ udf_permtomode(struct unode *up)
}
int
-_kvm_stat_udf(kvm_t *kd, struct kinfo_file2 *kf, struct vnode *vp)
+_kvm_stat_udf(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
struct unode up;
struct file_entry fentry;
diff --git a/lib/libkvm/shlib_version b/lib/libkvm/shlib_version
index d85251eba7d..77913220429 100644
--- a/lib/libkvm/shlib_version
+++ b/lib/libkvm/shlib_version
@@ -1,2 +1,2 @@
-major=14
+major=15
minor=0