STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
STREAMS Driver
Chapter 4
101
* a non-clone open
*/
if (sflag != CLONEOPEN) {
/* Non-clone open */
...
} else {
/* Clone open */
...
*dev = makedev(major(*dev), dev_minor);
}
/*
* Allocate the driver specific private data to be assigned to
* the q_ptr (per-stream data)
*/
drvp = (drv_priv_t *)kmem_alloc(sizeof(drv_priv_t), M_NOWAIT);
if (!drvp) {
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 = drvp;
...
return 0 ; /* Success */
}
int
drv_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