<br><br><div class="gmail_quote">On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri <span dir="ltr">&lt;<a href="mailto:rohan.puri15@gmail.com" target="_blank">rohan.puri15@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal <span dir="ltr">&lt;<a href="mailto:rishi.b.agrawal@gmail.com" target="_blank">rishi.b.agrawal@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br><br><div class="gmail_quote">On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri <span dir="ltr">&lt;<a href="mailto:rohan.puri15@gmail.com" target="_blank">rohan.puri15@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br><br><div class="gmail_quote"><div><div>On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal <span dir="ltr">&lt;<a href="mailto:rishi.b.agrawal@gmail.com" target="_blank">rishi.b.agrawal@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi All,<br><br><br>I had a module which used the path_lookup function to print the details of any file&#39;s inode. I now want to rewrite that module in order to show some juniors how to write some code in kernel.<br><br>





I am using 3.4.6 kernel, I tried finding out path_lookup but google showed that it has been removed.<br>

<br>I tried the following code then which did not work<br><br>.<br>.<br>.<br>dentry = kern_path_create(AT_FDCWD, filename, &amp;path, 1);<br><br>if (IS_ERR(dentry)) {<br>              printk(&quot;Failed to obtain the dentry&quot;);<br>







               return;<br>       }<br><br>its not returning dentry<br><br>I again tried after seeing the implementation of vfs_stat function <br><br>user_path_at(AT_FDCWD, filename, lookup_flags, &amp;path);<br><br>but this also fails.<br>







<br><br>I am using a proc interface to pass the filename, and copying the filename into a kernel buffer.<br><br>How can I get a copy of vfs inode for a file name.<span><font color="#888888"><br><br clear="all">
<br></font></span></blockquote></div></div><div>Need to use vfs_path_lookup for this, present in fs/namei.c file, which would give you filled nameidata nd that contais inodes pointer.<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<span><font color="#888888">-- <br>Regards,<br>Rishi Agrawal<br>

<br>
</font></span><br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">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></blockquote></div><span><font color="#888888"><br>- Rohan<br>
</font></span></blockquote></div><br></div></div>vfs_path_lookup needs a dentry/mountpoint for the current path. <br><br>How will I get those.<br><br><br>/**<br> * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair<br>




 * @dentry:  pointer to dentry of the base directory<br> * @mnt: pointer to vfs mount of the base directory<br> * @name: pointer to file name<br> * @flags: lookup flags<br> * @path: pointer to struct path to fill<br> */<span><font color="#888888"><br>




<br clear="all"><br>-- <br>Regards,<br>Rishi Agrawal<br><br>
</font></span></blockquote></div></div></div>If you dont have vfsmount&#39;s ptr, then you can make use of kern_path api with the LOOKUP_FOLLOW as second parameter. This will return the struct path ptr which contains vfsmount and the dentry&#39;s ptr. Now the dentry&#39;s ptr will contain the inode that you require.<span class="HOEnZb"><font color="#888888"><br>


<br>- Rohan<br>
</font></span></blockquote></div><br>Thanks, used that and its working now<br clear="all"><br>-- <br>Regards,<br>Rishi Agrawal<br><br>