STREAMS-UX Programmer's Guide (February 2007)

Multiplexing
STREAMS Multiplexor
Chapter 5
128
Installation Routine
Like other STREAMS drivers, STREAMS multiplexing drivers also need to configure the STREAMS specific
information by calling str_install() with a defined streams_info_t.
int
mux_install()
{
int retval;
if ((retval = (install_driver(&mux_info, &mux_drv_ops))) !=0)
return retval;
if ((retval = str_install(&mux_str_info)) !=0)
{
(void)uninstall_driver(&mux_info);
return retval;
}
return 0;
}
Open and Close Routines
The upper read queue contains the canonical driver open code. Each successful open of the multiplexor
updates the mux data structures in the mux_list, and assigns this address to the q_ptr of the upper read and
write queues. The minor number associated with the multiplexing driver is used as an index for mux_list.
The close routine below clears the mux entry set during the open, so that this queue will no longer be found.
int
mux_open(q, dev, oflag, sflag, credp)
queue_t *q; /* multiplexor’s upper read queue */
dev_t *dev;
int oflag;
int sflag;
cred_t *credp;
{
mux_data_t *muxp; /* Pointer to the multiplexor’s private data */
int index;
int minor_dev;
/*
* Assign a minor number depending on whether this is a clone or
* a non-clone open and make sure not to open more than MUXCNT streams.