Thread (9 messages) flat view 9 messages, 4 authors, 2015-09-17

How to get the inode - no path_lookup

From: Rishi Agrawal <hidden>
Date: 2012-08-09 03:15:06

On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri [off-list ref] wrote:

On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal [off-list ref]wrote:
quoted
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.
quoted
--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120809/d518d7dd/attachment.html 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help