Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12 549
STREAMS drivers, like WSIO class drivers, automatically track open()
and close() system calls for the STREAMS device. The system will
prevent a STREAMS driver from unloading whenever the device has one
or more open file handles. Of course, the driver can still disallow an
unload if this check is insufficient for its needs. A typical _unload()
function for a STREAMS driver is as follows:
Example 12-10 STREAMS Driver _unload Function
module_name
_unload(void *arg)
{
int retval;
/* Uninstall from Streams */
if ((retval = str_uninstall(&str_info)) != 0)
return retval;
/* Free module specific resources, etc. */
...
return 0;
}
STREAMS Modules
Loadable STREAMS modules have no special requirements during
initialization. The argument passed to the _load() function should be
ignored. Sample _load() and _install() functions are as follows: