]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/makedev.3
makedev.3: glibc has deprecated exposing the definitions via <sys/types.h>
[thirdparty/man-pages.git] / man3 / makedev.3
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 2017-09-15 "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 .TS
65 allbox;
66 lbw27 lb lb
67 l l l.
68 Interface Attribute Value
69 T{
70 .BR makedev (),
71 .BR major (),
72 .BR minor ()
73 T} Thread safety MT-Safe
74 .TE
75 .SH CONFORMING TO
76 The
77 .BR makedev (),
78 .BR major (),
79 and
80 .BR minor ()
81 functions are not specified in POSIX.1,
82 but are present on many other systems.
83 .\" The BSDs, HP-UX, Solaris, AIX, Irix.
84 .\" The header location is inconsistent:
85 .\" Could be sys/mkdev.h, sys/sysmacros.h, or sys/types.h.
86 .SH NOTES
87 These interfaces are defined as macros.
88 Since glibc 2.3.3,
89 they have been aliases for three GNU-specific functions:
90 .BR gnu_dev_makedev (),
91 .BR gnu_dev_major (),
92 and
93 .BR gnu_dev_minor ().
94 The latter names are exported, but the traditional names are more portable.
95 .PP
96 The BSDs expose the definitions for these macros via
97 .IR <sys/types.h> .
98 glibc also exposes definitions for these macros from that
99 header file if suitable feature test macros are defined,
100 but this is deprecated and will be removed in the future.
101 .SH SEE ALSO
102 .BR mknod (2),
103 .BR stat (2)