|
|
A clone device is a unique node in the file system that can be opened to access any unused device controlled by the specific driver. This special node guarantees that the user is allocated a unique device on every open( ) call, without requiring the calling process to poll a driver's minor device nodes to find an unused device.. Cloning is most often used in STREAMS drivers, where it guarantees the user a separate Stream that is associated with an unused device instance or, for SCO OpenServer 5 drivers and DDI versions prior to version 8, device number.
The clone device is useful, for example, in a networking environment where a protocol pseudo-device driver requires each user to open a separate Stream over which it establishes communication.
Clone behavior in DDI 8 drivers
is implemented as open redirection.
See the
open(D2)
manual page for details.
The $maxchan field of the
Node(DSP/4dsp)
file and the drv_maxchan
member of the
drvinfo(D4)
structure
should allow one channel for each special device file
that is defined in the Node file
plus one channel for each clone
open( )
that is supported.
So, if you anticipate needing 16 clone devices,
set $maxchan to 16.
Since the first channel is 0,
this creates 16 clone nodes plus the original node.
The $maxchan value determines
the number of channels are allocated
in the device table for the driver.
A clone device node can be created in the file system in one of two ways:
This causes the sflag argument to the open(D2) or open(D2oddi) entry point routine to be set to CLONEOPEN when /dev/net is opened.
This does not cause the sflag argument to the open( ) entry point routine to be set when /dev/net is opened. Instead, the driver has to designate a special minor device as its clone interface. When the clone is opened, the driver knows that it should look for an unused minor device. This implies that the reserved minor number for the clone entry point will never be given out.
For both methods, the driver returns the new device number as
devp = makedevice(getemajor(devp), newminor);
Note the following when using clone devices in ODDI and DDI versions prior to version 8: