2006-02-09 19:32:36 +00:00
|
|
|
.\" Copyright (C) 1996 Free Software Foundation, Inc.
|
2012-10-09 07:39:45 +00:00
|
|
|
.\" and Copyright (C) 2012 Michael Kerrisk <mtk.manpages@gmail.com>
|
2006-02-09 19:32:36 +00:00
|
|
|
.\" This file is distributed according to the GNU General Public License.
|
|
|
|
.\" See the file COPYING in the top level source directory for details.
|
|
|
|
.\"
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" 2006-02-09, some reformatting by Luc Van Oostenryck; some
|
2006-02-09 19:32:36 +00:00
|
|
|
.\" reformatting and rewordings by mtk
|
|
|
|
.\"
|
2012-10-09 07:39:45 +00:00
|
|
|
.TH DELETE_MODULE 2 2012-10-09 "Linux" "Linux Programmer's Manual"
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH NAME
|
2012-10-09 07:39:45 +00:00
|
|
|
delete_module \- unload a kernel module
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
2012-10-09 07:39:45 +00:00
|
|
|
.BI "int delete_module(const char *" name ", int " flags );
|
2006-02-09 19:32:36 +00:00
|
|
|
.fi
|
2012-10-09 07:39:45 +00:00
|
|
|
|
|
|
|
.IR Note :
|
|
|
|
There is no glibc wrapper for this system call; see NOTES.
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.BR delete_module ()
|
2012-10-09 07:39:45 +00:00
|
|
|
attempts to remove the unused loadable module entry
|
|
|
|
identified by
|
|
|
|
.IR name .
|
2006-02-09 19:32:36 +00:00
|
|
|
This system call requires privilege.
|
2012-10-09 07:39:45 +00:00
|
|
|
|
|
|
|
If there are other loaded modules that depend on
|
|
|
|
(i.e., refer to symbols defined in) this module,
|
|
|
|
then the call fails.
|
|
|
|
Otherwise, by default,
|
|
|
|
.BR delete_module ()
|
|
|
|
marks a module so that no new references are permitted.
|
|
|
|
If the module's reference count
|
|
|
|
(i.e., the number of processes currently using the module) is nonzero,
|
|
|
|
it then places the caller in an uninterruptible sleep
|
|
|
|
state until all reference count is zero,
|
|
|
|
at which point the call unblocks.
|
|
|
|
When the reference count reaches zero, the module is unloaded.
|
|
|
|
When the module is unloaded, the kernel executes its
|
|
|
|
.I exit
|
|
|
|
function.
|
|
|
|
|
|
|
|
The
|
|
|
|
.IR flags
|
|
|
|
argument can be used to modify the behavior of the system call.
|
|
|
|
The following values can be ORed in this argument:
|
|
|
|
.TP
|
|
|
|
.B O_TRUNC
|
|
|
|
.\" KMOD_REMOVE_FORCE in kmod library
|
|
|
|
Force unloading of the module, even if the following conditions are true:
|
|
|
|
.RS
|
|
|
|
.IP * 3
|
|
|
|
The module has no
|
|
|
|
.I exit
|
|
|
|
function.
|
|
|
|
By default, attempting to unload a module that has no
|
|
|
|
.I exit
|
|
|
|
function fails.
|
|
|
|
.IP *
|
|
|
|
The reference count for (i.e., the number of processes currently using)
|
|
|
|
this module is nonzero.
|
|
|
|
See the description of
|
|
|
|
.BR O_NONBLOCK .
|
|
|
|
.RE
|
|
|
|
.IP
|
|
|
|
Using this flag taints the kernel (TAINT_FORCED_RMMOD).
|
|
|
|
.IP
|
|
|
|
.IR "Using this flag is dangerous!"
|
|
|
|
If the kernel was not built with
|
|
|
|
.BR CONFIG_MODULE_FORCE_UNLOAD ,
|
|
|
|
this flag is silently ignored.
|
|
|
|
.TP
|
|
|
|
.B O_NONBLOCK
|
|
|
|
.\" KMOD_REMOVE_NOWAIT in kmod library
|
|
|
|
If both
|
|
|
|
.B O_NONBLOCK
|
|
|
|
and
|
|
|
|
.B O_TRUNC
|
|
|
|
are specified in
|
|
|
|
.IR flags
|
|
|
|
(and the kernel was built with
|
|
|
|
.BR CONFIG_MODULE_FORCE_UNLOAD ),
|
|
|
|
then the module is unloaded immediately,
|
|
|
|
regardless of whether it has a nonzero reference count.
|
|
|
|
If
|
|
|
|
.B O_NONBLOCK
|
|
|
|
was specified, but
|
|
|
|
.B O_TRUNC
|
|
|
|
was not, then an error is returned
|
|
|
|
if the module has a nonzero reference count.
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH "RETURN VALUE"
|
2007-04-12 22:42:49 +00:00
|
|
|
On success, zero is returned.
|
|
|
|
On error, \-1 is returned and
|
2006-02-09 19:32:36 +00:00
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.B EBUSY
|
2012-10-09 07:39:45 +00:00
|
|
|
The module is not "live"
|
|
|
|
(i.e., it is still being initialized or is already marked for removal);
|
|
|
|
or, the module has no
|
|
|
|
.I exit
|
|
|
|
function and
|
|
|
|
.B O_TRUNC
|
|
|
|
was not specified in
|
|
|
|
.IR flags .
|
|
|
|
|
2006-02-09 19:32:36 +00:00
|
|
|
.TP
|
|
|
|
.B EFAULT
|
|
|
|
.I name
|
|
|
|
is outside the program's accessible address space.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
.I name
|
|
|
|
was an empty string.
|
|
|
|
.TP
|
|
|
|
.B ENOENT
|
|
|
|
No module by that name exists.
|
|
|
|
.TP
|
|
|
|
.B EPERM
|
|
|
|
The caller was not privileged
|
|
|
|
(did not have the
|
|
|
|
.B CAP_SYS_MODULE
|
2012-10-09 07:39:45 +00:00
|
|
|
capability),
|
|
|
|
or module unloading is disabled
|
|
|
|
(see
|
|
|
|
.IR /proc/sys/kernel/modules_disabled
|
|
|
|
in
|
|
|
|
.BR proc (5)).
|
|
|
|
.TP
|
|
|
|
.B EWOULDBLOCK
|
|
|
|
Other modules depend on this module;
|
|
|
|
or,
|
|
|
|
.BR O_NONBLOCK
|
|
|
|
was specified in
|
|
|
|
.IR flags ,
|
|
|
|
but the reference count of this module is nonzero and
|
|
|
|
.B O_TRUNC
|
|
|
|
was not specified in
|
|
|
|
.IR flags .
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
.BR delete_module ()
|
2007-12-25 21:28:09 +00:00
|
|
|
is Linux-specific.
|
2012-10-09 07:39:45 +00:00
|
|
|
.SH NOTES
|
|
|
|
Glibc does not provide a wrapper for this system call; call it using
|
|
|
|
.BR syscall (2).
|
|
|
|
|
|
|
|
See the Linux kernel source file
|
|
|
|
.I include/linux/module.h
|
|
|
|
for some useful background information.
|
|
|
|
|
|
|
|
.SS Linux 2.4 and earlier
|
|
|
|
In Linux 2.4 and earlier, the system call took only one argument:
|
|
|
|
|
|
|
|
.BI " int delete_module(const char *" name );
|
|
|
|
|
|
|
|
If
|
|
|
|
.I name
|
|
|
|
is NULL, all unused modules marked auto-clean are removed.
|
|
|
|
|
|
|
|
Some further details of differences in the behavior of
|
|
|
|
.BR delete_module ()
|
|
|
|
in Linux 2.4 and earlier are
|
|
|
|
.I not
|
|
|
|
currently explained in this manual page.
|
2006-02-09 19:32:36 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR create_module (2),
|
|
|
|
.BR init_module (2),
|
2012-10-08 11:56:32 +00:00
|
|
|
.BR query_module (2),
|
|
|
|
.BR rmmod (8)
|