-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchain_0.c
49 lines (39 loc) · 1.09 KB
/
chain_0.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
#include <linux/kernel.h> /* printk() */
#include <linux/init.h>
#include <linux/notifier.h>
#include <linux/module.h>
#include <linux/fs.h> /* everything() */
#define INIT_EVENT_CHAIN 0x52U
static RAW_NOTIFIER_HEAD(init_event_chain);
/* define notifier_call_chain */
int call_init_event_notifiers(unsigned long val, void *v)
{
return raw_notifier_call_chain(&init_event_chain, val, v);
}
EXPORT_SYMBOL(call_init_event_notifiers);
/* define notifier_chain_register func */
int register_init_event_notifier(struct notifier_block *nb)
{
int err;
err = raw_notifier_chain_register(&init_event_chain, nb);
if(err){
printk(KERN_ERR "register notifier chain failed\n");
goto out;
}
out:
return err;
}
EXPORT_SYMBOL(register_init_event_notifier);
static int __init chain_0_init(void)
{
printk(KERN_DEBUG "I'm in chain_0 init\n");
return 0;
}
static void __exit chain_0_exit(void)
{
printk(KERN_DEBUG "Goodbye to chain_0\n");
}
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("[email protected]");
module_init(chain_0_init);
module_exit(chain_0_exit);