diff options
Diffstat (limited to 'lib/libkvm')
-rw-r--r-- | lib/libkvm/kvm_file2.c | 11 | ||||
-rw-r--r-- | lib/libkvm/kvm_getfiles.3 | 27 |
2 files changed, 29 insertions, 9 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); diff --git a/lib/libkvm/kvm_getfiles.3 b/lib/libkvm/kvm_getfiles.3 index f26818fcdc4..b8e0ed58d13 100644 --- a/lib/libkvm/kvm_getfiles.3 +++ b/lib/libkvm/kvm_getfiles.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: kvm_getfiles.3,v 1.16 2013/10/22 16:40:27 guenther Exp $ +.\" $OpenBSD: kvm_getfiles.3,v 1.17 2015/02/11 03:03:08 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: October 22 2013 $ +.Dd $Mdocdate: February 11 2015 $ .Dt KVM_GETFILES 3 .Os .Sh NAME @@ -62,7 +62,9 @@ describes the filtering predicate as follows: .Pp .Bl -tag -width 20n -offset indent -compact .It Dv KERN_FILE_BYFILE -all open files +all open files with type +.Fa arg +(0 for all files) .It Dv KERN_FILE_BYPID files opened by process ID .Fa arg @@ -70,11 +72,30 @@ files opened by process ID .It Dv KERN_FILE_BYUID files opened by processes with effective user ID .Fa arg +(\-1 for all users) .El .Pp Files associated with a process will include information about the process that has the file open. .Pp +For +.Dv KERN_FILE_BYFILE +the recognized file types are defined in +.In sys/file.h : +.Pp +.Bl -tag -width 20n -offset indent -compact +.It Dv DTYPE_VNODE +files and devices +.It Dv DTYPE_SOCKET +sockets, regardless of domain +.It Dv DTYPE_PIPE +pipes and FIFOs +.It Dv DTYPE_KQUEUE +kqueues +.It Dv DTYPE_SYSTRACE +systrace control files +.El +.Pp Only the first .Fa elemsize bytes of each array entry are returned. |