Results 1 to 6 of 6
i have a character array defined in /init/main.c as
char filepath[100];
i am accessing in /fs/open.c as
extern char filepath[100];
now i want to access this variable in my loadable ...
- 07-19-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 1
accessing global variables in loadable kernel modules
i have a character array defined in /init/main.c as
char filepath[100];
i am accessing in /fs/open.c as
extern char filepath[100];
now i want to access this variable in my loadable kernel module.
i have declared it as
extern char filepath[100];
but when i give a make command i get the following error
ERROR: "filepath" [drivers/misc/chardevopen.ko] undefined!
plz help me..
- 11-24-2008 #2Just Joined!
- Join Date
- Sep 2008
- Posts
- 21
sharing variable between two kernel module
hi
I am also in srch of this...how to share variable between two kernel module.
thanks
- 11-25-2008 #3
Are you trying to access a global variable in a user process from a kernel module??
If you are...an easy way to do this is to print the pid(process id) and address of the global variable and past them directly to the kernel module when you load it...Hope this helps Gerard4143...
Note you need the pid of the user process for this to work.....and you have to make sure the kernel is responding the user process for this to work...i.e. if you could hijack a system call that would do nicely
- 11-25-2008 #4Just Joined!
- Join Date
- Sep 2008
- Posts
- 21
use of extern variable in two kernel modules
No i dont want to access global variable in user space from kernel module. I want to access variable defined in one of the kernel module into another kernel module. How to use extern concept so that i will get same value which is assigned in one of the kernel module in another module.
Thanks
- 11-25-2008 #5
If you have a question npchanda you really should post it separately...you shouldn't hijack another persons posting...
But since you did ask you can solve your question the same as above, that is by printing the variable address when you install the kernel module “A” and then passing the address to the other kernel module “B” when you install it. If you want this variable to be permanently available (and visible) in the kernel well thats a process thats probably changed since I did it...Hope this Helps Geard4143
- 12-03-2008 #6Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
Hi
You have to export the symbol you wish to use in another module in the kernel. May be this can help.
Linux-Kernel Archive: exporting variables across modules


Reply With Quote

