poll.2: Remove <signal.h>
[man-pages.git] / man3 / makedev.3
blobf4e84170ed4bcc94d9f1ce9506eb6954c4501901
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH MAKEDEV 3 2021-03-22 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 makedev, major, minor \- manage a device number
29 .SH SYNOPSIS
30 .nf
31 .B #include <sys/sysmacros.h>
32 .PP
33 .BI "dev_t makedev(unsigned int " maj ", unsigned int " min );
34 .PP
35 .BI "unsigned int major(dev_t " dev );
36 .BI "unsigned int minor(dev_t " dev );
37 .fi
38 .SH DESCRIPTION
39 A device ID consists of two parts:
40 a major ID, identifying the class of the device,
41 and a minor ID, identifying a specific instance of a device in that class.
42 A device ID is represented using the type
43 .IR dev_t .
44 .PP
45 Given major and minor device IDs,
46 .BR makedev ()
47 combines these to produce a device ID, returned as the function result.
48 This device ID can be given to
49 .BR mknod (2),
50 for example.
51 .PP
52 The
53 .BR major ()
54 and
55 .BR minor ()
56 functions perform the converse task: given a device ID,
57 they return, respectively, the major and minor components.
58 These macros can be useful to, for example,
59 decompose the device IDs in the structure returned by
60 .BR stat (2).
61 .SH ATTRIBUTES
62 For an explanation of the terms used in this section, see
63 .BR attributes (7).
64 .ad l
65 .nh
66 .TS
67 allbox;
68 lbx lb lb
69 l l l.
70 Interface       Attribute       Value
72 .BR makedev (),
73 .BR major (),
74 .BR minor ()
75 T}      Thread safety   MT-Safe
76 .TE
77 .hy
78 .ad
79 .sp 1
80 .SH CONFORMING TO
81 The
82 .BR makedev (),
83 .BR major (),
84 and
85 .BR minor ()
86 functions are not specified in POSIX.1,
87 but are present on many other systems.
88 .\" The BSDs, HP-UX, Solaris, AIX, Irix.
89 .\" The header location is inconsistent:
90 .\" Could be sys/mkdev.h, sys/sysmacros.h, or sys/types.h.
91 .SH NOTES
92 These interfaces are defined as macros.
93 Since glibc 2.3.3,
94 they have been aliases for three GNU-specific functions:
95 .BR gnu_dev_makedev (),
96 .BR gnu_dev_major (),
97 and
98 .BR gnu_dev_minor ().
99 The latter names are exported, but the traditional names are more portable.
101 The BSDs expose the definitions for these macros via
102 .IR <sys/types.h> .
103 Depending on the version,
104 glibc also exposes definitions for these macros from that
105 header file if suitable feature test macros are defined.
106 However, this behavior was deprecated in glibc 2.25,
107 .\" glibc commit dbab6577c6684c62bd2521c1c29dc25c3cac966f
108 and since glibc 2.28,
109 .\" glibc commit e16deca62e16f645213dffd4ecd1153c37765f17
110 .IR <sys/types.h>
111 no longer provides these definitions.
112 .SH SEE ALSO
113 .BR mknod (2),
114 .BR stat (2)