Get major and minor device numbers
#include <sys/rsrcdbmgr.h> #include <sys/rsrcdbmsg.h> dev_t rsrcdbmgr_devno_attach( const char * name, int minor_request, int flags );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
As mentioned above, the name of the class of devices can be anything. The following class names are defined in <sys/ftype.h>:
|_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")|
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().
#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 );
If your application calls this function, it must run as root.
iofunc_attr_t, rsrcdbmgr_attach(), rsrcdbmgr_devno_detach(), stat()