Kernel Functions for Drivers modinstall(9F)
NAME
modinstall, modremove, modinfo, modmodname - add, remove
or query a loadable module
SYNOPSIS
#include
int modinstall(struct modlinkage *modlinkage);
int modremove(struct modlinkage *modlinkage);
int modinfo(struct modlinkage *modlinkage,
struct modinfo *modinfo);
const char *modmodname(struct modlinkage *modlinkage);
INTERFACE LEVEL
Solaris DI specific (Solaris DI).
PARAMETERS
modlinkage Pointer to the loadable module's modlinkage
structure which describes what type(s) of
module elements are included in this loadable
module.
modinfo Pointer to the modinfo structure passed to
info(9E).
DESCRIPTION
modinstall() must be called from a module's init(9E) rou-
tine.
modremove() must be called from a module's fini(9E) rou-
tine.
modinfo() must be called from a module's info(9E) routine.
modmodname() can be called from any module routine.
SunOS 5.11 Last change: 8 Jul 2008 1
Kernel Functions for Drivers modinstall(9F)
When init(9E) is executing, its call to modinstall()
enables other threads to call attach(9E) even prior to
modinstall() returning and init(9E) completion. From a
programming standpoint this means that all init(9E) ini-
tialization must occur prior to init(9E) calling
modinstall(). If modinstall() fails (non-zero return
value), any initialization must be undone.
When fini(9E) is executing, another thread may call
attach(9E) prior to fini(9E) calling modremove(). If this
occurs, the modremove() fails (non-zero return). From a
programming standpoint, this means that init(9E) initiliza-
tions should only be undone after a successful return from
modremove().
To query the name of a module, use modmodname(). If the
module is a driver, the module name is the same as the
driver name. This function can be used to avoid compiled-in
knowledge of the module name, and is of particular use when
init(9E) needs to call a function like kstatcreate(9F).
RETURN VALUES
modinstall() and modremove() return 0 upon success and
non-zero on failure.
modinfo() returns a non-zero value on success and 0 upon
failure.
modmodname() returns the name of the module. The returned
name remains valid as long as the module remains loaded.
EXAMPLES
See init(9E) for an example that uses these functions.
SEE ALSO
fini(9E), info(9E), init(9E), kstatcreate(9F),
modldrv(9S), modlinkage(9S), modlstrmod(9S)
Writing Device Drivers
SunOS 5.11 Last change: 8 Jul 2008 2
|