'\"macro stdmacro
.if n .pH ddi_dki.itoemajor @(#)itoemajor	40.7 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} itoemajor D3D "3B2" "DDI" "\&"
.if \nX=1 .ds x} itoemajor D3D "3B2" "DDI"
.if \nX=2 .ds x} itoemajor D3D "" "\&"
.if \nX=3 .ds x} itoemajor "" "" "\&"
.TH \*(x}
.IX "\f4itoemajor\fP(D3D)"
.SH NAME
\f4itoemajor\f1 \- convert internal to external major device number
.IX "major device number"
.SH SYNOPSIS
.nf
.na
\f4#include <sys/types.h>
#include <sys/ddi.h>
.sp 0.5
int itoemajor(major_t \f2imaj, \f4int \f2prevemaj\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2imaj\f1" 10n
An internal major number.
.IP "\f2prevemaj\f1" 10n
Most recently obtained external major number (or \f4NODEV\f1,
if this is the first
time the function has been called).
.RE
.SH DESCRIPTION
\f4itoemajor\f1 converts the internal major number to the external major
number.  The external-to-internal major number mapping is
many-to-one, and so any internal major number may correspond to more than
one external major number.  By repeatedly invoking this function and
passing the most recent external major number obtained, the driver can
obtain all possible external major number values.
.SH RETURN VALUE
External major number, or \f4NODEV\f1, if all have been searched
.SH LEVEL
Base or Interrupt
.SH SEE ALSO
.na
\f4getemajor\f1(D3D),
\f4geteminor\f1(D3D),
\f4etoimajor\f1(D3D),
\f4getmajor\f1(D3DK),
\f4getminor\f1(D3DK),
\f4makedevice\f1(D3DK)
.ad
.ig
	.SH EXAMPLE
	\f4itoemajor\f1 is used to convert an internal major 
	device number into an external major device
	number.  In this example, a disk 
	driver wishes to register itself with
	the hard disk error logger.
	Since the driver already knows its internal major device
	number (through the use of \f4#M\f1 in 
	its master file), the following code is included in
	the driver \f4init\f1(D2D) routine:
	.P
	.RS
	.ft 4
	.nf
	if ((myemajor = itoemajor(myimajor, -1)) != -1) {
	gfor (i = 0; i < NDISK; i++) {
			mydev = makedevice(myemajor, myfirstminor[i]);
			hdeeqd(mydev, MYPDBLKNO, EQD_ID);
		}
	}
	.fi
	.ft 1
	.RE
..
