cfg_query(9r)cfg_query(9r)NAMEcfg_query - General: Determines the values of selected subsystem
attributes
SYNOPSIS
#include <sys/sysconfig.h> ); cfg_status_t cfg_query(
char *subsys,
cfg_attr_t *attributes,
uint nattributes );
ARGUMENTS
Specifies the name of the subsystem to be queried. Contains informa‐
tion, such as attribute name, about the list of attributes being
queried. The array must have (nattributes + 1) cfg_attr_t structures
with the attribute name of the last one being set to a null string.
Specifies the number of attributes in the attributes argument being
queried.
DESCRIPTION
The cfg_query( ) routine obtains information about a list of subsystem
attributes. You can obtain information about one or more attributes.
When your application calls the cfg_query( ) routine, it passes the
subsystem name and a list of attribute names to the system. The system
reads this information, determines the validity of the information
about the named attributes, and returns the attribute value and a suc‐
cess status or an error status.
When your application calls the cfg_query( ) routine, it passes a list
of attribute names. The application passes this information in an array
of structures of type cfg_attr_t. For information about this structure,
see the cfg_subsys_query(3) reference page.
RETURN VALUES
This routine returns 32-bit status values composed of subsystem status
and framework status segments. The upper 16 bits is the subsystem sta‐
tus (CFG_STATUS_SUBSYS) and the lower 16 bits is the frame status
(CFG_STATUS_FRAME). The return values are organized as follows:
[Upper subsystem 16 bits][Lower framework 16 bits]
The subsystem status is returned by the subsystem's configure routine
and can be any error in errno.h. The framework status is returned by
the configuration framework; the possible values are defined in
<sys/sysconfig.h> as CFG_FRAME_Exxx. A successful operation has ESUC‐
CESS (0) returned in both status segments.
See the cfg_errno(9r) and errno(2) reference pages for more details
about error numbers and status.
EXAMPLE
A subsystem may be queried using the cfg_query routine as follows:
cfg_attr_t attributes[2];
cfg_status_t retval;
int i;
int nattributes;
/*****************************************************/
/* Initialize attribute names for the request */
strcpy (attributes[0].name, "maxmounts");
attributes[0].type = CFG_ATTR_INTTYPE;
attributes[0].attr.num.val = 30;
nattributes = 1;
attributes[1].name[0] = '\0';
/***************************************************/
/* Call the cfg_query() routine */
retval = cfg_query("lvm", attributes, nattributes);
if (retval != CFG_SUCCESS)
print_error (retval);
else {
for (i=0; i<1; i++) {
if (attributes[i].status != CFG_ATTR_SUCCESS) {
printf("%s:", attributes[i].name);
switch (attributes[i].status){
case CFG_ATTR_EEXISTS:
printf("unknown attribute\n");
break;
case CFG_ATTR_EOP:
printf("attribute does not allow this opera‐
tion\n");
break;
.
.
.
default:
printf("unknown error\n");
break;
}
}
}
}
For extracting attribute values of error status, refer to /usr/exam‐
ples/cfgmgr/sample_app.c.
SEE ALSO
Routines: cfg_subsys_query(3), cfg_configure(9r), cfg_errno(9r),
cfg_reconfigure(9r), cfg_subsysop(9r), cfg_unconfigure(9r)
Other: errno(2),
cfg_query(9r)