| 1 |
'\" t |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH makedev 3 2025-05-17 "Linux man-pages 6.18" |
| 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 |
.P |
| 16 |
.BI "dev_t makedev(unsigned int " maj ", unsigned int " min ); |
| 17 |
.P |
| 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 |
.P |
| 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 |
.P |
| 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 |
.TS |
| 48 |
allbox; |
| 49 |
lbx lb lb |
| 50 |
l l l. |
| 51 |
Interface Attribute Value |
| 52 |
T{ |
| 53 |
.na |
| 54 |
.nh |
| 55 |
.BR makedev (), |
| 56 |
.BR major (), |
| 57 |
.BR minor () |
| 58 |
T} Thread safety MT-Safe |
| 59 |
.TE |
| 60 |
.SH VERSIONS |
| 61 |
The BSDs expose the definitions for these macros via |
| 62 |
.IR <sys/types.h> . |
| 63 |
.SH STANDARDS |
| 64 |
None. |
| 65 |
.SH HISTORY |
| 66 |
BSD, HP-UX, Solaris, AIX, Irix. |
| 67 |
.\" The header location is inconsistent: |
| 68 |
.\" Could be sys/mkdev.h, sys/sysmacros.h, or sys/types.h. |
| 69 |
.P |
| 70 |
These interfaces are defined as macros. |
| 71 |
Since glibc 2.3.3, |
| 72 |
they have been aliases for three GNU-specific functions: |
| 73 |
.BR gnu_dev_makedev (), |
| 74 |
.BR gnu_dev_major (), |
| 75 |
and |
| 76 |
.BR gnu_dev_minor (). |
| 77 |
The latter names are exported, but the traditional names are more portable. |
| 78 |
.P |
| 79 |
Depending on the version, |
| 80 |
glibc also exposes definitions for these macros from |
| 81 |
.I <sys/types.h> |
| 82 |
if suitable feature test macros are defined. |
| 83 |
However, this behavior was deprecated in glibc 2.25, |
| 84 |
.\" glibc commit dbab6577c6684c62bd2521c1c29dc25c3cac966f |
| 85 |
and since glibc 2.28, |
| 86 |
.\" glibc commit e16deca62e16f645213dffd4ecd1153c37765f17 |
| 87 |
.I <sys/types.h> |
| 88 |
no longer provides these definitions. |
| 89 |
.SH SEE ALSO |
| 90 |
.BR mknod (2), |
| 91 |
.BR stat (2) |