Begin work on rust versions of modules
This commit is contained in:
parent
1f2cc50f26
commit
91f8ca7f49
23 changed files with 53 additions and 9 deletions
|
@ -1,55 +0,0 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static short int myshort = 1;
|
||||
static int myint = 420;
|
||||
static long int mylong = 9999;
|
||||
static char *mystring = "blah";
|
||||
static int myintarray[2] = { 420, 420 };
|
||||
static int arr_argc = 0;
|
||||
|
||||
module_param(myshort, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
|
||||
MODULE_PARM_DESC(myshort, "A short integer");
|
||||
|
||||
module_param(myint, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
MODULE_PARM_DESC(myint, "An integer");
|
||||
|
||||
module_param(mylong, long, S_IRUSR);
|
||||
MODULE_PARM_DESC(mylong, "A long integer");
|
||||
|
||||
module_param(mystring, charp, 0000);
|
||||
MODULE_PARM_DESC(mystring, "A character string");
|
||||
|
||||
module_param_array(myintarray, int, &arr_argc, 0000);
|
||||
MODULE_PARM_DESC(myintarray, "An array of integers");
|
||||
|
||||
static int __init module_params_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
pr_info("myshort: %hd\n", myshort);
|
||||
pr_info("myint: %d\n", myint);
|
||||
pr_info("mylong: %ld\n", mylong);
|
||||
pr_info("mystring: %s\n", mystring);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(myintarray); i++)
|
||||
pr_info("myintarray[%d] = %d\n", i, myintarray[i]);
|
||||
|
||||
pr_info("%d arguments for myintarray.\n", arr_argc);
|
||||
|
||||
pr_info("Module avec paramètre chargé.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit module_params_exit(void)
|
||||
{
|
||||
pr_info("Module avec paramètre déchargé.\n");
|
||||
}
|
||||
|
||||
module_init(module_params_init);
|
||||
module_exit(module_params_exit);
|
||||
|
||||
MODULE_LICENSE("MIT License");
|
||||
MODULE_AUTHOR("Florian RICHER");
|
||||
MODULE_DESCRIPTION("Un module noyau avec paramètre déchargé.");
|
||||
MODULE_VERSION("1.0");
|
Loading…
Add table
Add a link
Reference in a new issue