STREAMS-UX Programmer's Guide (February 2007)
Modules and Drivers
STREAMS Driver
Chapter 4
100
Installation Routine
Like STREAMS modules, STREAMS drivers need to configure the STREAMS specific information by calling
str_install() with a defined streams_info_t. In addition, since drivers do have cdevsw information, a call
to install_driver() should be made before the configuration for streams is done in str_install().
int
drv_install()
{
int retval;
if ((retval = (install_driver(&drv_info, &drv_ops))) !=0)
return retval;
if ((retval = str_install(&drv_str_info)) !=0) {
(void)uninstall_driver(&drv_info);
return retval;
}
return 0;
}
Open/Close Routines
At the system interface, the hardware device drivers and the character I/O drivers generally have direct entry
points to process open, close, read, write, IOCTL and select calls. For the STREAMS drivers however
these entry points are accessed via STREAMS and their format differs from the non-STREAMS character
device drivers (drv_ops_t for a STREAMS driver is usually NULL).
The STREAMS mechanism allows only one stream per minor device. The driver open is called whenever a
STREAMS device is opened.
int
drv_open(q, dev, oflag, sflag, credp)
queue_t *q;
dev_t *dev;
int oflag;
int sflag;
cred_t *credp;
{
drv_priv_t *drvp; /* Pointer to the module's private data */
dev_t dev_minor;
/*
* Assign a minor number depending on whether this is a clone or