HPlogo STREAMS/UX for the HP 9000 Reference Manual > Chapter 3 Differences Between STREAMS/UX and System V Release 4 STREAMS

HP-UX Changes to Cloning

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

STREAMS/UX supports two methods of cloning. See the SVR4.2 STREAMS manual for more information about cloning. Some differences exist between HP-UX cloning and SVR4.2 cloning.

The first cloning method uses a special clone major number, 72, to provide cloning. For each cloneable device, a device file must exist that has the clone major number of 72 and also has a minor number equal to the major number of the real device. When an application opens this type of device file, STREAMS/UX passes the driver open routine CLONEOPEN in the sflag parameter. The driver allocates a minor number and returns a new device number containing the true major number and the chosen minor number. The driver uses either makdev or to create the new device number.

The second cloning method is useful for drivers which need to be able to encode information in their minor numbers. This is not possible in the first method, as the clone device file for that method must have as its minor number the major number of the driver being cloned.

In the second cloning method, the driver designates a particular minor number as its "clone" minor number. The driver open routine checks the minor number portion of the device number parameter passed to it, and if it is the clone minor number, the driver open routine allocates a minor number and returns a new device number to the caller, in the same way as the first cloning method described above. The returned device number must contain both a major number and the new minor number. A driver using this cloning method may also change the major number in the device number it returns. However, the new major number must correspond to a STREAMS/UX driver with the same streamtab structure as the driver associated with the original major number. Also, on a multiprocessor system, if the original driver was MP scalable, the new one must be too. Likewise, if the original was UP emulation, the new one must be also.

Drivers using the second cloning method must indicate this in their install functions or master file entries. See Chapter 5 for more information about configuring STREAMS/UX drivers. Install functions must set the C_CLONESMAJOR flag. For example:

INSTALL FUNCTION CONFIGURATION

static drv_info_t example_drv_info = { /*driver information*/
"example", /* name */
"pseudo", /* class */
DRV_CHAR | DRV_PSEUDO, /* flags */
-1, /* block major number */
-1, /* dynamically assigned
character major number */
NULL, NULL, NULL, /* cdio, gio_private,and
cdio_private structures */
}

static drv_ops_t example_drv_ops = { /* driver entry points */
NULL, /* open */
NULL, /* close */
NULL, /* strategy */
NULL, /* dump */
NULL, /* psize */
NULL, /* mount */
NULL, /* read */
NULL, /* write */
NULL, /* ioctl */
NULL, /* select */
NULL, /* option1 */
NULL, NULL, NULL, NULL, /* reserved entry points */
C_CLONESMAJOR, /* ****NOTE****C_CLONESMAJOR
flag set */
}

static streams_info_t example_str_info = { /* streams information */
example, /* name */
-1, /* dynamically assigned major
number */
{ &examplerinit, &examplewinit,
NULL,NULL }, /* streamtab */
STR_IS_DEVICE, /* flags */
0, /* synchronization level */
"", /* elsewhere sync name */
}

int
example_install()
{
int retval;
MASTER FILE ENTRY

$DRIVER_INSTALL
* Driver Block major Char major
example 1 -1

if ((retval = install_driver(&example_drv_info, &example_drv_ops))!= 0)
return(retval);

/* Configure streams specific parameters. */
if ((retval = str_install(&example_str_info)) != 0) {
uninstall_driver(&example_drv_info);
return(retval);
}

/* Success */
return 0;

}

For definition in the $DEVICE table in the driver's master file entry, set the 0x8000 bit in the mask field to use the second cloning method. For example:

MASTER FILE $DEVICE TABLE CONFIGURATION

name handle type mask block char

example exampleinfo 21 80FC -1 75 /* 0x8000 set in mask */
© 1995 Hewlett-Packard Development Company, L.P.