Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getkerninfo(2) — BSD/386 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

GETKERNINFO(2)              BSD Programmer's Manual             GETKERNINFO(2)

NAME
     getkerninfo - get kernel information

SYNOPSIS
     #include <sys/types.h>
     #include <sys/kinfo.h>
     #include <sys/kinfoproc.h>
     #include <sys/sysinfo.h>

     int
     getkerninfo(int op, void *val, int *size, int arg)

DESCRIPTION
     The getkerninfo() function is used to retrieve various information from
     the kernel.  In general, the op parameter specifies the type of informa-
     tion to be retrieved, in conjunction with the selector arg, which has a
     meaning depending on the operation.  The information is copied into the
     buffer specified by val. The size of the buffer is given by the location
     specified by size before the call, and that location gives the amount of
     data copied after a successful call.  The amount of data available is re-
     turned by a successful call, which could be larger than the size of the
     buffer supplied.  In this case, not all of the available data are re-
     turned by the call.

     The amount of space required for a value may be obtained by calling
     getkerninfo() with NULL val and size parameters.  For some operations,
     the amount of space may change often; the system attempts to round up so
     that the return value is actually sufficient for a call to return the da-
     ta shortly thereafter.

     The parameter op specifies both the type of data to be returned, and in
     some cases, the meaning of the additional selector arg. The types of data
     currently available are process information, routing table entries, sys-
     tem vnodes, the open file entries, and various system information.

     The following list describes the types of data that may currently be re-
     trieved with getkerninfo(), according to the value of op and the value of
     arg. If the data type is followed by brackets ([]), an array of the indi-
     cated type is returned, depending on the current number of such objects
     in the system.

     OP                     ARG Meaning      type of data
     KINFO_PROC_ALL         none             struct kinfoproc[]
     KINFO_PROC_PID         process ID       struct kinfoproc[]
     KINFO_PROC_PGRP        process group    struct kinfoproc[]
     KINFO_PROC_SESSION     process ID       struct kinfoproc[]
     KINFO_PROC_TTY         tty device       struct kinfoproc[]
     KINFO_PROC_UID         user ID          struct kinfoproc[]
     KINFO_PROC_RUID        real user ID     struct kinfoproc[]

     KINFO_RT_DUMP          none             *
     KINFO_RT_FLAGS         rtflags          *

     KINFO_VNODE            process ID       **
     KINFO_FILE             process ID       struct filehead, struct file[]

     KINFO_SYSINFO          none             struct sysinfo

     * For KINFO_RT_DUMP and KINFO_RT_FLAGS, the data is returned as a se-
     quence of routing messages (see route(4) for the header file, format and
     meaning).  The length of each message is contained in the message header.


     ** For KINFO_VNODE, the returned data consists of an array, each element
     of which contains the kernel address of a vnode (struct vnode *) followed
     by the vnode itself (struct vnode).

     For most operations, the getkerninfo() function returns a consistent
     snapshot of the data requested.  (This is not currently true for
     KINFO_VNODE.) In order to do this, the destination buffer is locked into
     memory so that the data may be copied out without blocking.  Calls are
     serialized to avoid deadlock.

RETURN VALUES
     A -1 return value indicates an error occurred and errno is set to indi-
     cate the reason.  Otherwise, the return value indicates the amount of
     space required to store the requested information, which might be larger
     than the amount of space provided (if any).

ERRORS
     Getkerninfo() will fail if one of the following occurs:

     [EINVAL]      op was not valid.

     [EFAULT]      Either val or size points to memory that is not a valid
                   part of the process address space or was not writable.

HISTORY
     The getkerninfo function call appeared in 4.3BSD-Reno. It is not current-
     ly portable and is subject to change in future releases.

BSDI BSD/386                    March 26, 1993                               2






































Typewritten Software • bear@typewritten.org • Edmonds, WA 98026