modctl() will fail if:
[EBUSY]
The argument operation is MODCTL_UNLOAD and the module is in use or the module is compiled into the kernel.
[EDEADLK]
The argument operation is MODCTL_LOAD and there is a circular dependency in the module's dependency chain.
[EEXIST]
The argument operation is MODCTL_LOAD and the module is already loaded.
[EFAULT]
A bad address was given for argp.
[EFBIG]
The argument operation is MODCTL_LOAD, the specified module resides in the file system, and the module's default proplib file was too large.
[EINVAL]
The argument
operation is invalid.
The argument
operation is
MODCTL_LOAD and ml_props is not
NULL and “ml_propslen” is
0, or ml_props is
NULL and “ml_propslen” is not
0. The kernel is unable to internalize the plist. Or, there is a problem with the module or <module>.prop.
[EMLINK]
The argument operation is MODCTL_LOAD and the module has too many dependencies.
[ENAMETOOLONG]
A module name/path is too long.
[ENOENT]
The argument operation is MODCTL_LOAD and the module or a dependency can't be found. The argument operation is MODCTL_UNLOAD and no module by the name of argp is loaded.
[ENOEXEC]
The argument operation is MODCTL_LOAD and the module is not a valid object for the system.
[ENOMEM]
There was not enough memory to perform the operation.
[EPERM]
Not allowed to perform the operation.
[EPROGMISMATCH]
The argument operation is MODCTL_LOAD, the ml_flags field in the modctl_load_t structure does not include MODCTL_LOAD_FORCE, and the requested module does not match the current kernel's version information.