]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/makedev.3
capabilities.7: Add pivot_root(2) to CAP_SYS_ADMIN list
[thirdparty/man-pages.git] / man3 / makedev.3
CommitLineData
47a0131a
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
47a0131a
MK
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.
4b72fb64 24.\" %%%LICENSE_END
47a0131a 25.\"
09b8afdc 26.TH MAKEDEV 3 2018-04-30 "Linux" "Linux Programmer's Manual"
47a0131a
MK
27.SH NAME
28makedev, major, minor \- manage a device number
29.SH SYNOPSIS
30.nf
3350a864 31.B #include <sys/sysmacros.h>
dbfe9c70 32.PP
eb696b73 33.BI "dev_t makedev(unsigned int " maj ", unsigned int " min );
dbfe9c70 34.PP
2540aee7
MK
35.BI "unsigned int major(dev_t " dev );
36.BI "unsigned int minor(dev_t " dev );
47a0131a 37.fi
47a0131a
MK
38.SH DESCRIPTION
39A device ID consists of two parts:
40a major ID, identifying the class of the device,
41and a minor ID, identifying a specific instance of a device in that class.
42A device ID is represented using the type
43.IR dev_t .
847e0d88 44.PP
47a0131a
MK
45Given major and minor device IDs,
46.BR makedev ()
47combines these to produce a device ID, returned as the function result.
48This device ID can be given to
49.BR mknod (2),
50for example.
847e0d88 51.PP
47a0131a
MK
52The
53.BR major ()
54and
55.BR minor ()
56functions perform the converse task: given a device ID,
57they return, respectively, the major and minor components.
58These macros can be useful to, for example,
59decompose the device IDs in the structure returned by
60.BR stat (2).
fce328e6
PH
61.SH ATTRIBUTES
62For an explanation of the terms used in this section, see
63.BR attributes (7).
64.TS
65allbox;
66lbw27 lb lb
67l l l.
68Interface Attribute Value
69T{
70.BR makedev (),
71.BR major (),
72.BR minor ()
73T} Thread safety MT-Safe
74.TE
47297adb 75.SH CONFORMING TO
47a0131a 76The
9afb166c
MK
77.BR makedev (),
78.BR major (),
47a0131a
MK
79and
80.BR minor ()
81functions are not specified in POSIX.1,
82but are present on many other systems.
3350a864
MF
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.
47a0131a
MK
86.SH NOTES
87These interfaces are defined as macros.
88Since glibc 2.3.3,
89they have been aliases for three GNU-specific functions:
27d47e71
MK
90.BR gnu_dev_makedev (),
91.BR gnu_dev_major (),
47a0131a 92and
27d47e71 93.BR gnu_dev_minor ().
47a0131a 94The latter names are exported, but the traditional names are more portable.
847e0d88 95.PP
85a40055 96The BSDs expose the definitions for these macros via
1e50980d 97.IR <sys/types.h> .
517b7ac4 98Depending on the version,
1e50980d 99glibc also exposes definitions for these macros from that
517b7ac4
MK
100header file if suitable feature test macros are defined.
101However, this behavior was deprecated in glibc 2.25,
d2414cb5 102.\" glibc commit dbab6577c6684c62bd2521c1c29dc25c3cac966f
a706f0e0 103and since glibc 2.28,
517b7ac4
MK
104.\" glibc commit e16deca62e16f645213dffd4ecd1153c37765f17
105.IR <sys/types.h>
106no longer provides these definitions.
47297adb 107.SH SEE ALSO
47a0131a
MK
108.BR mknod (2),
109.BR stat (2)