How to read file in kernel module?
Hello,
I have written one /proc file creation kernel
module. This module creates /proc/file and defied operations on it. Also i have written user program that will read & write to /proc files from user space. Now what i want is to use same bufproc_read & bufproc_write functions defined in /proc file handling kernel module to be used in another kernel module to read that /proc/file in kernel module.The second kernel module only used to read /proc file in kernel. I am not understanding how can i open that /proc/file in second kenrel module to read in kernel? regards,linux_lover.
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
Quoted 5 lines · linux lover
Hello,
I have written one /proc file creation kernel
module. This module creates/proc/fileand defied operations on it. Also i have written user program that will read & write to /proc files from user space.
Quoted 8 lines
Now what i want is to use same
bufproc_read&bufproc_writefunctions defined in /proc file handling kernel module to be used in another kernel module to read that/proc/filein kernel module.The second kernel module only used to read /proc file in kernel. I am not understanding how can i open that/proc/filein second kenrel module to read in kernel? regards,
the answer really is that you should not read files from kernel modules; /proc or otherwise.
Hi,
Quoted 13 lines
Quoted 4 lines
I have written one /proc file creation kernel
module. This module creates/proc/fileand defied operations on it. Also i have written user program that will read & write to /proc files from user space.Quoted 8 lines
Now what i want is to use same
bufproc_read&bufproc_writefunctions defined in /proc file handling kernel module to be used in another kernel module to read that/proc/filein kernel module.The second kernel module only used to read /proc file in kernel. I am not understanding how can i open that/proc/filein second kenrel module to read in kernel? regards,
Quoted 2 lines
the answer really is that you should not read files from kernel modules; /proc or otherwise.
the only thing that is may needed by a kernel driver should be an external firmware file and for that we have request_firmware(). For everything else you are on the wrong track.
Regards
Marcel
Am 2005-02-07 07:38:36, schrieb Arjan van de Ven:
Quoted 2 lines
the answer really is that you should not read files from kernel modules; /proc or otherwise.
I think, he mean something like
echo "1" >/proc/sys/net/ipv4/ip_forward
Where you can (de)activate Kernel functions.
Greetings
Michelle
Signature · 4 lines
Linux-User #280138 with the Linux Counter, http://counter.li.org/
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)Quoted 11 lines · Arjan van de Ven
Quoted 8 lines · linux lover
Now what i want is to use same
bufproc_read&bufproc_writefunctions defined in /proc file handling kernel module to be used in another kernel module to read that/proc/filein kernel module.The second kernel module only used to read /proc file in kernel. I am not understanding how can i open that/proc/filein second kenrel module to read in kernel? regards,
Quoted 2 lines
the answer really is that you should not read files from kernel modules; /proc or otherwise.
As Arjan said - what you probably want to be doing instead is changing the code in your first module that provides the bufproc_* functions so that they're wrappers around some code that does the "real work", and then call the real_work function from your second module. Most likely, what you *really* want to be passing around is some 'struct *foo', and the bufproc_* functions are converting to/from a struct foo and a linear byte stream. (In the limiting case where it's just one variable, why not just 'EXPORT_SYMBOL(variable)' in the first module and then just assign or read the variable from the second module?)
Quoted 7 lines · linux lover
Now what i want is to use same
bufproc_read&bufproc_writefunctions defined in /proc file handling kernel module to be used in another kernel module to read that/proc/filein kernel module.The second kernel module only used to read /proc file in kernel. I am not understanding how can i open that/proc/filein second kenrel module to read in kernel?
Look at kernel_read() in fs/exec.c and fs/binfmt_*.c
Regards, Olaf.