Loads an object file into the kernel or queries for an object file already loaded.
The kmod_load kernel service loads into the kernel a kernel extension object file specified by the pathp parameter. This service returns a kernel module ID for that instance of the module.
You can specify flags to request a single load, which ensures that only one copy of the object file is loaded into the kernel. An additional option is simply to query for a given object file (specified by path name). This allows the user to determine if a module is already loaded and then access its assigned kernel module ID.
The kmod_load service also provides load-time symbol resolution of the loaded module's imported symbols. The kmod_load service loads additional kernel object modules if required for symbol resolution.
Symbols imported from the kernel name space are resolved with symbols that exist in the kernel name space at the time of the load. (Symbols are imported from the kernel name space by specifying the #!/unix character string as the first field in an import list at link-edit time.)
Kernel modules can also import symbols from other kernel object modules. These other kernel object modules are loaded along with the specified object module if they are needed to resolve the imported symbols.
Any symbols exported by the specified kernel object module are added to the kernel name space if the flags parameter has the LD_KERNELEX flag set. This makes the symbols available to other subsequently loaded kernel object modules. Kernel object modules loaded on behalf of the specified kernel object module (to resolve imported symbols) do not have their exported symbols added to the kernel name space.
Kernel export symbols specified (at link-edit time) with the SYSCALL keyword in the primary module's export list are added to the system call table. These kernel export symbols are available to application programs as system calls.
The search path search string is taken from the module header of the object module specified by the pathp parameter if the libpathp parameter is null. The module header of the object module specified by the pathp parameter is used.
If the module header contains an unqualified base file name for the symbol (no / [slash] characters in the name), a search string is used to find the location of the shared object module required to resolve the import. This search string can be taken from one of two places. If the libpathp parameter on the call to the kmod_load service is not null, then it points to a character string specifying the search path to be used. However, if the libpathp parameter is null, then the search path is to be taken from the module header for the object module specified by the pathp parameter.
The search path specification found in object modules loaded to resolve imported symbols is not used. The kernel loader service does not support deferred symbol resolution. The load of the kernel module is terminated with an error if any imported symbols cannot be resolved.
The kmod_load kernel service can be called from the process environment only.
If the object file is loaded without error, the module ID is returned in the location pointed to by the kmidp parameter and the return code is set to 0.
If an error results, the module is not loaded, and no kernel module ID is returned. The return code is set to one of the following return values:
EACCES | Indicates that an object module to be loaded is not an ordinary file or that the mode of the object module file denies read-only access. |
EACCES | Search permission is denied on a component of the path prefix. |
EFAULT | Indicates that the calling process does not have sufficient authority to access the data area described by the pathp or libpathp parameters when the LD_USRPATH flag is set. This error code is also returned if an I/O error occurs when accessing data in this area. |
ENOEXEC | Indicates that the program file has the appropriate access permission, but has an XCOFF indicator that is not valid in its header. The kmod_load kernel service supports loading of XCOFF (Extended Common Object File Format) object files only. This error code is also returned if the loader is unable to resolve an imported symbol. |
EINVAL | Indicates that the program file has a valid XCOFF indicator in its header, but the header is either damaged or incorrect for the machine on which the file is to be loaded. |
ENOMEM | Indicates that the load requires more kernel memory than allowed by the system-imposed maximum. |
ETXTBSY | Indicates that the object file is currently open for writing by some process. |
ENOTDIR | Indicates that a component of the path prefix is not a directory. |
ENOENT | Indicates that no such file or directory exists or the path name is null. |
ESTALE | Indicates that the caller's root or current directory is located in a virtual file system that has been unmounted. |
ELOOP | Indicates that too many symbolic links were encountered in translating the path or libpathp parameter. |
ENAMETOOLONG | Indicates that a component of a path name exceeded 255 characters, or an entire path name exceeded 1023 characters. |
EIO | Indicates that an I/O error occurred during the operation. |
The kmod_unload kernel service is part of Base Operating System (BOS) Runtime.
The kmod_unload kernel service.
Kernel Extension and Device Driver Management Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts.