HP-UX Reference (11i v2 03/08) - 5 Miscellaneous Topics, 7 Device (Special) Files, 9 General Information, Index (vol 9)

k
kmem(7) kmem(7)
NAME
kmem - perform I/O on kernel memory based on symbol name.
SYNOPSIS
#include <sys/ksym.h>
int ioctl(int kmemfd, int command, void *
rks);
DESCRIPTION
When used with a valid file descriptor for
/dev/kmem (kmemfd), ioctl can be used to manipulate ker-
nel memory. The specifics of this manipulation depend on the command given as follows:
MIOC_READKSYM
Read mirk_buflen bytes of kernel memory starting at the address for
mirk_symname into mirk_buf. rks is a pointer to a
mioc_rksym structure,
defined below.
MIOC_IREADKSYM
Indirect read. Read sizeof(void *) bytes of kernel memory starting at the
address for mirk_symname and use that as the address from which to read
mirk_buflen bytes of kernel memory into mirk_buf. rks is a pointer to a
mioc_rksym structure.
MIOC_WRITEKSYM
Write mirk_buflen bytes from mirk_buf into kernel memory starting at the
address for mirk_symname. rks is a pointer to a
mioc_rksym structure.
MIOC_IWRITEKSYM Indirect write. Read
sizeof(void *) bytes of kernel memory starting at the
address for mirk_symname and use that as the kernel memory address into which
mirk_buflen bytes from mirk_buf are written. rks is a pointer to a
mioc_rksym
structure.
MIOC_LOCKSYM Increase the hold count by one for the dynamically loaded module whose name is
given by rks, a pointer to a character string, thereby preventing its unloading.
MIOC_UNLOCKSYM
Decrease the hold count by one for the dynamically loaded module whose name is given by rks,a
pointer to a character string. If the count is thereby reduced to 0, the module becomes a candi-
date for unloading.
The
struct mioc_rksym definition is:
struct mioc_rksym {
char * mirk_modname; /* limit search for symname
to module modname; if NULL
use standard search order */
char * mirk_symname; /* name of symbol whose address
is the basis for this
operation */
void * mirk_buf; /* buffer into/from which
read/write takes place */
size_t mirk_buflen; /* length (in bytes) of desired
operation */
};
RETURN VALUE
ioctl returns 0 upon successful completion. If an error occurs, a value of -1 is returned and errno is
set to indicate the error.
ERRORS
In addition to the errors described in ioctl (2), the
kmem ioctl also fails if one or more of the following
are true:
[EINVAL] modname does not represent a currently loaded module or this is an
MIOC_UNLOCKSYM and the hold count is already 0.
[ENXIO] kmemfd open on wrong minor device (i.e., not
/dev/kmem).
[EBADF] kmemfd open for reading and this is an
MIOC_WRITEKSYM.
[ENOMATCH] symname not found.
HP-UX 11i Version 2: August 2003 1 Hewlett-Packard Company Section 759