forked from mncoppola/suterusu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.c
50 lines (39 loc) · 1007 Bytes
/
module.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "common.h"
int success_int ( void )
{
return 0;
}
void success_void ( void )
{
}
int module_handler ( struct notifier_block *nblock, unsigned long code, void *_param )
{
unsigned long flags;
struct module *param = _param;
DEFINE_SPINLOCK(module_event_spinlock);
spin_lock_irqsave(&module_event_spinlock, flags);
switch ( param->state )
{
case MODULE_STATE_COMING:
DEBUG("Detected insertion of module '%s', neutralizing init and exit routines\n", param->name);
param->init = success_int;
param->exit = success_void;
break;
default:
break;
}
spin_unlock_irqrestore(&module_event_spinlock, flags);
return NOTIFY_DONE;
}
static struct notifier_block nb = {
.notifier_call = module_handler,
.priority = INT_MAX,
};
void disable_module_loading ( void )
{
register_module_notifier(&nb);
}
void enable_module_loading ( void )
{
unregister_module_notifier(&nb);
}