forked from cirosantilli/linux-kernel-module-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvermagic.c
42 lines (37 loc) · 1.03 KB
/
vermagic.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
/* https://cirosantilli.com/linux-kernel-module-cheat#vermagic */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/utsname.h>
#if 0
#include <linux/vermagic.h> /* VERMAGIC_STRING */
#endif
static int myinit(void)
{
struct new_utsname *uts = init_utsname();
pr_info(
"sysname = %s\n"
"nodename = %s\n"
"release = %s\n"
"version = %s\n"
"machine = %s\n"
"domainname = %s\n",
uts->sysname,
uts->nodename,
uts->release,
uts->version,
uts->machine,
uts->domainname
);
#if 0
/* Possible before v5.8, but was buggy apparently, not sure why:
* https://github.com/cirosantilli/linux/commit/51161bfc66a68d21f13d15a689b3ea7980457790 */
pr_info("VERMAGIC_STRING = " VERMAGIC_STRING "\n");
#endif
/* Nice try, but it is not a member. */
/*pr_info("THIS_MODULE->vermagic = %s\n", THIS_MODULE->vermagic);*/
return 0;
}
static void myexit(void) {}
module_init(myinit)
module_exit(myexit)
MODULE_LICENSE("GPL");