Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cfg_query(9r) [osf1 man page]

cfg_query(9r)															     cfg_query(9r)

NAME
cfg_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 information, 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 status (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 ESUCCESS(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] = ''; /***************************************************/ /* 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 "); break; case CFG_ATTR_EOP: printf("attribute does not allow this operation "); break; . . . default: printf("unknown error "); break; } } } } For extracting attribute values of error status, refer to /usr/examples/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)

Check Out this Related Man Page

cfg_subsys_query(3)					     Library Functions Manual					       cfg_subsys_query(3)

NAME
cfg_subsys_query - Determine the value of selected subsystem attributes LIBRARY
Configuration Management Library (libcfg.a) SYNOPSIS
#include <cfg.h> cfg_status_t cfg_subsys_query( 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. On input, names the attributes for which you are requesting a value. On return, contains information about the named attributes. 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. An integer value specifying the number of attributes for which you are requesting information. DESCRIPTION
Use the cfg_subsys_query() routine to get information about a list of subsystem attributes. You can get information about one or more attributes. When your application calls the cfg_subsys_query() routine, it passes the subsystem name and a list of attribute names to the system. The system reads this information and finds and collects the information about the named attributes. The system then returns the attribute information to your application. The information returned from the cfg_subsys_query() routine is passed in a structure of type cfg_attr_t. If your application requests information about more than one attribute, an array of structures is returned. For information about this structure, see libcfg(3). To query an individual array element, on input the index field of the cfg_attr_t structure must be set to the index value of the array ele- ment. The following list describes the information returned to your application when it calls the cfg_subsys_query() 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_UINTTYPE (uint), CFG_ATTR_LONGTYPE (long), or CFG_ATTR_ULONGTYPE (ulong). The string data type is a character string type named CFG_ATTR_STRTYPE 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 code are CFG_OP_QUERY (you can request information about the attribute), CFG_OP_CONFIGURE (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, the system assigns a status to each attribute. The following table describes the status values that your application might receive from the cfg_subsys_query() 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, the disposal routine, if any, to be called once the attribute value is returned, and for binary attributes, the length of the current value of the attribute. (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() library routine: cfg_attr_t attributes[2]; cfg_status_t retval; cfg_handle_t handle; int i; /*****************************************************/ /* Initialize attribute names for the query */ strcpy (attributes[0].name, "bufcache"); strcpy (attributes[1].name, "max-vnodes"); /***************************************************/ /* Call the cfg_subsys_query() routine */ retval = cfg_subsys_query(&handle, "vfs", attributes, 2); if (retval != CFG_SUCCESS) print_error (retval); else { /* Use data returned from the query */ for (i=0; i<2; i++) { printf ("%s", attributes[i].name); if (attributes[i].status != CFG_ATTR_SUCCESS) { switch (attributes[i].status){ case CFG_ATTR_EEXISTS: printf("unknown attribute "); break; 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; } } } In this example, the application requests information about two attributes, bufcache and max-vnodes. When the cfg_subsys_query() 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() routine returns CFG_SUCCESS, the status for each attribute is tested and any errors are reported. The application displays to the user the value of attributes that return CFG_ATTR_SUCCESS. RETURN VALUES
Upon successful completion, cfg_subsys_query() returns CFG_SUCCESS. Other return values indicate that an error has occurred. For informa- tion about handling return values from routines in the configuration management library, see libcfg(3). RELATED INFORMATION
Commands: cfgmgr(8), sysconfig(8) Routines: cfg_connect(3), cfg_subsys_query_all(3), libcfg(3) delim off cfg_subsys_query(3)
Man Page