xref: /netbsd-src/share/man/man3/makedev.3 (revision 9d0b321d433d3946d8442f94e1b2ac5f4df21de7)
1.\" $NetBSD: makedev.3,v 1.2 2011/04/01 06:03:06 jruoho Exp $
2.\"
3.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/share/man/man3/makedev.3,v 1.2 2008/09/28 20:26:16 ed Exp $
28.\"
29.Dd April 1, 2011
30.Dt MAKEDEV 3
31.Os
32.Sh NAME
33.Nm makedev ,
34.Nm major ,
35.Nm minor
36.Nd device number conversion
37.Sh SYNOPSIS
38.In sys/types.h
39.Ft dev_t
40.Fn makedev "int major" "int minor"
41.Ft int
42.Fn major "dev_t dev"
43.Ft int
44.Fn minor "dev_t dev"
45.Sh DESCRIPTION
46The
47.Fn makedev
48macro allows a unique device number to be generated based on its
49.Fa major
50and
51.Fa minor
52number.
53The
54.Fn major
55and
56.Fn minor
57macros can be used to obtain the original numbers from the device number
58.Fa dev .
59.Pp
60All block and character devices are uniquely
61identified by a pair of major and minor numbers.
62The major number refers to a certain device class (e.g. disks, TTYs)
63while the minor number identifies an instance within the device class.
64.Sh RETURN VALUES
65The
66.Fn major
67macro returns a device major number that has a value between 0 and 255.
68The
69.Fn minor
70macro returns a device minor number whose value can span the complete
71range of an
72.Vt int .
73.Sh SEE ALSO
74.Xr mknod 2 ,
75.Xr devname 3 ,
76.Xr MAKEDEV 8
77