STREAMS-UX Programmer's Guide (February 2007)
Modules and Drivers
STREAMS Module
Chapter 4
91
if (!modp) {
return 1 ; /* Failure */
}
/*
* Assign the private data structure to both the read and the write
* side q_ptr's.
*/
q->q_ptr = WR(q)->q_ptr = modp;
return 0 ; /* Success */
}
Based on a module’s requirement, a module should:
• Validate the flag value specified in the cflag.
• Validate the user credentials passed through credp.
• Cancel any pending timeout or bufcall routines that access data that are deinitialized or deallocated
during close.
• Deallocate any resources allocated on open.
int
mod_close(q, cflag, credp)
queue_t *q;
int cflag;
cred_t *credp
{
flushq(WQ(q), FLUSHALL);
/*
* Free any module specific resources allocated during open for
* this instance of the module.
*/
kmem_free((caddr_t)q->q_ptr, sizeof(mod_priv_t));
/*
* Assign NULL to both the read and the write side q_ptr's
*/
q->q_ptr = WR(q)->q_ptr = NULL;
return 0 ; /* Success */
}