xref: /openbsd/share/man/man3/makedev.3 (revision 09467b48)
1.\"	$OpenBSD: makedev.3,v 1.2 2019/01/25 00:19:26 millert Exp $
2.\"
3.\" Copyright (c) 2014 Todd C. Miller <millert@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 25 2019 $
18.Dt MAKEDEV 3
19.Os
20.Sh NAME
21.Nm makedev ,
22.Nm major ,
23.Nm minor
24.Nd create or extract device numbers
25.Sh SYNOPSIS
26.In sys/types.h
27.Ft dev_t
28.Fn makedev "unsigned int maj" "unsigned int min"
29.Ft unsigned int
30.Fn major "dev_t dev"
31.Ft unsigned int
32.Fn minor "dev_t dev"
33.Sh DESCRIPTION
34On
35.Ox ,
36all devices on the system are assigned a unique number which consists
37of a major and minor component.
38Typically, the major number identifies the kind of device and
39the minor number identifies a specific instance of the device.
40.Pp
41The
42.Fn makedev
43macro is used to combine a major and minor device number into
44a form suitable for use with the
45.Xr mknod 2
46system call.
47.Pp
48The
49.Fn major
50macro extracts the major number from the specified device number.
51.Pp
52The
53.Fn minor
54macro extracts the minor number from the specified device number.
55.Sh RETURN VALUES
56The
57.Fn makedev
58macro returns a combined device number from the specified major and
59minor numbers.
60.Pp
61The
62.Fn major
63macro returns the major number corresponding to the specified device number.
64.Pp
65The
66.Fn minor
67macro returns the minor number corresponding to the specified device number.
68.Sh SEE ALSO
69.Xr mknod 2 ,
70.Xr intro 4
71.Sh STANDARDS
72The
73.Fn makedev ,
74.Fn major ,
75and
76.Fn minor
77macros are not standardized by
78.St -p1003.1
79but are available on most systems.
80.Sh HISTORY
81The
82.Fn makedev ,
83.Fn major ,
84and
85.Fn minor
86macros first appeared in
87.At v7 .
88.Sh CAVEATS
89On some systems,
90.Fn makedev ,
91.Fn major ,
92and
93.Fn minor
94are implemented as functions rather than macros.
95