From: rishi.b.agrawal@gmail.com (Rishi Agrawal)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to get the inode - no path_lookup
Date: Mon, 13 Aug 2012 14:17:08 +0530 [thread overview]
Message-ID: <CADDndfMJ2OSGYqWU=En1v4JvGR63PyMpmPYQ3BDTriGsmgiy-g@mail.gmail.com> (raw)
In-Reply-To: <CALJfu6NCQSjSG-_Ho4DuuEZekgKMO3mH1SrAh+nurjJwPvp7uA@mail.gmail.com>
On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri <rohan.puri15@gmail.com> wrote:
>
>
> On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal <rishi.b.agrawal@gmail.com>wrote:
>
>>
>>
>> On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri <rohan.puri15@gmail.com>wrote:
>>
>>>
>>>
>>> On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal <rishi.b.agrawal@gmail.com
>>> > wrote:
>>>
>>>> Hi All,
>>>>
>>>>
>>>> I had a module which used the path_lookup function to print the details
>>>> of any file's inode. I now want to rewrite that module in order to show
>>>> some juniors how to write some code in kernel.
>>>>
>>>> I am using 3.4.6 kernel, I tried finding out path_lookup but google
>>>> showed that it has been removed.
>>>>
>>>> I tried the following code then which did not work
>>>>
>>>> .
>>>> .
>>>> .
>>>> dentry = kern_path_create(AT_FDCWD, filename, &path, 1);
>>>>
>>>> if (IS_ERR(dentry)) {
>>>> printk("Failed to obtain the dentry");
>>>> return;
>>>> }
>>>>
>>>> its not returning dentry
>>>>
>>>> I again tried after seeing the implementation of vfs_stat function
>>>>
>>>> user_path_at(AT_FDCWD, filename, lookup_flags, &path);
>>>>
>>>> but this also fails.
>>>>
>>>>
>>>> I am using a proc interface to pass the filename, and copying the
>>>> filename into a kernel buffer.
>>>>
>>>> How can I get a copy of vfs inode for a file name.
>>>>
>>>>
>>>> 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.
>>>
>>>> --
>>>> Regards,
>>>> Rishi Agrawal
>>>>
>>>>
>>>> _______________________________________________
>>>> Kernelnewbies mailing list
>>>> Kernelnewbies at kernelnewbies.org
>>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>>
>>>>
>>> - Rohan
>>>
>>
>> vfs_path_lookup needs a dentry/mountpoint for the current path.
>>
>> How will I get those.
>>
>>
>> /**
>> * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
>> * @dentry: pointer to dentry of the base directory
>> * @mnt: pointer to vfs mount of the base directory
>> * @name: pointer to file name
>> * @flags: lookup flags
>> * @path: pointer to struct path to fill
>> */
>>
>>
>> --
>> Regards,
>> Rishi Agrawal
>>
>> If you dont have vfsmount'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's ptr. Now the dentry's ptr
> will contain the inode that you require.
>
> - Rohan
>
Thanks, used that and its working now
--
Regards,
Rishi Agrawal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120813/effeee59/attachment.html
next prev parent reply other threads:[~2012-08-13 8:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 14:41 How to get the inode - no path_lookup Rishi Agrawal
2012-08-08 7:16 ` Rohan Puri
2012-08-09 3:15 ` Rishi Agrawal
2012-08-09 7:09 ` Rohan Puri
2012-08-13 8:47 ` Rishi Agrawal [this message]
2012-08-13 9:34 ` Rohan Puri
2015-09-04 16:26 ` priyamn
2015-09-16 22:31 ` Greg KH
2015-09-17 8:10 ` Rohan Puri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADDndfMJ2OSGYqWU=En1v4JvGR63PyMpmPYQ3BDTriGsmgiy-g@mail.gmail.com' \
--to=rishi.b.agrawal@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).