| KVM_GETFILES(3) | Library Functions Manual | KVM_GETFILES(3) |
kvm_getfiles —
survey open files
#include <kvm.h>
#include <sys/types.h>
#include <sys/sysctl.h>
struct kinfo_file *
kvm_getfiles(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. The value of op describes the
filtering predicate as follows:
KERN_FILE_BYFILEKERN_FILE_BYPIDKERN_FILE_BYUIDFiles associated with a process will include information about the process that has the file open.
For KERN_FILE_BYFILE the recognized file
types are defined in
<sys/file.h>:
DTYPE_VNODEDTYPE_SOCKETDTYPE_PIPEDTYPE_KQUEUEOnly the first elemsize
bytes of each array entry are returned. If the size of the
kinfo_file 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_getfiles()
will continue to function without the need for recompilation.
The files are returned as a contiguous array of
kinfo_file 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_getfiles() and destroyed by
kvm_close(). Data should be copied out if it needs
to be saved.
kvm_getfiles() will return
NULL on failure.
kvm_getfiles() will fail if:
kvm(3), kvm_geterr(3), kvm_nlist(3), kvm_open(3), kvm_read(3)
This routine does not belong in the kvm interface.
| May 4, 2016 | openbsd |