kernel implementation of /proc/<pid>

Submitted by Anonymous
on January 21, 2007 - 3:29pm

I'm in serious trouble because I can't find where actually /proc/ entries are created. I scanned through /fs/proc/*.c files but got no idea how these entries in /proc are created. Can anyone help me out, please?

what are you trying to do?

Anonymous (not verified)
on
January 21, 2007 - 3:49pm

You do not state your problem clearly - how can anyone help?
Are you trying to learn how to create entries in the /proc filesystem?
Are you trying to find the actual code which creates certain entries in that filesystem?

The fs/proc/*.c code does not create entries just as the fs/ext2/*.c code does not create files - it is code elsewhere which invokes the filesystem code to create entries/files.

Thanks for your interest and

Anonymous (not verified)
on
January 21, 2007 - 6:58pm

Thanks for your interest and sorry for not being precise: I want to extend /proc filesystem. In order to do that each process needs to have a file in /proc/pid and it should be both readable and writable. I didn't state my problem clearly because actually I had a tiny or/and bad understanding of how /proc internals work. Now, after spending a few hours on struggling through sources, I've found out that it is that proc_pident_*() functions that do the whole thing (in fact proc_pident_lookup() or am I wrong?). Since I want my file writable I'm not quite sure but I think that just putting a proper struct (contaning .write field set to my write function) into the inode->i_op in proc_pident_lookup() should be enough.
I would be grateful for any comments/advice.

writing to PIDs ...

Anonymous (not verified)
on
January 21, 2007 - 7:19pm

Why do you want to write to a PID entry in proc?

There are numerous examples in the kernel code itself - have a look at other modules which use /proc and have writable entries (the NAT module should do that). Then you need to look carefully at the PID-related items in proc to see if there is support for writing information to the PID; if not, you will have to put that in yourself. Although what you want to do is technically feasible, I still can't imagine why you would want to do it, or is this a matter of doing something simply because it can be done?

/proc/pid enhancements

Anonymous (not verified)
on
January 21, 2007 - 8:10pm

I would want to do that because it's a task at my computer programming studies;). The task is to implement a method of reading and setting a limit for read(v)/write(v) operations and it must be done through a pair of /proc/pid/files (not to pid itself). Thanks for hint, but am I right with my conclusions in my previous post?

creating /proc entries

Dominique (not verified)
on
January 22, 2007 - 3:16am

As far as my limited knowledge goes, /proc entries are created through calls to create_proc_entry() or proc_create_entry() or somesuch. You then get a struct in which you can fill in handlers for reading to and writing from your proc entry. At least, this seems to be how it works in 2.4 kernels. Maybe things are different in 2.6, I don't know. Hope this helps.

Yes, 2.6 kernel has

Anonymous (not verified)
on
January 22, 2007 - 6:39am

Yes, 2.6 kernel has create_proc_entry() but it is not a sensible/convenient method to achieve what I want. I've found out by myself that better solution is to extend tid_base_stuff array and accompanying functions.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.