Regarding how to use Global variable using our created modules
Hi.. We have defined one global variable named as "trace_flag". we have also check that, its entry in kernel global symbol table,Yes it has inserted in table.
now our problem is that,we want to create module. Through that module we want to set that flag value to 1. But we are unable to use that "trace_flag" variable. We are thinking about ioctl() function. But still we are not getting it.. Please suggest. |
this variable is exported?
AFAIK, the global symbols have to be exported, so, all kernel can access it. grep for EXPORT_SYMBOL() macro, the kernel use it everywhere. |
Yes we have use EXPORT_SYMBOL. And we have defined one more function to access this "trace_flag",the function name is "set_trace(int)".
void set_trace(int pass) { trace_flag=pass } For this function also,we have used EXPORT_SYMBOL. And we have checked its existence in global table, YES,both are present.. Now, we have created one module to set this flag to 1,named "tracemod.c" now in tracemod.c in init_module() { set_trace(1); } and in cleanup_module() { set_trace(0); } Ok.. Now our problem is ,the value of trace_flag is remain zero itself. It is not get updated... Please suggest.. |
I'd just add some printk() in the set_trace function and in the module init/cleanup.
|
We have done that also. Only problem is that trace_flag is not get updated though it is global...
|
Hello,
I can not understand why it is not working on your module, perhaps you are forgetting some basic step: I tried to simulate your problem this way: 1) put the global variable and the exported function on somewhere on the kernel, I choose the init/main.c file: Code:
Code:
diff --git a/include/linux/kernel.h b/include/linux/kernel.h Code:
#include <linux/kernel.h> Quote:
if yes, this is quite simple, there is no reason to fail. please review your code and write here what you found. happy hollyday! :) |
All times are GMT -5. The time now is 05:00 AM. |