2 .\" Copyright (c) 2008, Sun Microsystems, Inc., All Rights Removed
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MOD_INSTALL 9F "Jul 8, 2008"
8 mod_install, mod_remove, mod_info, mod_modname \- add, remove or query a
13 #include <sys/modctl.h>
17 \fBint\fR \fBmod_install\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
22 \fBint\fR \fBmod_remove\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
27 \fBint\fR \fBmod_info\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR,
28 \fBstruct modinfo *\fR\fImodinfo\fR);
33 \fBconst\fR \fBchar *\fR\fImod_modname\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
38 Solaris DDI specific (Solaris DDI).
42 \fB\fImodlinkage\fR\fR
45 Pointer to the loadable module's \fBmodlinkage\fR structure which describes
46 what type(s) of module elements are included in this loadable module.
55 Pointer to the \fBmodinfo\fR structure passed to \fB_info\fR(9E).
60 \fBmod_install()\fR must be called from a module's \fB_init\fR(9E) routine.
63 \fBmod_remove()\fR must be called from a module's \fB_fini\fR(9E) routine.
66 \fBmod_info()\fR must be called from a module's \fB_info\fR(9E) routine.
69 \fBmod_modname()\fR can be called from any module routine.
72 When \fB_init\fR(9E) is executing, its call to \fBmod_install()\fR enables
73 other threads to call \fBattach\fR(9E) even prior to \fBmod_install()\fR
74 returning and \fB_init\fR(9E) completion. From a programming standpoint this
75 means that all \fB_init\fR(9E) initialization must occur prior to
76 \fB_init\fR(9E) calling \fBmod_install()\fR. If \fBmod_install()\fR fails
77 (non-zero return value), any initialization must be undone.
80 When \fB_fini\fR(9E) is executing, another thread may call \fBattach\fR(9E)
81 prior to \fB_fini\fR(9E) calling \fBmod_remove()\fR. If this occurs, the
82 \fBmod_remove()\fR fails (non-zero return). From a programming standpoint, this
83 means that \fB_init\fR(9E) initializations should only be undone after a
84 successful return from \fBmod_remove()\fR.
87 To query the name of a module, use \fBmod_modname()\fR. If the module is a
88 driver, the module name is the same as the driver name. This function can be
89 used to avoid compiled-in knowledge of the module name, and is of particular
90 use when \fB_init\fR(9E) needs to call a function like \fBkstat_create\fR(9F).
93 \fBmod_install()\fR and \fBmod_remove()\fR return \fB0\fR upon success and
97 \fBmod_info()\fR returns a non-zero value on success and \fB0\fR upon failure.
100 \fBmod_modname()\fR returns the name of the module. The returned name remains
101 valid as long as the module remains loaded.
104 See \fB_init\fR(9E) for an example that uses these functions.
107 \fB_fini\fR(9E), \fB_info\fR(9E), \fB_init\fR(9E), \fBkstat_create\fR(9F),
108 \fBmodldrv\fR(9S), \fBmodlinkage\fR(9S), \fBmodlstrmod\fR(9S)
111 \fIWriting Device Drivers\fR