Template Information

Trang

The Cleanup Function

Thứ Bảy, 4 tháng 6, 2011 / 20:32

static void __exit cleanup_function(void)
{
/* Cleanup code here */
}
module_exit(cleanup_function);
The cleanup function has no value to return, so it is declared void. The __exit modifier
marks the code as being for module unload only (by causing the compiler to
place it in a special ELF section). If your module is built directly into the kernel,
or if your kernel is configured to disallow the unloading of modules, functions
marked __exit are simply discarded. For this reason, a function marked __exit can
be called only at module unload or system shutdown time; any other use is an error.
Once again, the module_exit declaration is necessary to enable to kernel to find your
cleanup function.
If your module does not define a cleanup function, the kernel does not allow it to be
unloaded.

0 nhận xét:

Đăng nhận xét