[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 2

genminor Device Configuration Subroutine


Generates either the smallest unused minor number available for a device, a preferred minor number if it is available, or a set of unused minor numbers for a device.


#include <cf.h>
#include <sys/cfgodm.h>
#include <sys/cfgdb.h>
long *genminor (device_instance, major_no, preferred_minor,
     minors_in_grp, inc_within_grp, inc_btwn_grp)
char *device_instance;
long major_no;
int preferred_minor;
int minors_in_grp;
int inc_within_grp;
int inc_btwn_grp;


device_instance Points to a character string containing the device instance name.
major_no Contains the major number of the device instance.
preferred_minor Contains a single preferred minor number or a starting minor number for generating a set of numbers. In the latter case, the genminor subroutine can be used to get a set of minor numbers in a single call.
minors_in_grp Indicates how many minor numbers are to be allocated.
inc_within_grp Indicates the interval between minor numbers.
inc_btwn_grp Indicates the interval between groups of minor numbers.


The genminor device configuration subroutine is one of the designated routines for accessing the Customized Device Driver (CuDv) object class. To ensure that unique numbers are generated, the object class is locked by this routine until its completion.

If a single preferred minor number needs to be allocated, it should be given in the preferred_minor parameter. In this case, the other parameters should contain an integer value of 1. If the desired number is available, it is returned. Otherwise, a null pointer is returned, indicating that the requested number is in use.

If the caller has no preference and only requires one minor number, this should be indicated by passing a value of -1 in the preferred_minor parameter. The other parameters should all contain the integer value of 1. In this case, the genminor subroutine returns the lowest available minor number.

If a set of numbers is desired, then every number in the designated set must be available. An unavailable number is one that has already been assigned. To get a specific set of minor numbers allocated, the preferred_minor parameter contains the starting minor number. If this set has a minor number that is unavailable, then the genminor subroutine returns a null pointer indicating failure.

If the set of minor numbers needs to be allocated with the first number beginning on a particular boundary (that is, a set beginning on a multiple of 8), then a value of -1 should be passed in the preferred_minor parameter. The inc_btwn_grp parameter should be set to the multiple desired. The genminor subroutine uses the inc_btwn_grp parameter to find the first complete set of available minor numbers.

If a list of minor numbers is to be returned, the return value points to the first in a list of preferred minor numbers. This pointer can then be incremented to move through the list to access each minor number. The minor numbers are returned in ascending sorted order.

Return Values

In the case of failure, a null pointer is returned. If the genminor subroutine succeeds, a pointer is returned to the lowest available minor number or to a list of minor numbers.


/usr/lib/libcfg.a Archive of device configuration subroutines.

Related Information

The genmajor device configuration subroutine, getminor device configuration subroutine, reldevno device configuration subroutine.

List of ODM Commands and Subroutines in AIX General Programming Concepts: Writing and Debugging Programs.

Customized Device Driver (CuDvDr) object class.

List of Device Configuration Subroutines.

[ Previous | Next | Contents | Home | Search ]