1mod_install(9F) Kernel Functions for Drivers mod_install(9F)
2
3
4
6 mod_install, mod_remove, mod_info, mod_modname - add, remove or query a
7 loadable module
8
10 #include <sys/modctl.h>
11
12
13
14 int mod_install(struct modlinkage *modlinkage);
15
16
17 int mod_remove(struct modlinkage *modlinkage);
18
19
20 int mod_info(struct modlinkage *modlinkage,
21 struct modinfo *modinfo);
22
23
24 const char *mod_modname(struct modlinkage *modlinkage);
25
26
28 Solaris DDI specific (Solaris DDI).
29
31 modlinkage Pointer to the loadable module's modlinkage structure
32 which describes what type(s) of module elements are
33 included in this loadable module.
34
35
36 modinfo Pointer to the modinfo structure passed to _info(9E).
37
38
40 mod_install() must be called from a module's _init(9E) routine.
41
42
43 mod_remove() must be called from a module's _fini(9E) routine.
44
45
46 mod_info() must be called from a module's _info(9E) routine.
47
48
49 mod_modname() can be called from any module routine.
50
51
52 When _init(9E) is executing, its call to mod_install() enables other
53 threads to call attach(9E) even prior to mod_install() returning and
54 _init(9E) completion. From a programming standpoint this means that all
55 _init(9E) initialization must occur prior to _init(9E) calling
56 mod_install(). If mod_install() fails (non-zero return value), any ini‐
57 tialization must be undone.
58
59
60 When _fini(9E) is executing, another thread may call attach(9E) prior
61 to _fini(9E) calling mod_remove(). If this occurs, the mod_remove()
62 fails (non-zero return). From a programming standpoint, this means that
63 _init(9E) initilizations should only be undone after a successful
64 return from mod_remove().
65
66
67 To query the name of a module, use mod_modname(). If the module is a
68 driver, the module name is the same as the driver name. This function
69 can be used to avoid compiled-in knowledge of the module name, and is
70 of particular use when _init(9E) needs to call a function like
71 kstat_create(9F).
72
74 mod_install() and mod_remove() return 0 upon success and non-zero on
75 failure.
76
77
78 mod_info() returns a non-zero value on success and 0 upon failure.
79
80
81 mod_modname() returns the name of the module. The returned name remains
82 valid as long as the module remains loaded.
83
85 See _init(9E) for an example that uses these functions.
86
88 _fini(9E), _info(9E), _init(9E), kstat_create(9F), modldrv(9S), mod‐
89 linkage(9S), modlstrmod(9S)
90
91
92 Writing Device Drivers
93
94
95
96SunOS 5.11 8 Jul 2008 mod_install(9F)