SYS_KULOAD sysconfig Operation

Purpose

Unloads a loaded kernel object file and any imported kernel object files that were loaded with it.

Description

The SYS_KULOAD sysconfig operation unloads a previously loaded kernel file and any imported kernel object files that were automatically loaded with it. It does this by decrementing the load and use counts of the specified object file and any object file having symbols imported by the specified object file.

The parmp parameter on the sysconfig subroutine should point to a cfg_load structure, as described for the SYS_KLOAD (SYS_KLOAD sysconfig Operation) operation. The kmid field should specify the kernel module ID that was returned when the object file was loaded by the SYS_KLOAD or SYS_SINGLELOAD (SYS_SINGLELOAD sysconfig Operation) operation. The path and libpath fields are not used for this command and can be set to null. The parmlen parameter should be set to the size of the cfg_load structure.

Upon successful completion, the specified object file (and any other object files containing symbols that the specified object file imports) will have their load and use counts decremented. If there are no users of any of the module's exports and its load count is 0, then the object file is immediately unloaded.

However, if there are users of this module (that is, modules bound to this module's exported symbols), the specified module is not unloaded. Instead, it is unloaded on some subsequent unload request, when its use and load counts have gone to 0. The specified module is not in fact unloaded until all current users have been unloaded.

Note:
  1. Care must be taken to ensure that a subroutine has freed all of its system resources before being unloaded. For example, a device driver is typically prepared for unloading by using the SYS_CFGDD (SYS_CFGDD sysconfig Operation) operation and specifying termination.
  2. If the use count is not 0, and you cannot force it to 0, the only way to terminate operation of the kernel extension is to reboot the machine.

Loader Symbol Binding Support explains the symbol binding support provided when loading kernel object files.

Return Values

If the unload operation is successful or the specified object file load count is successfully decremented, a value of 0 is returned.

Error Codes

On error, the specified file and any imported files are not unloaded, nor are their load and use counts decremented. A value of -1 is returned and the errno global variable is set to one of the following:

Item Description
EACCES The calling process does not have the required privilege.
EINVAL Invalid module ID or the specified module is no longer loaded or already has a load count of 0.
EFAULT The calling process does not have sufficient authority to access the data area described by the parmp and parmlen parameters provided to the subroutine. This error is also returned if an I/O error occurred when accessing data in this area.