GETMAJOR(9F) Kernel Functions for Drivers GETMAJOR(9F)

getmajor - get major device number

#include <sys/types.h>
#include <sys/mkdev.h>
#include <sys/ddi.h>
major_t getmajor(dev_t dev);

Architecture independent level 1 (DDI/DKI).

dev

Device number.

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

The major number.

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

Example 1 Using getmajor()

The following example shows both the getmajor() and getminor(9F) functions used in a debug cmn_err(9F) statement to return the major and minor numbers for the device supported by the driver.


dev_t dev;
#ifdef DEBUG
cmn_err(CE_NOTE,"Driver Started.  Major# = %d, 	

Minor# = %d", getmajor(dev), getminor(dev)); #endif

cmn_err(9F), getminor(9F), makedevice(9F)

Writing Device Drivers

No validity checking is performed. If dev is invalid, an invalid number is returned.

January 16, 2006 OmniOS