kmod_unload Kernel Service

Purpose

Unloads a kernel object file.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/ldr.h>

int kmod_unload ( kmid
,  flags)
mid_t kmid;
uint flags;

Parameters

Item Description
kmid Specifies the kernel module ID of the object file to be unloaded. This kernel module ID is returned when using the kmod_load kernel service.
flags Flags specifying unload options. The following flag is defined:
0
Unloads the object module specified by its kmid parameter and any object modules that were loaded as a result of loading the specified object file if this file is not still in use.

Description

The kmod_unload kernel service unloads a previously loaded kernel extension object file. The object to be unloaded is specified by the kmid parameter. Upon successful completion, the following objects are unloaded or marked unload pending:

Users of these exports or system calls are modules bound to this module's exported symbols. If there are no users of any of the module's kernel exports or system calls, the module is immediately unloaded. If there are users of this module, the module is not unloaded but marked unload pending.

Marking a module unload pending removes the module's exported symbols from the kernel name space. Any system calls exported by this module are also removed. This prohibits new users of these symbols. The module is unloaded only when all current users have been unloaded.

If the unload is successfully completed or marked pending, a value of 0 is returned. When an error occurs, the specified module and any imported modules are not unloaded. A nonzero return value indicates the error.

Execution Environment

The kmod_unload kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates successful completion.
EINVAL Indicates that the kmid parameter, which specifies the kernel module, is not valid or does not correspond to a currently loaded module.
EBUSY The kmid parameter specifies a kernel extension that is still intercepting system calls.