1getmajor(9F)             Kernel Functions for Drivers             getmajor(9F)
2
3
4

NAME

6       getmajor - get major device number
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/mkdev.h>
11       #include <sys/ddi.h>
12
13
14
15       major_t getmajor(dev_t dev);
16
17

INTERFACE LEVEL

19       Architecture independent level 1 (DDI/DKI).
20

PARAMETERS

22       dev    Device number.
23
24

DESCRIPTION

26       The getmajor() function extracts the major number from a device number.
27

RETURN VALUES

29       The major number.
30

CONTEXT

32       The  getmajor()  function can be called from user, interrupt, or kernel
33       context.
34

EXAMPLES

36       Example 1 Using getmajor()
37
38
39       The following example shows both the getmajor() and getminor(9F)  func‐
40       tions  used  in  a  debug cmn_err(9F) statement to return the major and
41       minor numbers for the device supported by the driver.
42
43
44         dev_t dev;
45
46         #ifdef DEBUG
47         cmn_err(CE_NOTE,"Driver Started.  Major# = %d,
48              Minor# = %d", getmajor(dev), getminor(dev));
49         #endif
50
51

SEE ALSO

53       cmn_err(9F), getminor(9F), makedevice(9F)
54
55
56       Writing Device Drivers
57

WARNINGS

59       No validity checking is performed. If dev is invalid, an invalid number
60       is returned.
61
62
63
64SunOS 5.11                        16 Jan 2006                     getmajor(9F)
Impressum