cfg_subsys_config(3) Library Functions Manual cfg_subsys_config(3)NAME
cfg_subsys_config - Configure a subsystem
LIBRARY
Configuration Management Library (libcfg.a)
SYNOPSIS
#include <cfg.h> cfg_status_t cfg_subsys_config(
cfg_handle_t *handle,
caddr_t subsys);
PARAMETERS
Structure identifying the means of communication between your application and the configuration management server. For local requests,
pass NULL in this parameter. For remote requests, pass the value returned from the cfg_connect routine. Names the subsystem to be config-
ured.
DESCRIPTION
To initially configure a subsystem into the kernel, call the cfg_subsys_config() routine. If the subsystem is not loaded into the kernel,
this routine loads the subsystem. The routine then configures the subsystem using the attribute settings from the /etc/sysconfigtab data-
base. If no attributes are set in the database, the default values defined in the subsystem code are used.
Each subsystem is contained in a module file named subsystem-name.mod. For example, a subsystem named mysubsystem is contained in the
mysubsystem.mod module file. This module file must exist in the /subsys, /var/subsys, or /sys/BINARY directory on the system you are con-
figuring.
EXAMPLES
The following example illustrates the use of the cfg_subsys_config() routine:
cfg_status_t retval; cfg_handle_t handle;
retval = cfg_subsys_config(&handle, "vfs");
if (retval != CFG_SUCCESS)
print_error(retval);
In this example, the cfg_subsys_config() routine attempts to configure the vfs subsystem. If an error is returned, the corresponding error
message is displayed to the application user.
RETURN VALUES
Upon successful completion, cfg_subsys_config() returns CFG_SUCCESS. Other return values indicate that an error has occurred. For infor-
mation about handling return values from routines in the configuration management library, see libcfg(3).
RELATED INFORMATION
Commands: cfgmgr(8), sysconfig(8)
Routines: cfg_subsys_reconfig(3), cfg_subsys_unconfig(3), libcfg(3) delim off
cfg_subsys_config(3)
Check Out this Related Man Page
cfg_subsys_query_all(3) Library Functions Manual cfg_subsys_query_all(3)NAME
cfg_subsys_query_all - Determine the value of all attributes for a subsystem
LIBRARY
Configuration Management Library (libcfg.a)
SYNOPSIS
#include <cfg.h> cfg_status_t cfg_subsys_query_all(
cfg_handle_t *handle,
caddr_t subsys,
cfg_attr_t **attributes,
int *nattributes);
PARAMETERS
Structure identifying the means of communication between your application and the configuration management server. For local requests,
pass NULL in this parameter. For remote requests, pass the value returned from the cfg_connect() routine. Specifies the name of the sub-
system for which you are getting attribute values. Returns information about all attributes for the named subsystem. The information
includes the data type of the attribute, the list of operations supported by that attribute, the attribute-specific status of the query
operation, the minimum and maximum allowed values for the attribute, and the current value of the attribute. For binary data items, the
information includes the size of the attribute's current value. The system allocates memory for this array, which you should free when the
information in the array is no longer needed, as shown in the EXAMPLES section. An integer value specifying the number of attributes for
which information has been returned.
DESCRIPTION
Use the cfg_subsys_query_all() routine to get information about all the attributes for a particular subsystem.
When your application calls the cfg_subsys_query_all() routine, it passes the name of the subsystem for which you want information. The
system reads the subsystem name and finds and collects the information about its attributes. The system then returns that information to
your application.
For array-type attributes, each individual array element will be returned in a separate cfg_attr_t structure and the index field will have
the index value of the array element.
The information returned from the cfg_subsys_query_all() routine is passed in a structure of type cfg_attr_t. If the subsystem has more
than one attribute, an array of structures is returned. For information about this structure, see libcfg(3).
The following list describes the information returned to your application when it calls the cfg_subsys_query_all() routine: Attributes can
be integer, string, or binary data. As defined in <sys/sysconfig.h>, the integer data types can be CFG_ATTR_INTTYPE (int), CFG_ATTR_UINT-
TYPE (uint), CFG_ATTR_LONGTYPE (long), or CFG_ATTR_ULONGTYPE (ulong). The string data type is a character string type named CFG_ATTR_STR-
TYPE and the binary data type is CFG_ATTR_BINTYPE. The definition of each attribute in the subsystem code determines what operations you
can perform on the attribute. The possible operation codes are CFG_OP_QUERY (you can request information about the attribute), CFG_OP_CON-
FIGURE (you can set the attribute value when the subsystem is initially configured), and CFG_OP_RECONFIGURE (you can modify the value of
the attribute). During a query request, each attribute is assigned a status. The following table describes the status values your appli-
cation might receive from the cfg_subsys_query_all() routine:
---------------------------------------------------------------------
Status Code Meaning
---------------------------------------------------------------------
CFG_ATTR_SUCCESS Successful operation
CFG_ATTR_EEXISTS No attribute by that name exists
CFG_ATTR_EOP Attribute does not support the query operation
CFG_ATTR_ESUBSYS Subsystem failure (code within the subsystem
returned an error)
CFG_ATTR_EINDEX The index for an indexed attribute is out of
range
CFG_ATTR_EMEM Unable to allocate memory to return the attribute
value
---------------------------------------------------------------------
The value of each attribute is returned in a structure. In addition to the attribute value, this structure returns the minimum and maximum
value for the attribute and the disposal routine, if any, to be called once the attribute value is returned. For binary attributes, the
length of attribute's current value is also returned. (The disposal routine is used to free kernel memory occupied by string and binary
data.)
EXAMPLES
The following example illustrates the use of the cfg_subsys_query_all() library routine: cfg_attr_t *attributes; cfg_status_t
retval; cfg_handle_t handle; int nattributes; int i;
/***************************************************/ /* Call the cfg_subsys_query_all() routine */
retval = cfg_subsys_query_all(&handle, "vfs", &attributes, &nattributes);
if (retval != CFG_SUCCESS)
print_error (retval);
else {
/* Use data returned from the query */
for (i=0; i<nattributes; i++) {
printf ("%s", attributes[i].name);
if (attributes[i].status != CFG_ATTR_SUCCESS) {
switch (attributes[i].status){
case CFG_ATTR_EOP:
printf("attribute does not allow this operation
");
break;
.
.
.
default:
printf("unknown error
");
break;
}
continue;
}
/* Display attribute value to application user */
switch (attributes[i].type){
case CFG_ATTR_INTTYPE:
printf ("%d
", (int) attributes[i].attr.num.val);
break;
.
.
.
case CFG_ATTR_STRTYPE:
printf ("%s
", (int) attributes[i].attr.str.val);
free(attributes[i].attr.str.val);
break;
case CFG_ATTR_BINTYPE:
printf ("%d bytes of binary data received
", (int)
attributes[i].attr.bin.val_size);
free(attributes[i].attr.str.val);
break;
}
}
/* Free the memory allocated by the configuration management */
/* library */
free(attributes); }
In this example, the application requests information about all attributes of the vfs subsystem. When the cfg_subsys_query_all() routine
returns information about those attributes, the application tests the return status of the routine. The application reports any errors
returned. If cfg_subsys_query_all() returns CFG_SUCCESS, the status for each attribute is tested and any errors are reported. The appli-
cation displays the value of attributes that return CFG_ATTR_SUCCESS.
RETURN VALUES
Upon successful completion, cfg_subsys_query_all() returns CFG_SUCCESS. Other return values indicate that an error has occurred. For
information about handling return values from routines in the configuration management library, see libcfg(3).
RELATED INFORMATION
Commands: cfgmgr(8), sysconfig(8)
Routines: cfg_subsys_query(3), libcfg(3) delim off
cfg_subsys_query_all(3)