-
Notifications
You must be signed in to change notification settings - Fork 5
/
scheduling.c
66 lines (53 loc) · 1.33 KB
/
scheduling.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* The KErnel ROotKIt Detector (KEROKID)
*
* (c) 2014 Fraunhofer FKIE
*/
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include "kerokid.h"
#include "notifier.h"
#include "proc_file.h"
#include "main.h"
char msg[MAX_PROC_MESSAGE_LEN];
void init_rescan(void)
{
clear_proc_message();
refresh_module_info();
mdelay(100);
scan();
}
/* ------- rescan on module notification -----*/
int rescan_notifier_function(struct notifier_block *nblock, unsigned long code, void *param)
{
printk(KERN_INFO"KEROKID: initiating rescan (module load)\n");
init_rescan();
return NOTIFY_OK;
}
struct notifier_block nb_rescan = {
.notifier_call = rescan_notifier_function,
.priority = INT_MAX - 1
};
/* ------ rescan on write to proc file -----*/
ssize_t write_proc(struct file *filp, const char *buf, size_t count, loff_t *offp)
{
unsigned long i;
i = copy_from_user(msg, buf, count);
printk(KERN_INFO"KEROKID: initiating rescan (manual)\n");
init_rescan();
return count;
}
struct file_operations proc_writing_fops = {
write: write_proc
};
/* ------ init and cleanup ------ */
void init_scheduling(void)
{
struct proc_dir_entry *reading_proc;
reading_proc = proc_create("rescan", 0, get_proc_parent(), &proc_writing_fops);
register_module_notifier(&nb_rescan);
}
void clean_scheduling(void)
{
unregister_module_notifier(&nb_rescan);
}