Write data to proc

5 views
Skip to first unread message

Jagadeesh Dyaberi

unread,
Mar 30, 2009, 12:38:31 PM3/30/09
to linux...@googlegroups.com
Hello all,

I have some data which I need to write to /proc where it will be accessed by another module. I am not sure how to do this. I can get a kernel module to compile and create a file in /proc, but not sure how best to write data. The data to be written can be hardcoded into the write module and need not be inputted from the userspace.

Thanks,

Jagadeesh.

Lokesh

unread,
Apr 4, 2009, 10:35:21 PM4/4/09
to linuxgurus
Hi,

Hmm.. As per for requirement, basically you need to communicate /
exchange information or data between two modules?
Generally we use this /proc to see the instant behavior of the system
or module. User will use this to find the current status
of his expectations.

So, just think if your data is that so important to show to userspace
then going to /proc will be a good option.
And as /proc is the place where the data will be generated on the fly.
You can make suitable access rights to
protect your data.

So, if you just want to pass this information / data to another
module, well we have another methods to do this
in modules itself. Check out the struct module...

Regards
Lokesh

Jagadeesh Dyaberi

unread,
Apr 5, 2009, 2:40:09 PM4/5/09
to linux...@googlegroups.com
Yeah, the data I need to communicate to the module comes from userspace. Data is calculated offline in userspace and the end result needs to be passed to the kernel module. Therefore I need to write it to proc so that the other module can access the data.

Thanks,
Jagadeesh

Lokesh

unread,
Apr 11, 2009, 1:04:43 AM4/11/09
to linuxgurus
Well, as i explained earlier, u dont need to add to the /proc. Instead
use the memory or a buffer
in the module1 and acess this buffer in module2, make the module2
dependent on module1.
hint: Export few functions to access this buffer such as read, write
in to the buffer.
Refer the lkmpg (Linux Kernel Module Programming Guide) for further

~Lokesh

Jagadeesh Dyaberi

unread,
Apr 11, 2009, 11:43:12 AM4/11/09
to linux...@googlegroups.com
yeah, I got it working. I misread what you were trying to say in the previous mail. Using two modules and exporting the variable did the trick

Thanks,

Jagadeesh
Reply all
Reply to author
Forward
0 new messages