-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel_symbols.c
40 lines (34 loc) · 1.16 KB
/
kernel_symbols.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
/**
* @file
* @author INESC-ID
* @date
* @version 2.2.0
* @brief Adapted from the code provided by ilia kuzmin
* <[email protected]>, adapted from the code provided by reza
* karimi <[email protected]>, adapted from the code implemented by miguel
* marques <[email protected]>
*/
#include "kernel_symbols.h"
#include "find_kallsyms_lookup_name.h"
#define M(RET, NAME, SIGNATURE) \
typedef RET(*NAME##_t) SIGNATURE; \
NAME##_t g_##NAME
#include "IMPORT.M"
#undef M
#define M(RET, NAME, SIGNATURE) \
if (!(g_##NAME = (NAME##_t)the_kallsyms_lookup_name(#NAME))) { \
pr_err("Can't lookup '" #NAME "' function."); \
return -1; \
}
int import_symbols(void)
{
#include "IMPORT.M"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 5)
if (!(g_lru_disable_count = (atomic_t *)the_kallsyms_lookup_name(
"lru_disable_count"))) {
pr_err("Can't lookup 'lru_disable_count' variable.");
return -1;
}
#endif
return 0;
}