OSDN Git Service

(split) LDP: Update original to LDP v3.41.
[linuxjm/LDP_man-pages.git] / original / man3 / makedev.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH MAKEDEV 3 2012-05-10 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 makedev, major, minor \- manage a device number
27 .SH SYNOPSIS
28 .nf
29 .BR "#define _BSD_SOURCE" "             /* See feature_test_macros(7) */"
30 .B #include <sys/types.h>
31
32 .BI "dev_t makedev(int " maj ", int " min );
33
34 .BI "unsigned int major(dev_t " dev );
35 .BI "unsigned int minor(dev_t " dev );
36
37 .fi
38 .SH DESCRIPTION
39 A device ID consists of two parts:
40 a major ID, identifying the class of the device,
41 and a minor ID, identifying a specific instance of a device in that class.
42 A device ID is represented using the type
43 .IR dev_t .
44
45 Given major and minor device IDs,
46 .BR makedev ()
47 combines these to produce a device ID, returned as the function result.
48 This device ID can be given to
49 .BR mknod (2),
50 for example.
51
52 The
53 .BR major ()
54 and
55 .BR minor ()
56 functions perform the converse task: given a device ID,
57 they return, respectively, the major and minor components.
58 These macros can be useful to, for example,
59 decompose the device IDs in the structure returned by
60 .BR stat (2).
61 .SH "CONFORMING TO"
62 The
63 .BR makedev (),
64 .BR major (),
65 and
66 .BR minor ()
67 functions are not specified in POSIX.1,
68 but are present on many other systems.
69 .\" The BSDs, HP-UX, Solaris, AIX, Irix
70 .SH NOTES
71 These interfaces are defined as macros.
72 Since glibc 2.3.3,
73 they have been aliases for three GNU-specific functions:
74 .BR gnu_dev_makedev (),
75 .BR gnu_dev_major (),
76 and
77 .BR gnu_dev_minor ().
78 The latter names are exported, but the traditional names are more portable.
79 .SH "SEE ALSO"
80 .BR mknod (2),
81 .BR stat (2)