How to get the information from /proc/files from within a kernel module?

Aruna Hewapathirane aruna.hewapathirane at gmail.com
Mon Aug 25 12:42:55 EDT 2014


>
> >> I want process related information like rss.(we can get this by doing
> cat /proc/<pid>status) Is there a way to get this from >> within a kernel
> module? I checked out the sources on /proc filesystem. They all show how to
> create, read, write a new
>
>> proc file. But I want to read from an existing proc file specifically
> /proc/<pid>/status
>

Have a look here: https://gist.github.com/Aruna-Hewapathirane
/f41e7291e15bae6062a1 does exactly what your trying to do.

>> Can anyone please point me to either resources or guide me to accomplish
> the task of reading information from
>
>>/proc/files...
>

I would suggest you go through the source code for PS : http://procps.
sourceforge.net/ and carefully study how things are done.

This will also help: https://www.kernel.org/doc/Documentation/filesystems/
proc.txt

That being said I have to agree fully with Valdis the best way is always to
grep through the kernel that way you get to see code that is being used and
how things are done.

With all due respect to all the more experienced and knowledgeable folks on
the list I had great difficulty when I first started out accessing
information and I have no wish to see anyone who is fascinated by the
kernel and wants to mess with the internals be it for fun as a hobby to
learn or for serious patching and contributing to the kernel walk away
frustrated like I did so many times. ( I always walked right back though...
:)

Yes Valdis you can give me a hard time on IRC when I next show up :)

Aruna ( Ravali, please heed Valdis's advice that is the best way. I just
pointed you in the right direction with a bit more code to play with but
try to do your own digging first through the kernel and good luck ! )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140825/ab79d343/attachment.html 


More information about the Kernelnewbies mailing list