mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Multiple kernel params, busybox modinfo
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
CONFIG_MODINFO=y
|
||||||
CONFIG_NC=y
|
CONFIG_NC=y
|
||||||
CONFIG_NC_EXTRA=y
|
CONFIG_NC_EXTRA=y
|
||||||
CONFIG_NC_SERVER=y
|
CONFIG_NC_SERVER=y
|
||||||
|
|||||||
@@ -4,15 +4,21 @@ Allows passing parameters at insertion time.
|
|||||||
Those parameters can also be read and modified at runtime from /sys.
|
Those parameters can also be read and modified at runtime from /sys.
|
||||||
|
|
||||||
insmod /params.ko
|
insmod /params.ko
|
||||||
# dmesg => 0
|
# dmesg => 0 0
|
||||||
cd /sys/module/params/parameters
|
cd /sys/module/params/parameters
|
||||||
cat i
|
cat i
|
||||||
# => 0
|
# => 1 0
|
||||||
printf 1 >i
|
printf 1 >i
|
||||||
# dmesg => 1
|
# dmesg => 1 0
|
||||||
rmmod params
|
rmmod params
|
||||||
insmod /params.ko i=1
|
|
||||||
# dmesg => 1
|
insmod /params.ko i=1 j=1
|
||||||
|
# dmesg => 1 1
|
||||||
|
rmmod params
|
||||||
|
|
||||||
|
modinfo
|
||||||
|
/params.ko
|
||||||
|
# Output contains MODULE_PARAM_DESC descriptions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/delay.h> /* usleep_range */
|
#include <linux/delay.h> /* usleep_range */
|
||||||
@@ -24,15 +30,18 @@ Those parameters can also be read and modified at runtime from /sys.
|
|||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
|
static int j = 0;
|
||||||
module_param(i, int, S_IRUSR | S_IWUSR);
|
module_param(i, int, S_IRUSR | S_IWUSR);
|
||||||
|
module_param(j, int, S_IRUSR | S_IWUSR);
|
||||||
MODULE_PARM_DESC(i, "my favorite int");
|
MODULE_PARM_DESC(i, "my favorite int");
|
||||||
|
MODULE_PARM_DESC(j, "my second favorite int");
|
||||||
|
|
||||||
static struct task_struct *kthread;
|
static struct task_struct *kthread;
|
||||||
|
|
||||||
static int work_func(void *data)
|
static int work_func(void *data)
|
||||||
{
|
{
|
||||||
while (!kthread_should_stop()) {
|
while (!kthread_should_stop()) {
|
||||||
pr_info("%d\n", i);
|
pr_info("%d %d\n", i, j);
|
||||||
usleep_range(1000000, 1000001);
|
usleep_range(1000000, 1000001);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user