'\" te .\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH DEVMAP_DUP 9E "June 18, 2021" .SH NAME devmap_dup \- device mapping duplication entry point .SH SYNOPSIS .nf #include #include \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 illumos DDI specific (illumos DDI). .SH ARGUMENTS .ne 2 .na \fB\fIdhp\fR \fR .ad .RS 13n An opaque mapping handle that the system uses to describe the mapping currently being duplicated. .RE .sp .ne 2 .na \fB\fIpvtp\fR \fR .ad .RS 13n Driver private mapping data for the mapping currently being duplicated. .RE .sp .ne 2 .na \fB\fInew_dhp\fR \fR .ad .RS 13n An opaque data structure that the system uses to describe the duplicated device mapping. .RE .sp .ne 2 .na \fB\fInew_pvtp\fR \fR .ad .RS 13n A pointer to be filled in by device drivers with the driver private mapping data for the duplicated device mapping. .RE .SH DESCRIPTION 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 \fBdevmap_dup()\fR returns the following values: .sp .ne 2 .na \fB\fB0\fR \fR .ad .RS 12n Successful completion. .RE .sp .ne 2 .na \fBNon-zero\fR .ad .RS 12n An error occurred. .RE .SH EXAMPLES .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 \fBfork\fR(2), \fBdevmap_callback_ctl\fR(9S) .sp .LP \fIWriting Device Drivers\fR