xref: /titanic_50/usr/src/man/man9f/getmajor.9f (revision a0563a48b6bba0177dc249048ea515ca080c73af)
te
Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
Copyright 1989 AT&T
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
GETMAJOR 9F "Jan 16, 2006"
NAME
getmajor - get major device number
SYNOPSIS

#include <sys/types.h>
#include <sys/mkdev.h>
#include <sys/ddi.h>



major_t getmajor(dev_t dev);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
dev

Device number.

DESCRIPTION

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

RETURN VALUES

The major number.

CONTEXT

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

EXAMPLES

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
SEE ALSO

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

Writing Device Drivers

WARNINGS

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