This article describes how a Change device method works. It also suggests guidelines for programmers writing their own Change device configuration methods.
chgDev -l Name [ -p Parent ] [ -w Connection ] [ -P | -T ] [ -a Attr=Value [ -a Attr=Value ] ... ]
The Change method applies configuration changes to a device. If the device is in the Defined state, the changes are simply recorded in the Customized database. If the device is in the Available state, the Change method must also apply the changes to the actual device by reconfiguring it.
A Change method does not need to support all the flags described for Change methods. For example, if your device is a pseudo-device with no parent, it need not support parent and connection changes. For devices that have parents, it may be desirable to disallow parent and connection changes. For printers, such changes are logical because they are easily moved from one port to another. By contrast, an adapter card is not usually moved without first shutting off the system. It is then automatically configured at its new location when the system is rebooted. Consequently, there may not be a need for a Change method to support parent and connection changes.
Note: In deciding whether to support the -T and -P flags, remember that these options allow a device's configuration to get out of sync with the Configuration database. The -P flag is useful for devices that are typically kept open by the system. The Change methods for most supported devices do not support the -T flag.
In applying changes to a device in the Available state, the Change method could terminate the device from the driver, rebuild the device-dependent structure (DDS) using the new information, and redefine the device to the driver using the new DDS. The method may also need to reload adapter software or perform other device-specific operations. An alternative is to invoke the device's Unconfigure method, update the Customized database, and invoke the device's Configure method.
By convention, the first three characters of the name of the Change method should be chg. The remainder of the name (Dev) can be any characters, subject to operating system file-name restrictions, that identify the device or group of devices that use the method.
This list of tasks is intended as a guideline for writing a Change method. When writing for a specific device, some tasks may be omitted. For example, if a device does not support the changing of a parent or connection, there is no need to include those tasks. A device may have special needs that are not included in these tasks.
If the Change method is written to invoke the Unconfigure and Configure methods, it must:
If the Change method detects attributes that are in error, it must write information to the stderr file to identify them. This consists of writing the attribute name followed by the attribute description. Only one attribute and its description is to be written per line. If an attribute name was mistyped so that it does not match any of the device's attributes, write the attribute name supplied on a line by itself.
The mkdev and chdev configuration commands intercept the information written to the standard error file by the Change method. These commands write out the information following an error message describing that there were invalid attributes. Both the attribute name and attribute description are needed to identify the attribute. By invoking the mkdev or chdev command directly, the attributes can be identified by name. When using SMIT, these attributes can be identified by description.
The attribute description is obtained from the appropriate message catalog. A message is identified by catalog name, set number, and message number. The catalog name and set number are obtained from the device's PdDv object. The message number is obtained from the NLS Index descriptor in either the Predefined Attribute (PdAt) or Customized Attribute (CuAt) object corresponding to the attribute.
Writing a Device Method, ODM Device Configuration Object Classes.
Writing an Unconfigure Method, Writing a Configure Method
The chdev command, mkdev command, rmdev command.
The attrval subroutine, odm_run_method subroutine.
Customized Devices (CuDv) object class, Predefined Devices (PdDv) object class, Predefined Connection (PdCn) object class, Predefined Attribute (PdAt) object class, Customized Attribute (CuAt) object class.
Device Dependent Structure (DDS) Overview, Understanding Device Dependencies and Child Devices in AIX Kernel Extensions and Device Support Programming Concepts.
Object Data Manager (ODM) Overview for Programmers in AIX General Programming Concepts: Writing and Debugging Programs.