SYSGET(2) SYSGET(2)
sysget - Call for reading or writing kernel data
#include <sys/sysget.h>
sysget (int name, char *buffer, int buflen, int flags,
sgt_cookie_t *cookie);
The sysget system call provides user access to kernel structures and
tables on IRIX systems. sysget can return data for a combination of cpus,
nodes, or cells depending on the combination of flags and cookie
settings.
The sysget system call accepts the following arguments:
name Identifies the kernel structure or table. The sys/sysget.h file
contains the list of names supported. Most come from the sysmp
MP_SAGET options. Here is a partial list:
SGT_SINFO SGT_MINFO SGT_DINFO SGT_SERR Returns the various
sysinfo-type structures. See the sys/sysinfo.h file.
SGT_RMINFO Returns the rminfo structure. See the sys/sysmp.h
file.
SGT_NODE_INFO
Returns the nodeinfo structure for each node. See
the sys/sysinfo.h file.
SGT_KSYM Returns the structure identified by the kernel
symbol specified in the cookie by using the
SGT_COOKIE_SET_KSYM() macro. Only a subset of kernel
symbols are supported. See the sys/sysget.h file.
buffer Points to the user's buffer space.
buflen Specifies the size of buffer in bytes.
flags Specifies option flags. A user must select the SGT_INFO,
SGT_READ, or SGT_WRITE flag. flags is combination of one or more
of the following:
SGT_INFO Returns information on the kernel structure or table
defined by the name argument. This option is similar
to the sysmp MP_SASZ option. The buffer argument
points to a structure defined in the sys/sysget.h
file as the following:
struct sgt_info {
int si_size;
Page 1
SYSGET(2) SYSGET(2)
int si_num;
int si_hiwater;
}
SGT_READ Returns the information defined by the name argument
in the buffer specified by the buffer argument.
SGT_STAT Returns information about the table or server
specified by the name argument. This information is
similar to that provided by the SGT_INFO flag.
SGT_SUM This flag is obsolete and will be ignored.
SGT_WRITE Writes the information specified by the buffer
argument to the kernel structure defined by the name
argument.
SGT_CPUS Returns data for each cpu. Not all structures
support this option.
SGT_NODES Returns data for each node. Not all structures
support this option.
cookie Specifies which cell, cpu, or node should be used when asking for
information. The kernel also uses it as a place-holder mechanism
to allow sysget to be used iteratively to return a list of
structures when the length of the list is unknown. Other uses are
to specify a specific location to seek to in a list.
This argument points to a structure defined as follows:
struct sgt_cookie {
sc_status_t sc_status;
union {
cell_t cellid;
cnodeid_t cnodeid;
int cpuid;
} sc_id;
sc_type_t sc_type;
char sc_opaque[SGT_OPAQUE_SZ];
}
The cookie must be initialized before the first call by using the
SGT_COOKIE_INIT() macro. See the sys/sysget.h file
If sysget completes normally, the number of bytes copied is returned,
otherwise a value of -1 is returned and errno is set to indicate the
error.
Page 2
SYSGET(2) SYSGET(2)
The sysget system call fails if one of the following error conditions
occurs:
Error Code Description
EFAULT The buffer address specified is not valid.
EINVAL A flag was specified in a context that was not valid
or the cookie was not set properly.
ENOENT The value specified in the name argument or in
combination with the cookie is unknown.
ENOTSUP The function specified by the flags parameter is not
supported.
ESRCH The cookie or cpu specified is not valid.
The following examples show how to use the sysget system call to retrieve
information.
Example 1: This example shows how to use sysget to obtain the number and
size of sysinfo structures in the system (a system running cells will
have a sysinfo structure per cell):
sgt_info_t info;
sgt_cookie_t cookie;
SGT_COOKIE_INIT(&cookie);
sysget(SGT_SINFO, (char *)&info, sizeof(info),
SGT_INFO, &cookie);
printf("number of sysinfo: %d, size: %d\n",
info.si_num, info.si_size);
Example 2: In this example, sysget reads the list of sysinfo structures
for each cpu:
sgt_info_t info;
sgt_cookie_t cookie;
struct sysinfo *si;
SGT_COOKIE_INIT(&cookie);
sysget(SGT_SINFO, (char *)&info, sizeof(info),
SGT_INFO | SGT_CPUS, &cookie);
si = (struct sysinfo *)malloc(info.si_num * info.si_size);
SGT_COOKIE_INIT(&cookie);
sysget(SGT_SINFO, (char *)si, info.si_num * info.si_size,
SGT_READ | SGT_CPUS, &cookie);
Page 3
SYSGET(2) SYSGET(2)
Example 3: In this example, sysget reads the list of sysinfo structures
for each cpu one at a time by iterating on the cookie:
sgt_info_t info;
sgt_cookie_t cookie;
struct sysinfo si;
SGT_COOKIE_INIT(&cookie);
while (cookie.sc_status != SC_DONE) {
sysget(SGT_SINFO, (char *)&si, sizeof(si),
SGT_READ | SGT_CPUS, &cookie);
}
Example 4: This example shows how to use sysget to read the contents of
a structure by specifying its kernel symbol using the SGT_KSYM option:
sgt_cookie_t cookie;
int avenrun[3];
SGT_COOKIE_INIT(&cookie);
SGT_COOKIE_SET_KSYM(&cookie, "avenrun");
sysget(SGT_KSYM, (char *)avenrun, sizeof(avenrun),
SGT_READ, &cookie);
sysmp(2), syssgi(2), nlist(3C), sysctl(3C)
PPPPaaaaggggeeee 4444 [ Back ]
|