man : kvm_getfiles(3)
KVM_GETFILES(3) OpenBSD Programmer's Manual KVM_GETFILES(3)
kvm_getfiles - survey open files
kvm_getfiles(kvm_t *kd, int op, int arg, int *cnt);
struct kinfo_file2 *
kvm_getfile2(kvm_t *kd, int op, int arg, size_t elemsize, int *cnt);
kvm_getfiles() returns a (sub-)set of the open files in the kernel
indicated by kd. The op and arg arguments constitute a predicate which
limits the set of files returned. No predicates are currently defined.
The number of processes found is returned in the reference parameter 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.
kvm_getfile2() is similar to kvm_getfiles() but returns an array of
kinfo_file2 structures. Additionally, only the first elemsize bytes of
each array entry are returned. If the size of the kinfo_file2 structure
increases in size in a future release of OpenBSD, the kernel will only
return the requested amount of data for each array entry and programs
that use kvm_getfile2() will continue to function without the need for
recompilation. The op and arg arguments constitute a predicate which
limits the set of processes returned. The value of op describes the
filtering predicate as follows:
KERN_FILE_BYFILE all open files
KERN_PROC_BYPID files opened by process ID arg (-1 for all
KERN_FILE_BYUID files opened by processes with effective user
Files associated with a process will include information about the
process that has the file open.
The files are returned as a contiguous array of kinfo_file2 structures.
The number of structures found is returned in the reference parameter
cnt. This memory is owned by kvm and will be overwritten by subsequent
calls to kvm_getfile2() and destroyed by kvm_close(). Data should be
copied out if it needs to be saved.
kvm_getfiles() and kvm_getfile2() will return NULL on failure.
kvm(3), kvm_close(3), kvm_geterr(3), kvm_nlist(3), kvm_open(3),
kvm_openfiles(3), kvm_read(3), kvm_write(3)
This routine does not belong in the kvm interface.
OpenBSD 4.9 June 7, 2009 OpenBSD 4.9