Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cfg_subsys_state(3) [osf1 man page]

cfg_subsys_state(3)					     Library Functions Manual					       cfg_subsys_state(3)

NAME
cfg_subsys_state - Determine the state of the named subsystem LIBRARY
Configuration Management Library (libcfg.a) SYNOPSIS
#include <cfg.h> cfg_status_t cfg_subsys_state( cfg_handle_t *handle, caddr_t subsys, unsigned int *state); 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 you receive when you call the cfg_connect() routine. Specifies the name of the subsystem for which you are requesting state information. Returns a collection of bit flags representing the state of the subsys- tem. The bit flags are defined in the <sys/sysconfig.h> header file. The following flags are currently defined: CFG_STATE_CONFIGURED, CFG_STATE_DYNAMIC, and CFG_STATE_LOADED. DESCRIPTION
Use the cfg_subsys_state() routine to determine the state of a particular subsystem. Subsystems can be loaded, loaded and configured, or unloaded. (Subsystems must be loaded to be configured.) In addition, a subsystem can be either static (the CFG_STATE_DYNAMIC bit flag is not set) or dynamic (the CFG_STATE_DYNAMIC bit flag is set). Static subsystems are linked into the kernel at build time and the only way to add or remove them from the kernel is to rebuild the kernel. Dynamic subsystems are loadable, meaning that they can be added and removed from the kernel while the system is running. The value returned in the state parameter is an integer representation of a binary value. The bits in the value designate the state of the subsystem. For example, the least significant bit designates whether or not the subsystem is loaded. If this bit is set, the subsystem is loaded. If the next higher order bit is set, the subsystem is configured. You can determine the state of a subsystem by using the value returned in the state parameter in a bitwise AND operation. The <sys/sysconfig.h> header file defines constants for this purpose. See the EXAMPLES section for more information about using these constants. EXAMPLES
The following example illustrates the use of the cfg_subsys_state() library routine: cfg_status_t retval; cfg_handle_t handle; unsigned int state; retval = cfg_subsys_state(&handle, "vfs", &state); if (retval != CFG_SUCCESS) print_error(retval); else { /* Determine whether or not the subsystem is loaded */ /* and configured. Display a message describing the */ /* subsystem state. */ if (state & CFG_STATE_LOADED) { if (state & CFG_STATE_CONFIGURED) printf("The subsystem is loaded and configured. "); else printf("The subsystem is loaded but not configured. "); else printf("The subsystem is unloaded. "); } } In this example, the cfg_subsys_state() routine returns a value representing the state of the vfs subsystem. The application determines whether the call to the routine was successful and, if it was, displays a message describing the state of the subsystem. RETURN VALUES
Upon successful completion, cfg_subsys_state() 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_subsys_list(3), libcfg(3) delim off cfg_subsys_state(3)

Check Out this Related Man Page

cfg_subsys_defaults_all(3)				     Library Functions Manual					cfg_subsys_defaults_all(3)

NAME
cfg_subsys_defaults_all - Determine the /etc/sysconfigtab value for all attributes of a subsystem LIBRARY
Configuration Management Library (libcfg.a) SYNOPSIS
#include <cfg.h> cfg_status_t cfg_subsys_defaults_all( cfg_handle_t *handle, caddr_t subsys, cfg_attr_t **attributes, int *nattributes); PARAMETERS
Structure identifying the means of communications 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 default attribute values. Returns information about all attributes for the named subsystem. The informa- tion includes the attribute-specific status of the query operation and the default value of the attribute. The system allocates memory for this array, which you should free when the information in the array is no longer needed. Specifies the number of attributes for which information has been returned. DESCRIPTION
Use the cfg_subsys_defaults_all() routine to get the value of all attributes of a subsystem as specified in the /etc/sysconfigtab database. For information about the /etc/sysconfigtab database, see sysconfigtab(4). In the call to the cfg_subsys_defaults_all() routine, your application 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. That information is then returned to your application in a buffer allocated by the cfg_subsys_defaults_all() routine. (You should free the allocated buffer space when it is no longer needed, as shown in the EXAMPLES section.) The information returned from the cfg_subsys_defaults_all() routine is passed in a structure of type cfg_attr_t. For subsystems with 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_defaults_all() routine: Attributes can be integer, string, or binary data. However, the system is unable to determine the data type of attributes by reading the /etc/syscon- figtab database. Therefore, this field returns the CFG_ATTR_STRTYPE data type for all attributes. The definition of each attribute in the subsystem attribute table determines what operations you can perform on the attribute. The system is unable to determine this information from the /etc/sysconfigtab database, so this field is NULL on return from the cfg_subsys_defaults_all() routine. During the processing of a cfg_subsys_defaults_all() routine, the system assigns each attribute a status. The following table describes the status values your application might receive on return from this 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, which contains a string representing the value of the attribute as it is defined in the /etc/sysconfigtab database. If an attribute is omitted from the database, the cfg_subsys_defaults_all() routine returns a NULL attribute value. The cfg_subsys_defaults_all() routine returns NULL for other fields in the attribute value structure. EXAMPLES
The following example illustrates the use of the cfg_subsys_defaults_all() library routine: cfg_attr_t *attributes; cfg_sta- tus_t retval; cfg_handle_t handle; int nattributes; int i; /**********************************************************/ /* Call the cfg_subsys_defaults_all routine */ retval = cfg_subsys_defaults_all(&handle, "vfs", &attributes, &nattributes); if (retval != CFG_SUCCESS) print_error (retval); else { /* Use data returned from the request */ 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_EMEM: printf( "Unable to allocate memory to return attribute value "); break; default: printf("unknown error "); break; } continue; } printf ("%s ", attributes[i].attr.str.val); } /* Free the memory allocated by the configuration management */ /* library */ free(attributes); } In this example, the application queries the values of all attributes of the vfs subsystem as they are defined in the /etc/sysconfigtab database. When the cfg_subsys_defaults_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_defaults_all() returns CFG_SUCCESS, the status for each attribute is tested and any errors are reported. The application displays the default value of attributes that return CFG_ATTR_SUCCESS. RETURN VALUES
Upon successful completion, cfg_subsys_defaults_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_connect(3), cfg_subsys_defaults(3), libcfg(3) Files: sysconfigtab(4) delim off cfg_subsys_defaults_all(3)
Man Page