From a97d025f9d557cb2e82b00c37b0d96c54a805a68 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Wed, 11 Feb 2015 03:03:10 +0000 Subject: 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@ --- lib/libkvm/kvm_file2.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/libkvm/kvm_file2.c') 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 @@ -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); -- cgit v1.2.3