]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man3/makedev.3
zfs: merge openzfs/zfs@233d34e47
[FreeBSD/FreeBSD.git] / share / man / man3 / makedev.3
1 .\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .Dd August 3, 2017
26 .Dt MAKEDEV 3
27 .Os
28 .Sh NAME
29 .Nm makedev ,
30 .Nm major ,
31 .Nm minor
32 .Nd device number conversion
33 .Sh SYNOPSIS
34 .In sys/types.h
35 .Ft dev_t
36 .Fn makedev "int major" "int minor"
37 .Ft int
38 .Fn major "dev_t dev"
39 .Ft int
40 .Fn minor "dev_t dev"
41 .Sh DESCRIPTION
42 The
43 .Fn makedev
44 macro returns a device number created from the provided
45 .Fa major
46 and
47 .Fa minor
48 number.
49 The
50 .Fn major
51 and
52 .Fn minor
53 macros return the original numbers from the device number
54 .Fa dev .
55 In other words, for a value
56 .Va dev
57 of the type
58 .Vt dev_t ,
59 and values
60 .Va ma , mi
61 of the type
62 .Vt int ,
63 the assertions
64 .Dl dev == makedev(major(dev), minor(dev))
65 .Dl ma == major(makedev(ma, mi))
66 .Dl mi == minor(makedev(ma, mi))
67 are valid.
68 .Pp
69 In previous implementations of
70 .Fx
71 all block and character devices were uniquely identified by a pair of
72 stable major and minor numbers.
73 The major number referred to a certain device class (e.g. disks, TTYs)
74 while the minor number identified an instance within the device class.
75 Later versions of
76 .Fx
77 automatically generate a unique device number for each character device
78 visible in
79 .Pa /dev/ .
80 These numbers are not divided in device classes and are not guaranteed
81 to be stable upon reboot or driver reload.
82 .Pp
83 On
84 .Fx
85 these macros are only used by utilities that need to exchange numbers
86 with other operating systems that may use different encodings for
87 .Vt dev_t ,
88 but also applications that present these numbers to the user in a more
89 conventional way.
90 .Sh RETURN VALUES
91 The
92 .Fn major
93 and
94 .Fn minor
95 macros return numbers whose value can span the complete range of an
96 .Vt int .
97 .Sh SEE ALSO
98 .Xr mknod 2 ,
99 .Xr devname 3 ,
100 .Xr devfs 5