<div>Following your recommendations parent->pde always returns NULL. You know why ?</div><div><br></div><div>// code...</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>err = kern_path("/proc/1/", LOOKUP_FOLLOW, &path);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (err) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return err;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>struct proc_inode *parent = PROC_I(path.dentry->d_inode);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>struct proc_dir_entry *parent_dir = parent->pde;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (parent_dir == NULL) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>printk("parent_dir is NULL\n");</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} else {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>create_proc_entry("SOMEFile", 0644, parent_dir);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div><div><br></div>
<div><br></div><div>Mauro!</div><div><br></div><div class="gmail_quote">On Tue, Jan 11, 2011 at 4:39 AM, Rajat Sharma <span dir="ltr"><<a href="mailto:fs.rajat@gmail.com">fs.rajat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Try this:<br>
1. do a path_lookup for parent proc dir e.g. /proc/1234 and get its inode.<br>
2. get proc_inode structure for parent from vfs inode like this:<br>
sruct proc_inode *parent = PROC_I(inode).<br>
PROC_I is defined in proc_fs.h<br>
3. get parent proc_dir_entry object:<br>
struct proc_dir_entry *parent_dir = parent->pde;<br>
4. now you can call:<br>
create_proc_entry("SOME file", 0644, parent_dir);<br>
5. or you can create a directory if you want:<br>
proc_mkdir("your dir", parent_dir);<br>
<br>
hope this helps.<br>
<br>
Rajat<br>
<br>
On Tue, Jan 11, 2011 at 12:19 AM, Mauro Romano Trajber<br>
<div class="im"><<a href="mailto:trajber@gmail.com">trajber@gmail.com</a>> wrote:<br>
> I think I found:<br>
> static const struct pid_entry tgid_base_stuff[] at fs/proc/base.c has all<br>
> /proc/[pid] entries.<br>
> But unfortunately it does not use create_proc_entry function, and I'm trying<br>
> to create a new syscall that creates a new proc_entry for the caller<br>
> process.<br>
> Adding a new element in tgid_base_stuff[] makes the things more complicated<br>
> than simply call a create_proc_entry function.<br>
> Is there another way to do it ?<br>
> Mauro Romano Trajber<br>
><br>
> On Mon, Jan 10, 2011 at 3:18 PM, Mauro Romano Trajber <<a href="mailto:trajber@gmail.com">trajber@gmail.com</a>><br>
> wrote:<br>
>><br>
>> How can I create a new proc entry under /proc/[pid] ?<br>
>> I using create_proc_entry("SOME_FILE", 0644, NULL /* here goes the pid<br>
>> proc entry */);<br>
>> Is there any way to get PID directory as a parent proc entry ? How ?<br>
>> Thanks,<br>
>> Mauro<br>
><br>
</div>> _______________________________________________<br>
> Kernelnewbies mailing list<br>
> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
><br>
</blockquote></div><br>