-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameter.c
More file actions
34 lines (29 loc) · 793 Bytes
/
parameter.c
File metadata and controls
34 lines (29 loc) · 793 Bytes
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
#include <linux/init.h>
#include <linux/module.h>
//For parameters:
#include <linux/moduleparam.h>
//Create variable
int param_var = 0;
//register the variable created
//permissions: S_I is the general beginning
// S_IRUSR : R-reading
// S_IWUSR : W-writing
// S_IXUSR : X-execution
// USR - user
// S_IWGRP : GRP - group
// S_IRGRP :
// | : XOR for two permissions
module_param(param_var, int, S_IRUSR | S_IWUSR);
void display(void){
printk(KERN_ALERT "Test: param = %d \n", param_var);
}
static int parameter_init(void){
printk(KERN_ALERT "Purpose is to register functionalities and allocate resources\n");
display();
return 0;
}
static void parameter_exit(void){
printk(KERN_ALERT "Module exit\n");
}
module_init(parameter_init);
module_exit(parameter_exit);