mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 11:11:35 +01:00
MODULE_VERSION and srcversion
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# Changes to this file are automatically trigger kernel reconfigures
|
# Changes to this file are automatically trigger kernel reconfigures
|
||||||
# even without using the linux-reconfigure target.
|
# even without using the linux-reconfigure target.
|
||||||
|
|
||||||
|
CONFIG_MODULE_SRCVERSION_ALL=y
|
||||||
|
|
||||||
|
# GDB debugging.
|
||||||
CONFIG_DEBUG_FS=y
|
CONFIG_DEBUG_FS=y
|
||||||
CONFIG_DEBUG_INFO=y
|
CONFIG_DEBUG_INFO=y
|
||||||
CONFIG_DEBUG_KERNEL=y
|
CONFIG_DEBUG_KERNEL=y
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
1. [params](params.c)
|
1. [params](params.c)
|
||||||
1. [vermagic](vermagic.c)
|
1. [vermagic](vermagic.c)
|
||||||
1. [vermagic_fail](vermagic_fail.c)
|
1. [vermagic_fail](vermagic_fail.c)
|
||||||
|
1. [module_version](module_version.c)
|
||||||
1. Pseudo filesystems
|
1. Pseudo filesystems
|
||||||
1. [debugfs](debugfs.c)
|
1. [debugfs](debugfs.c)
|
||||||
1. [procfs](procfs.c)
|
1. [procfs](procfs.c)
|
||||||
|
|||||||
28
kernel_module/module_version.c
Normal file
28
kernel_module/module_version.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
https://stackoverflow.com/questions/4839024/how-to-find-the-version-of-a-compiled-kernel-module/42556565#42556565
|
||||||
|
|
||||||
|
insmod /module_version.ko
|
||||||
|
cat /sys/modules/module_version/version
|
||||||
|
# => 1.0
|
||||||
|
cat /sys/module/module_version/srcversion
|
||||||
|
# => AB0F06618BC3A36B687CDC5
|
||||||
|
modinfo /module_version.ko | grep -E '^(src|)version'
|
||||||
|
# => version: 1.0
|
||||||
|
# => srcversion: AB0F06618BC3A36B687CDC5
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
static int myinit(void)
|
||||||
|
{
|
||||||
|
pr_info(__FILE__ "\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void myexit(void) {}
|
||||||
|
|
||||||
|
module_init(myinit)
|
||||||
|
module_exit(myexit)
|
||||||
|
MODULE_VERSION("1.0");
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
insmod /vermagic.ko
|
insmod /vermagic.ko
|
||||||
# => 4.9.6 SMP mod_unload modversions
|
# => 4.9.6 SMP mod_unload modversions
|
||||||
TODO how to get the vermagic from running kernel from userland? <https://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-October/006306.html>
|
|
||||||
|
TODO how to get the vermagic from running kernel from userland?
|
||||||
|
<https://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-October/006306.html>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
@@ -10,7 +12,7 @@ TODO how to get the vermagic from running kernel from userland? <https://lists.k
|
|||||||
|
|
||||||
static int myinit(void)
|
static int myinit(void)
|
||||||
{
|
{
|
||||||
pr_info(VERMAGIC_STRING "\n");
|
pr_info(__FILE__ "\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user