delete_module - Online Linux Manual PageSection : 2
Updated : 2023-02-05
Source : Linux man-pages 6.03

NAMEdelete_module − unload a kernel module

LIBRARYStandard C library (libc, −lc)

SYNOPSIS#include <fcntl.h> /* Definition of O_* constants */ #include <sys/syscall.h> /* Definition of SYS_* constants */ #include <unistd.h>int syscall(SYS_delete_module, const char *name, unsigned int flags);Note: glibc provides no wrapper for delete_module(), necessitating the use of syscall(2).

DESCRIPTIONThe delete_module() system call attempts to remove the unused loadable module entry identified by name. If the module has an exit function, then that function is executed before unloading the module. The flags argument is used to modify the behavior of the system call, as described below. This system call requires privilege. Module removal is attempted according to the following rules: (1) If there are other loaded modules that depend on (i.e., refer to symbols defined in) this module, then the call fails. (2) Otherwise, if the reference count for the module (i.e., the number of processes currently using the module) is zero, then the module is immediately unloaded. (3) If a module has a nonzero reference count, then the behavior depends on the bits set in flags. In normal usage (see NOTES), the O_NONBLOCK flag is always specified, and the O_TRUNC flag may additionally be specified. The various combinations for flags have the following effect: flags == O_NONBLOCK  The call returns immediately, with an error. flags == (O_NONBLOCK | O_TRUNC)  The module is unloaded immediately, regardless of whether it has a nonzero reference count. (flags & O_NONBLOCK) == 0  If flags does not specify O_NONBLOCK, the following steps occur: • The module is marked so that no new references are permitted. • If the module's reference count is nonzero, the caller is placed in an uninterruptible sleep state (TASK_UNINTERRUPTIBLE) until the reference count is zero, at which point the call unblocks. • The module is unloaded in the usual way. The O_TRUNC flag has one further effect on the rules described above. By default, if a module has an init function but no exit function, then an attempt to remove the module fails. However, if O_TRUNC was specified, this requirement is bypassed. Using the O_TRUNC flag is dangerous! If the kernel was not built with CONFIG_MODULE_FORCE_UNLOAD, this flag is silently ignored. (Normally, CONFIG_MODULE_FORCE_UNLOAD is enabled.) Using this flag taints the kernel (TAINT_FORCED_RMMOD).

RETURN VALUEOn success, zero is returned. On error, −1 is returned and errno is set to indicate the error.

ERRORSEBUSY  The module is not "live" (i.e., it is still being initialized or is already marked for removal); or, the module has an init function but has no exit function, and O_TRUNC was not specified in flags. EFAULT  name refers to a location outside the process's accessible address space. ENOENT  No module by that name exists. EPERM  The caller was not privileged (did not have the CAP_SYS_MODULE capability), or module unloading is disabled (see /proc/sys/kernel/modules_disabled in proc(5)). EWOULDBLOCK  Other modules depend on this module; or, O_NONBLOCK was specified in flags, but the reference count of this module is nonzero and O_TRUNC was not specified in flags.

STANDARDSdelete_module() is Linux-specific.

NOTESThe delete_module() system call is not supported by glibc. No declaration is provided in glibc headers, but, through a quirk of history, glibc versions before glibc 2.23 did export an ABI for this system call. Therefore, in order to employ this system call, it is (before glibc 2.23) sufficient to manually declare the interface in your code; alternatively, you can invoke the system call using syscall(2). The uninterruptible sleep that may occur if O_NONBLOCK is omitted from flags is considered undesirable, because the sleeping process is left in an unkillable state. As at Linux 3.7, specifying O_NONBLOCK is optional, but in future kernels it is likely to become mandatory.

Linux 2.4 and earlierIn Linux 2.4 and earlier, the system call took only one argument: int delete_module(const char *name); If name is NULL, all unused modules marked auto-clean are removed. Some further details of differences in the behavior of delete_module() in Linux 2.4 and earlier are not currently explained in this manual page.

SEE ALSOcreate_module(2), init_module(2), query_module(2), lsmod(8), modprobe(8), rmmod(8)
0
Johanes Gumabo
Data Size   :   15,677 byte
man-delete_module.2Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 182,257
Visitor ID   :     :  
Visitor IP   :   18.223.195.30   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.