rsrcdbmgr_devno_attach()

Get major and minor device numbers

Synopsis:

#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

dev_t rsrcdbmgr_devno_attach( const char * name,
                              int minor_request,
                              int flags );

Arguments:

name
The name of the class of devices that you want to get the major number for. This string can be anything, but various names are defined in in <sys/ftype.h>; see Class names,” below.
minor_request
The minor device number that you want to reserve, or -1 to let the system assign the next available minor number.
flags
Presently, there are no flags; pass zero for this argument.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The function rsrcdbmgr_devno_attach() reserves a device number that consists of:

There's a maximum of 64 major numbers (0 through 63) on the system, and a maximum of 1024 minor numbers (0 through 1023) per major number.

Major and minor numbers are used only by resource managers and are exposed through the rdev member of the iofunc_attr_t structure , and correspondingly the st_rdev member of the stat structure. They aren't required for proper operation; on simple devices, an entry will be simulated for you.

Class names

As mentioned above, the name of the class of devices can be anything. The following class names are defined in <sys/ftype.h>:

Constant Value Class
_MAJOR_PATHMGR "pathmgr" Used only by the path manager
_MAJOR_DEV "dev" Devices in /dev with only one instance (e.g. /dev/tty)
_MAJOR_BLK_PREFIX "blk-" All block devices (e.g. /dev/hd[0-9]* would be "blk-hd")
_MAJOR_CHAR_PREFIX "char-" All character devices (e.g. /dev/ser[0-9]* would be "char-ser")
_MAJOR_FSYS "fsys" All filesystems

Returns:

A dev_t object that contains the major and minor numbers, or -1 if an error occurs (errno is set).

You can extract the major and minor number values from the dev_t object by using the major() and minor() macros defined in <sys/types.h>. For more information, see the documentation for stat().

Errors:

EINVAL
Invalid argument.

Examples:

#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

char      *dev_name;
int       myminor_request, flags=0;
dev_t     major_minor;

major_minor = rsrcdbmgr_devno_attach
              ( dev_name, myminor_request, flags );

…

rsrcdbmgr_devno_detach( major_minor, flags );

Classification:

QNX Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

If your application calls this function, it must run as root.

See also:

iofunc_attr_t, rsrcdbmgr_attach(), rsrcdbmgr_devno_detach(), stat()