1MAKEDEV(3) Linux Programmer's Manual MAKEDEV(3)
2
3
4
6 makedev, major, minor - manage a device number
7
9 #include <sys/sysmacros.h>
10
11 dev_t makedev(unsigned int maj, unsigned int min);
12
13 unsigned int major(dev_t dev);
14 unsigned int minor(dev_t dev);
15
17 A device ID consists of two parts: a major ID, identifying the class of
18 the device, and a minor ID, identifying a specific instance of a device
19 in that class. A device ID is represented using the type dev_t.
20
21 Given major and minor device IDs, makedev() combines these to produce a
22 device ID, returned as the function result. This device ID can be
23 given to mknod(2), for example.
24
25 The major() and minor() functions perform the converse task: given a
26 device ID, they return, respectively, the major and minor components.
27 These macros can be useful to, for example, decompose the device IDs in
28 the structure returned by stat(2).
29
31 For an explanation of the terms used in this section, see
32 attributes(7).
33
34 ┌────────────────────────────┬───────────────┬─────────┐
35 │Interface │ Attribute │ Value │
36 ├────────────────────────────┼───────────────┼─────────┤
37 │makedev(), major(), minor() │ Thread safety │ MT-Safe │
38 └────────────────────────────┴───────────────┴─────────┘
40 The makedev(), major(), and minor() functions are not specified in
41 POSIX.1, but are present on many other systems.
42
44 These interfaces are defined as macros. Since glibc 2.3.3, they have
45 been aliases for three GNU-specific functions: gnu_dev_makedev(),
46 gnu_dev_major(), and gnu_dev_minor(). The latter names are exported,
47 but the traditional names are more portable.
48
49 The BSDs expose the definitions for these macros via <sys/types.h>.
50 Depending on the version, glibc also exposes definitions for these
51 macros from that header file if suitable feature test macros are
52 defined. However, this behavior was deprecated in glibc 2.25, and
53 since glibc 2.28, <sys/types.h> no longer provides these definitions.
54
56 mknod(2), stat(2)
57
59 This page is part of release 5.04 of the Linux man-pages project. A
60 description of the project, information about reporting bugs, and the
61 latest version of this page, can be found at
62 https://www.kernel.org/doc/man-pages/.
63
64
65
66Linux 2018-04-30 MAKEDEV(3)