HP-UX Reference (11i v2 07/12) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
c
clone(7) clone(7)
NAME
clone - opens a major and minor device pair on a STREAMS driver
DESCRIPTION
The clone driver is a "pass through" device driver that allows other drivers to select unique minor device
numbers on each open(). In effect, the driver passes an open operation through to the other driver. This
mechanism allows for multiple instantiations of a driver, each with a different minor number, through a
single device file.
When the clone driver is opened, it is passed a major and minor device number by the operating system.
The major number is the clone driver’s major number (72), and the minor number is the major number of
the driver the user wishes to clone (referred to here as the target driver). The
clone driver calls the open
routine of the target driver with the
CLONEOPEN
flag which specifies a clone open. The target driver’s
open routine allocates an unused minor number. The target driver must use
makedev to make a new
device number for the newly created device, and must set
*devp to the new device number returned by
makedev. The new device number is returned to the
clone open through *devp. The clone open
then returns to the user a file descriptor that points to the new instantiation of the target driver.
The
echo driver is an example of a clonable driver.
Notes
It is not possible to do multiple opens of a device with the same major and minor number using the
clone
driver. This is because the clone driver is only given the major number of the driver to be cloned, and
that driver will then select a minor number which has not been opened.
When called with a pathname which corresponds to the clonable driver, stat() will return different
results than fstat() when it is called on a file descriptor returned from open() of the same clonable
driver pathname.
RETURN VALUE
If the
clone driver is given an invalid minor number, or if the driver indicated is not a clonable driver, the
open() fails and errno is set to [ENXIO].
SEE ALSO
open(2), fstat(2).
HP-UX 11i Version 2: December 2007 Update − 1 − Hewlett-Packard Company 31