STREAMS-UX Programmer's Guide (February 2007)
Modules and Drivers
STREAMS Module
Chapter 4
90
Installation Routine
STREAMS modules do not have any cdevsw-related information. They only have STREAMS-specific
information and this is configured by calling str_install() with a defined streams_info_t.
int
mod_install()
{
int retval;
if ((retval = str_install(&mod_str_info)) !=0)
return retval; /* failure */
return 0; /* Success */
}
NOTE Any module specific global data structures, spinlocks etc. can be setup and initialized in the
installation routine.
Open/Close Routines
As described in the earlier sections the open and close routines associated with a module get invoked when
the module is pushed onto a stream or when it is popped out of a stream.
Based on the module’s requirement, a module can:
•Verify that MODOPEN is specified in the sflag.
• Validate the open flags specified in the oflag.
• Validate the user credentials passed through credp.
int
mod_open(q, dev, oflag, sflag, credp)
queue_t *q;
dev_t *dev;
int oflag;
int sflag;
cred_t *credp;
{
mod_priv_t *modp; /* Pointer to the module's private data */
/*
* Allocate the module specific private data to be assigned to
* the q_ptr
*/
modp = (mod_priv_t *)kmem_alloc(sizeof(mod_priv_t), M_NOWAIT);