cfgadev
Purpose
Adds a device.
Library
Run-time Services Library (librts.a)
Syntax
#include <cfg01.h>
int cfgadev (master, system, xstanza, vstanza, dstanza, vflag, cflag)
char *master, *system, *xstanza, *vstanza, *dstanza;
int vflag, cflag;
Description
The cfgadev subroutine adds information about devices and
device drivers to the system configuration.
The master parameter points to the full path name of the
master file. The system parameter points to the full
path name of the system file. These files are usually
/etc/master and /etc/system, respectively.
The xstanza, vstanza, and dstanza parameters point to
buffers that contain the text of attribute file stanzas.
Any one or two of these parameters can be NULL pointers,
indicating that a stanza of that type is not to be added,
but at least one of them must point to a stanza buffer.
The xstanza parameter points to an AIX device driver
stanza to be added to the master file. If the major
device number is missing from the stanza, then the
cfgadev subroutine generates a new one, beginning with
decimal 20.
The vstanza parameter points to a VRM device driver
stanza to be added to the master file. If the IOCN is
missing from the stanza, then the cfgadev subroutine gen-
erates a new one, beginning with decimal 1024.
The dstanza parameter points to a device stanza to be
added to the system file. If the IODN is missing from
the stanza, then the cfgadev subroutine generates a new
one, beginning with decimal 12000. It also generates a
minor device number if only the prefix is supplied or if
the value is not unique.
The vflag parameter is either 1 (for "yes") or 0 (for
"no"), indicating whether to execute the vrmconfig
command after the device stanza is added. If the vflag
parameter is 1, then cfgadev executes the vrmconfig
command with the -a stname flag, where stname is the name
of the device stanza. The vrmconfig command then proc-
esses this stanza for driver addition and produces a
shell procedure. The cfgadev subroutine then runs this
shell procedure, which creates the special file
/dev/stname, where stname is the name of the device
stanza in the system file. If the vrmconfig command
returns an error, then all stanzas that were added to the
master and system files are deleted.
The cflag parameter is either 1 (for "yes") or 0 (for
"no"), indicating whether to attempt to associate the VRM
device driver stanza with one that has been defined pre-
viously. If the cflag parameter is 1, then the cfgadev
subroutine gets the VRM device driver stanza associated
with the device being added. If this VRM device driver
stanza contains a code keyword, then cfgadev searches
through the master file for other stanzas that contain
the same code keyword value and that are associated with
a device stanza, in the system file, with the same dtype
value. If another stanza is found and if that stanza is
defined before the stanza for the device being added,
then the cfgadev subroutine replaces the code keyword
with a copy keyword to copy the stanza that was found.
If the VRM device driver stanza contains a copy keyword,
then cfgadev verifies that the stanza it is copying is
defined before the VRM device driver stanza of the device
being added.
If the device stanza pointed to by the dstanza parameter
contains the admgr keyword, then its value specifies the
name of the device manager's stanza in the system file.
The new device is added to the vdmgr keyword value list
in the device manager's stanza.
If the device stanza pointed to by the dstanza parameter
contains the specproc keyword, then the program specified
by the value of this keyword is executed to perform any
special processing required when adding this device. The
value of the specproc keyword must be the full path name
of an executable file. The following arguments are
passed to the program using the argv mechanism described
in "exec: execl, execv, execle, execve, execlp, execvp."
All of them are passed as character strings.
argv[0| The full path name of the special-processing
program
argv[1| The full path name of the master file
argv[2| The full path name of the system file
argv[3| The name of the device stanza
argv[4| The character string ""a"", indicating addi-
tion.
If the special processing program fails, then the device
is still added to the system, but additional steps may be
required before it can be used.
Return Value
Upon successful completion, the value CFG_SUCC is
returned. If the cfgadev subroutine fails, then one of
the following values is returned:
CFG_BEMP The xstanza, vstanza, and dstanza parameters
are all NULL pointers.
CFG_BFIC An input stanza is incomplete, or necessary
information is missing.
CFG_BFNA A failure occurred while adding a stanza to
the master or system file.
CFG_BFSM An input stanza buffer cannot be updated
because the buffer is too small.
CFG_CFLI The cflag parameter is 1, but the device
stanza pointed to by the dstanza parameter
contains nocopy = true. Or, the VRM device
driver stanza for the new device contains a
copy keyword, but the stanza that it copies
is not defined before it in the /etc/master
file.
CFG_CLSE An error was detected while trying to close a
file.
CFG_FCOR The master or system file is set up incor-
rectly.
CFG_MALF Memory allocation failed because of insuffi-
cient space.
CFG_MAXM The maximum number of minor device numbers
has been reached for the driver associated
with the device being added.
CFG_MGRF A failure occurred while updating the device
manager's stanza.
CFG_MPRE The prefix of the device's minor number is
neither b nor c.
CFG_OPNE An error was detected while trying to open a
file.
CFG_SLPF Special processing failed. The device was
added but may require some additional steps
before it can be used.
CFGT_VLNG An IOCN value, an IODN value, or a major
device number could not be generated to com-
plete an input stanza.
CFG_VCFG The vrmconfig command failed.
File
/etc/specials
Related Information
In this book: "attributes," "master," and "system."
The vrmconfig command in AIX Operating System Commands
Reference.