Current File : //usr/man/man9e/devmap_dup.9e
'\" te
.\"  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
.TH devmap_dup 9E "21 Jan 1997" "SunOS 5.11" "Driver Entry Points"
.SH NAME
devmap_dup \- device mapping duplication entry point
.SH SYNOPSIS
.LP
.nf
#include <sys/ddi.h>
#include <sys/sunddi.h

\fB int prefix\fR\fBdevmap_dup\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBvoid *\fR\fIpvtp\fR, 
     \fBdevmap_cookie_t\fR \fInew_dhp\fR, \fBvoid **\fR\fInew_pvtp\fR);
.fi

.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI).
.SH ARGUMENTS
.sp
.ne 2
.mk
.na
\fB\fIdhp\fR \fR
.ad
.RS 13n
.rt  
An opaque mapping handle that the system uses to describe the mapping currently being duplicated.
.RE

.sp
.ne 2
.mk
.na
\fB\fIpvtp\fR \fR
.ad
.RS 13n
.rt  
Driver private mapping data for the mapping currently being duplicated.
.RE

.sp
.ne 2
.mk
.na
\fB\fInew_dhp\fR \fR
.ad
.RS 13n
.rt  
An opaque data structure that the system uses to describe the duplicated device mapping.
.RE

.sp
.ne 2
.mk
.na
\fB\fInew_pvtp\fR \fR
.ad
.RS 13n
.rt  
A pointer to be filled in by device drivers with the driver private mapping data for the duplicated device mapping.
.RE

.SH DESCRIPTION
.sp
.LP
The system calls \fBdevmap_dup()\fR when a device mapping is duplicated, such as during the execution of the \fBfork\fR(2) system call.  The system expects \fBdevmap_dup()\fR to generate new driver private data for the new mapping, and to set \fInew_pvtp\fR to point to it. \fInew_dhp\fR is the handle of the new mapped object.
.sp
.LP
A non-zero return value from  \fBdevmap_dup()\fR will cause a corresponding operation such as \fBfork()\fR to fail.
.SH RETURN VALUES
.sp
.LP
\fBdevmap_dup()\fR returns the following values:
.sp
.ne 2
.mk
.na
\fB\fB0\fR \fR
.ad
.RS 12n
.rt  
Successful completion.
.RE

.sp
.ne 2
.mk
.na
\fBNon-zero\fR
.ad
.RS 12n
.rt  
An error occurred. 
.RE

.SH EXAMPLES
.sp
.in +2
.nf
static int
xxdevmap_dup(devmap_cookie_t dhp, void *pvtp, \e
    devmap_cookie_t new_dhp,
    void **new_pvtp)
{
    struct xxpvtdata    *prvtdata;
    struct xxpvtdata    *p = (struct xxpvtdata *)pvtp;
    struct xx_softc     *softc = p->softc;
    mutex_enter(&softc->mutex);
    /* Allocate a new private data structure */
    prvtdata = kmem_alloc(sizeof (struct xxpvtdata), KM_SLEEP);
    /* Return the new data */
    prvtdata->off = p->off;
    prvtdata->len = p->len;
    prvtdata->ctx = p->ctx;
    prvtdata->dhp = new_dhp;
    prvtdata->softc = p->softc;
    *new_pvtp = prvtdata;
    mutex_exit(&softc->mutex);
    return (0);
}
.fi
.in -2

.SH SEE ALSO
.sp
.LP
\fBfork\fR(2), \fBdevmap_callback_ctl\fR(9S) 
.sp
.LP
\fIWriting Device Drivers for Oracle Solaris 11.2\fR