1MAKEDEV(3)                 Linux Programmer's Manual                MAKEDEV(3)
2
3
4

NAME

6       makedev, major, minor - manage a device number
7

SYNOPSIS

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

DESCRIPTION

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

ATTRIBUTES

31       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
32       tributes(7).
33
34       ┌────────────────────────────────────────────┬───────────────┬─────────┐
35Interface                                   Attribute     Value   
36       ├────────────────────────────────────────────┼───────────────┼─────────┤
37makedev(), major(), minor()                 │ Thread safety │ MT-Safe │
38       └────────────────────────────────────────────┴───────────────┴─────────┘
39

CONFORMING TO

41       The  makedev(),  major(),  and  minor()  functions are not specified in
42       POSIX.1, but are present on many other systems.
43

NOTES

45       These interfaces are defined as macros.  Since glibc 2.3.3,  they  have
46       been  aliases  for  three  GNU-specific  functions:  gnu_dev_makedev(),
47       gnu_dev_major(), and gnu_dev_minor().  The latter names  are  exported,
48       but the traditional names are more portable.
49
50       The  BSDs  expose  the  definitions for these macros via <sys/types.h>.
51       Depending on the version, glibc  also  exposes  definitions  for  these
52       macros  from  that  header file if suitable feature test macros are de‐
53       fined.  However, this behavior was deprecated in glibc 2.25, and  since
54       glibc 2.28, <sys/types.h> no longer provides these definitions.
55

SEE ALSO

57       mknod(2), stat(2)
58

COLOPHON

60       This  page  is  part of release 5.13 of the Linux man-pages project.  A
61       description of the project, information about reporting bugs,  and  the
62       latest     version     of     this    page,    can    be    found    at
63       https://www.kernel.org/doc/man-pages/.
64
65
66
67Linux                             2021-03-22                        MAKEDEV(3)
Impressum