[ Previous |
Next |
Contents |
Home |
Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 2
Writing an Undefine Method
This article describes how an Undefine device method works. It also suggests guidelines for programmers writing their own Undefine device configuration methods.
Syntax
undDev -l Name
Description
The Undefine method deletes a Defined device from the Customized database. Once a device is deleted, it cannot be configured until it is once again defined by the Define method.
The Undefine method is also responsible for releasing the major and minor number assignments for the device instance and deleting the device's special files from the /dev directory. If minor number assignments are registered with the genminor subroutine, the Undefine method can release the major and minor number assignments and delete the special files by using the reldevno subroutine.
By convention, the first three characters of the name of the Undefine method are und. 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.
Flags
-l Name |
Identifies the logical name of the device to be undefined. |
Guidelines for Writing an Undefine Method
This list of tasks is intended as a guideline for writing an Undefine method. Some devices may have specials needs that are not addressed in these tasks.
The Undefine method must:
- Validate the input parameters. The -l flag must be supplied to identify the device to be undefined.
- Initialize the Object Data Manager (ODM) using the odm_initialize subroutine and lock the configuration database using the odm_lock subroutine. See "Writing a Device Method" in AIX Kernel Extensions and Device Support Programming Concepts for an example.
- Retrieve the Customized Device (CuDv) object for the device to be undefined. This is done by getting the CuDv object whose Device Name descriptor matches the name supplied with the -l flag. If no object is found with the specified name, this method exits with an error.
- Check the device's current state. If the Device Status descriptor indicates that the device is not in the Defined state, then it is not ready to be undefined. If this is the case, this method exits with an error.
- Check for any child devices. This check is accomplished by querying the CuDv object class for any objects whose Parent Device Logical Name descriptor matches this device's name. If the device has child devices, regardless of the states they are in, the Undefine method will fail. All child devices must be undefined before the parent can be undefined.
- Check to see if this device is listed as a dependency of another device. This is done by querying the Customized Dependency (CuDep) object class for objects whose Dependency descriptor matches this device's logical name. If a match is found, the method exits with an error. A device may not be undefined if it has been listed as a dependent of another device. "Understanding Device Dependencies and Child Devices" in AIX Kernel Extensions and Device Support Programming Concepts discusses dependencies.
- Delete Special Files and major and minor numbers. If no errors have been encountered, the method can delete customized information. First, delete the special files from the /dev directory. Next, delete all minor number assignments. If the last minor number has been deleted for a particular major number, release the major number as well, using the relmajor subroutine. The Undefine method should never delete objects from the Customized Device Driver (CuDvDr) object class directly, but should always use the routines provided. If the minor number assignments are registered with the genminor subroutine, all of the above can be accomplished using the reldevno subroutine.
- Delete all attributes for the device from the Customized Attribute (CuAt) object class. Simply delete all CuAt objects whose Device Name descriptor matches this device's logical name. It is not an error if the ODM routines used to delete the attributes indicate that no objects were deleted. This indicates that the device has no attributes that have been changed from the default values.
- Delete the Customized VPD (CuVPD) object for the device, if it has one.
- Delete the Customized Dependency (CuDep) objects that indicate other devices that are dependents of this device.
- Delete the Customized Device (CuDv) object for the device.
- Close all object classes and terminate the ODM. Exit with an exit code of 0 (zero) if there are no errors.
Files
/dev directory |
Contains the device special files. |
Related Information
ODM Device Configuration Object Classes.
The genminor subroutine, odm_initialize subroutine, odm_lock subroutine, reldevno subroutine, relmajor subroutine.
Writing a Define Method.
Customized Devices (CuDv) object class, Predefined Devices (PdDv) object class, Customized Attributes (CuAt) object class, Predefined Attribute (PdAt) object class, Customized Vital Product Data (CuVPD) object class.
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.
Special Files Overview in AIX Files Reference.
[ Previous |
Next |
Contents |
Home |
Search ]