]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/makedev.3
0d987f5baa85c039fecbf05c06e6bd0c1b103e63
[thirdparty/man-pages.git] / man3 / makedev.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH MAKEDEV 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
7 .SH NAME
8 makedev, major, minor \- manage a device number
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ", " \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <sys/sysmacros.h>
15 .PP
16 .BI "dev_t makedev(unsigned int " maj ", unsigned int " min );
17 .PP
18 .BI "unsigned int major(dev_t " dev );
19 .BI "unsigned int minor(dev_t " dev );
20 .fi
21 .SH DESCRIPTION
22 A device ID consists of two parts:
23 a major ID, identifying the class of the device,
24 and a minor ID, identifying a specific instance of a device in that class.
25 A device ID is represented using the type
26 .IR dev_t .
27 .PP
28 Given major and minor device IDs,
29 .BR makedev ()
30 combines these to produce a device ID, returned as the function result.
31 This device ID can be given to
32 .BR mknod (2),
33 for example.
34 .PP
35 The
36 .BR major ()
37 and
38 .BR minor ()
39 functions perform the converse task: given a device ID,
40 they return, respectively, the major and minor components.
41 These macros can be useful to, for example,
42 decompose the device IDs in the structure returned by
43 .BR stat (2).
44 .SH ATTRIBUTES
45 For an explanation of the terms used in this section, see
46 .BR attributes (7).
47 .ad l
48 .nh
49 .TS
50 allbox;
51 lbx lb lb
52 l l l.
53 Interface Attribute Value
54 T{
55 .BR makedev (),
56 .BR major (),
57 .BR minor ()
58 T} Thread safety MT-Safe
59 .TE
60 .hy
61 .ad
62 .sp 1
63 .SH STANDARDS
64 The
65 .BR makedev (),
66 .BR major (),
67 and
68 .BR minor ()
69 functions are not specified in POSIX.1,
70 but are present on many other systems.
71 .\" The BSDs, HP-UX, Solaris, AIX, Irix.
72 .\" The header location is inconsistent:
73 .\" Could be sys/mkdev.h, sys/sysmacros.h, or sys/types.h.
74 .SH NOTES
75 These interfaces are defined as macros.
76 Since glibc 2.3.3,
77 they have been aliases for three GNU-specific functions:
78 .BR gnu_dev_makedev (),
79 .BR gnu_dev_major (),
80 and
81 .BR gnu_dev_minor ().
82 The latter names are exported, but the traditional names are more portable.
83 .PP
84 The BSDs expose the definitions for these macros via
85 .IR <sys/types.h> .
86 Depending on the version,
87 glibc also exposes definitions for these macros from that
88 header file if suitable feature test macros are defined.
89 However, this behavior was deprecated in glibc 2.25,
90 .\" glibc commit dbab6577c6684c62bd2521c1c29dc25c3cac966f
91 and since glibc 2.28,
92 .\" glibc commit e16deca62e16f645213dffd4ecd1153c37765f17
93 .I <sys/types.h>
94 no longer provides these definitions.
95 .SH SEE ALSO
96 .BR mknod (2),
97 .BR stat (2)