MODCTL(2) | System Calls Manual | MODCTL(2) |
modctl
—
#include <sys/module.h>
int
modctl
(int
operation, void
*argp);
modctl
() provides control over loaded kernel modules.
The argument operation is one of
MODCTL_LOAD
, MODCTL_UNLOAD
,
MODCTL_STAT
, or MODCTL_EXISTS
.
The argument argp depends on the
operation to be performed.
Operations are:
MODCTL_LOAD
MODCTL_UNLOAD
MODCTL_STAT
If the block is not large enough, the data returned will be truncated to fit. The kernel will then update the iov_len member of the iovec to reflect the size of the complete report, regardless of whether this is larger or smaller than the size passed in.
MODCTL_EXISTS
MODCTL_LOAD
, or it should be “1” to
test if the system can autoload modules. Note that this test does not
consider the sysctl kern.module.autoload
.MODCTL_LOAD
contains the following elements, which
should be filled in by the caller:
MODCTL_NO_PROP
MODCTL_LOAD_FORCE
NULL
in which case
ml_propslen must be 0
. An
upper limit of 4096 bytes is imposed on the value of ml_propslen.
Attempting to load a proplib dictionary larger than this size will return
ENOMEM
.The modstat_t structure used with
MODCTL_STAT
contains the following elements, which
are filled in by the kernel:
MODULE_SOURCE_KERNEL
MODULE_SOURCE_BOOT
MODULE_SOURCE_FILESYS
MODULE_CLASS_SECMODEL
MODULE_CLASS_VFS
MODULE_CLASS_DRIVER
MODULE_CLASS_EXEC
MODULE_CLASS_MISC
MODFLAG_MUST_FORCE
MODFLAG_AUTO_LOADED
Otherwise, a value of -1 is returned and errno is set to indicate the error.
modctl
() will fail if:
EBUSY
]MODCTL_UNLOAD
and the module is in use or the
module is compiled into the kernel.EDEADLK
]MODCTL_LOAD
and there is a circular dependency in
the module's dependency chain.EEXIST
]MODCTL_LOAD
and the module is already loaded.EFAULT
]EFBIG
]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
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>.plist.
EMLINK
]MODCTL_LOAD
and the module has too many
dependencies.ENAMETOOLONG
]ENOENT
]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
]MODCTL_LOAD
and the module is not a valid object
for the system. Most likely, one or more undefined symbols could not be
resolved by the in-kernel linker.ENOMEM
]EPERM
]EPROGMISMATCH
]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.modctl
() function call first appeared in
NetBSD 5.0.
December 4, 2019 | NetBSD 9.2 |