summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_file2.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-02-11 03:03:10 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-02-11 03:03:10 +0000
commita97d025f9d557cb2e82b00c37b0d96c54a805a68 (patch)
treed519b13fe30095c21d06350bca185a5525010720 /lib/libkvm/kvm_file2.c
parentb62d642f586ac0d39a5ae95ec450b3e137b276f2 (diff)
sysctl({CTL_KERN, KERN_FILE, KERN_FILE_BYFILE}) previously required
the extra argument to be zero; instead, make it filter on the file type (DTYPE_*) when non-zero to make claudio's netstat work easier. ok claudio@
Diffstat (limited to 'lib/libkvm/kvm_file2.c')
-rw-r--r--lib/libkvm/kvm_file2.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libkvm/kvm_file2.c b/lib/libkvm/kvm_file2.c
index 35d26b5ba96..4a6979f7707 100644
--- a/lib/libkvm/kvm_file2.c
+++ b/lib/libkvm/kvm_file2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_file2.c,v 1.41 2015/01/16 16:48:51 deraadt Exp $ */
+/* $OpenBSD: kvm_file2.c,v 1.42 2015/02/11 03:03:08 guenther Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -178,11 +178,6 @@ kvm_getfiles(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
deadway:
switch (op) {
case KERN_FILE_BYFILE:
- if (arg != 0) {
- _kvm_err(kd, kd->program,
- "%d: invalid argument", arg);
- return (NULL);
- }
return (kvm_deadfile_byfile(kd, op, arg, esize, cnt));
break;
case KERN_FILE_BYPID:
@@ -239,6 +234,10 @@ kvm_deadfile_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 (file.f_count == 0)
+ continue;
+ if (arg && file.f_type != arg)
+ continue;
if (fill_file(kd, &kf, &file, (u_long)fp, NULL, NULL, 0, 0)
== -1)
return (NULL);