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 glibc also exposes definitions for these macros from that header file
51 if suitable feature test macros are defined, but this is deprecated
52 since glibc 2.25 and will be removed in the future.
53
55 mknod(2), stat(2)
56
58 This page is part of release 4.15 of the Linux man-pages project. A
59 description of the project, information about reporting bugs, and the
60 latest version of this page, can be found at
61 https://www.kernel.org/doc/man-pages/.
62
63
64
65Linux 2017-09-15 MAKEDEV(3)