table(2)table(2)NAMEtable - Examine or update elements from a system tableSYNOPSIS
#include <sys/table.h>
int table(
long id,
long index,
void *addr,
long nel,
u_long lel );
PARAMETERS
The ID of the system table that contains the element or elements. The
index of an element within the table. The address of a struct (or a
struct array) of the appropriate type to copy the element values to (on
examine) or from (on update). The various structure layouts are
described in /usr/include/sys/table.h. A signed number that specifies
how many elements to copy and in which direction. A positive value
copies the elements from the kernel to addr. A negative value copies
the elements from addr to the kernel. The expected size of a single
element.
DESCRIPTION
The table() interface is used to examine or update one or more elements
in the system table. The system table is specified by id and the start‐
ing element is specified by index.
The table() interface copies the element value or values to or from the
specified addr. The nel parameter specifies the number of elements to
copy, starting from index. A positive value indicates an examine opera‐
tion. The elements are copied from the kernel to addr. A negative
value indicates an update operation. The elements are copied from addr
to the kernel.
The lel parameter specifies the expected element size. If multiple ele‐
ments are specified, successive addresses are calculated for addr by
incrementing it by lel for each element copied. If the size of a given
element is larger than lel, table() truncates excess data on an update
(from addr to the kernel) and stores only the expected size on an exam‐
ine (from the kernel to addr). If the size of a given element is
smaller than lel, table() copies only the valid data on an update and
pads the element value on an examine.
The table() interface guarantees that an update operation will not
change the offset and size of any field within an element. New fields
are added only at the end of an element.
The table() interface returns a count of the elements examined or
updated. The id value TBL_PROCINFO allows you to determine the actual
number of elements in a table before requesting any data; in this case,
call table() with lel set to zero (0) and nel to the maximum positive
integer.
The id parameter must specify one of the following tables, each of
which has a structure in <sys/table.h>, unless otherwise noted: The
controlling terminal device number table. The index is by process ID
and exactly one element can be requested. If the process ID is zero
(0), the current process is indexed. Only 0 and the current process ID
are supported. The element is of type dev_t as defined in
<sys/types.h>. This table is examine only. It cannot be updated. The
U-area table. The index is by process ID. See the <user.h> header file
for the (pseudo) struct user that is returned. The system load average
vector (pseudo) table. In this case, index must be zero (0) and exactly
one element can be requested.
If the scale is zero (0), the load average vector is the float‐
ing point variant. If the size is non-zero, the load average
vector has been scaled by the indicated factor (typically 1000)
to produce the long integer variant. This table is examine
only. It cannot be updated. The system include-file version-
number (pseudo) table. The index value must be zero (0) and
exactly one element can be requested. The include-file version
is a unique integer. It identifies the layout of kernel data
structures that are imported by certain kernel-dependent pro‐
grams. This table is examine only. It cannot be updated. The
process command argument table containing the saved arguments
for processes. The index value is by process ID only and exactly
one element can be requested. Arguments for processes other than
the current process can be accessed only by the root user. This
table is examine only. It cannot be updated.
This table contains all the command line arguments for the
process. Specify the process id in the index argument. The addr
argument points to a buffer into which the command line argu‐
ments are placed.
The amount of buffer space needed for the command line arguments
depends on the total length of all the arguments from the
process being examined. Specify the size of the user buffer
with the lel argument. If the buffer is not large enough to
accept the complete argument list, the given length of the buf‐
fer is copied.
The arguments are placed in the buffer as a series of null-ter‐
minated strings, in argument order. The maximum process count
per user ID table. The index is by process ID and exactly one
element can be requested. If the process ID is zero (0), the
current process is indexed. Only 0 and the current process ID
are supported. The element is of the short integer type.
The maximum count includes all processes running under the cur‐
rent user ID even though the limit affects only the current
process and any children created with that limit in effect. The
limit can be changed only by the root user. The process status
information table. The index value is an offset into a table of
processes. Status information for processes other than the cur‐
rent process can be accessed only by the root user. This table
is examine only and cannot be updated.
The TBL_PROCINFO id value lets you determine the actual number
of elements in a table before you request any data. You call ta‐
ble() with the lel argument set to zero, index set to zero, and
the nel argument set to the maximum positive integer. The return
is the number of elements in the table. The current count of
threads and their states. The index value may be either a single
process ID, or zero (0) to count all process IDs. Only the root
user can obtain information on a single process ID that is not
the current process. Only one element should be requested (only
one is available). This table is examine only. It cannot be
updated. The process environment table. The index value is by
process ID and exactly one element can be requested. Environment
information for processes other than the current process can be
accessed only by the root user. This table is examine only. It
cannot be updated. The system time information table. The index
must be zero (0) and exactly one element can be requested. The
system information table contains ticks of time accumulated in
the various system states: user, nice, system, and idle. The
system tick frequency and profiling (if configured) frequency
are also provided for conversion from ticks to time values. This
table is examine only. It cannot be updated. The disk statis‐
tics table. The index is by disk number. This table is examine
only. It cannot be updated. The system swap device list infor‐
mation table. This table is examine only. It cannot be updated.
If index is positive or zero (0), the swap device information
for the entry in the swap device list is returned.
If index is less than zero (0), the amount of total swap space
configured and amount of total free space on the system is
returned. In addition, the options member contains the value of
vm_swap_eager system attribute and the dev field contains the
lazy swap device number (if lazy swap is set) or zero (0) (if
eager swap is set). The TTY statistics table. The index value
must be zero (0) and exactly one element can be requested. This
table is examine only. It cannot be updated. The message queue
ID table. The index value is the index into the queue array.
Each element of the array is a msqid_ds structure as defined in
<sys/msg.h>. This table is examine only. Its elements cannot be
updated. The semaphore ID table. The index value is the index
into the array of semaphore IDs. Each element is a semid_ds
structure as defined in <sys/sem.h>. This table is examine only.
Its elements cannot be updated. The shared memory region ID ta‐
ble. The index value is the index into the array of shared mem‐
ory region IDs. Each element is a shmid_ds structure as defined
in <sys/shm.h>. This table is examine only. Its elements cannot
be updated. The message information table. This table is exam‐
ine only. Its elements cannot be updated. The message informa‐
tion structure is defined in <sys/msg.h>.
The index is by field positions within the message information
structure, as follows: The maximum message size The maximum num‐
ber of bytes on the queue The number of message queue identi‐
fiers The number of system message headers The semaphore infor‐
mation table. This table is examine only. It cannot be updated.
The semaphore information structure is defined in <sys/sem.h>.
The index value is the field position within the semaphore
information structure as follows: The number of semaphore iden‐
tifiers The maximum number of semaphores per identifier The max‐
imum number of operations per semop() call The maximum number of
undo entries per process The semaphore maximum value The maximum
adjust-on-exit value The shared memory information table. This
table is examine only. It cannot be updated. The shared memory
information structure is defined in <sys/shm.h>.
The index value is the field position within the shared memory
information structure, as follows: The maximum shared memory
region size The minimum shared memory region size The number of
shared memory identifiers The maximum number of attached shared
memory regions per process The system interrupt information ta‐
ble. There is no index into the table. This table is examine
only. It cannot be updated. The user file table. The index is
by process ID and exactly one element can be requested. The addr
argument is of type struct stat. The nel argument specifies the
file descriptor. This table provides stat information on the
specified descriptor for the specified process ID. Information
on processes other than the current process can be accessed only
by the root user. This table is examine only.
RETURN VALUES
A positive return value indicates that the call succeeded for that num‐
ber of elements. A return value of -1 indicates failure, in which case,
errno is set to indicate the error.
ERRORS
The addr parameter specifies an invalid address. One of the following
applies: The table specified by id is not defined. The index value is
not valid for the specified table. The specified table allows only an
index of the current process ID with exactly one element. Some other
index or element number was specified. An element length of zero (0)
was supplied for the TBL_ARGUMENTS table. An attempt was made to
update an examine-only table. No such device or address. An attempt
was made to change the maximum number of processes or the account ID,
and the caller was not the root user. The process specified by a
process ID index cannot be found. A call using TBL_ENVIRONMENT failed
because of memory or lock contention.
SEE ALSOacct(2)table(2)