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.
--
Regards,
Rishi Agrawal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120807/2c863831/attachment.html
On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal [off-list ref]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.
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.
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
On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal [off-list ref]wrote:
On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri [off-list ref]wrote:
quoted
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.
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
On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri [off-list ref] wrote:
On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal [off-list ref]wrote:
quoted
On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri [off-list ref]wrote:
quoted
On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal <rishi.b.agrawal@gmail.com
quoted
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.
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
On Mon, Aug 13, 2012 at 2:17 PM, Rishi Agrawal [off-list ref]wrote:
On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri [off-list ref]wrote:
quoted
On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal [off-list ref]wrote:
quoted
On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri [off-list ref]wrote:
quoted
On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal <
rishi.b.agrawal at gmail.com> 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.
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
Good to know :)
Hi,
I happened to come across this discussion. I am having a similar issue.
I am using Rhel7-3.10.0-123
kernel. I tried all the options that are mentioned above and none of the api's
including kern_path() return valid dentry value.
My requirement is to fetch directory name from filepath.
Can anybody suggest a work-around for this ?
On Fri, Sep 04, 2015 at 04:26:06PM +0000, priyamn wrote:
Hi,
I happened to come across this discussion. I am having a similar issue.
I am using Rhel7-3.10.0-123
kernel. I tried all the options that are mentioned above and none of the api's
including kern_path() return valid dentry value.
My requirement is to fetch directory name from filepath.
Why do you need a directory name from a filepath within the kernel?
What problem are you trying to solve that you feel a directory name is
the correct solution?
And remember, namespaces, what does a "directory name" really mean... :)
thanks,
greg k-h
On 17 Sep 2015 04:02, "Greg KH" [off-list ref] wrote:
On Fri, Sep 04, 2015 at 04:26:06PM +0000, priyamn wrote:
quoted
Hi,
I happened to come across this discussion. I am having a similar issue.
I am using Rhel7-3.10.0-123
kernel. I tried all the options that are mentioned above and none of
the api's
quoted
including kern_path() return valid dentry value.
My requirement is to fetch directory name from filepath.
Why do you need a directory name from a filepath within the kernel?
What problem are you trying to solve that you feel a directory name is
the correct solution?
And remember, namespaces, what does a "directory name" really mean... :)
thanks,
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Priya,
Please make use of a single thread for one topic. There was another thread
by you on the same topic. Anyways, I am replying to this one.
Greg has asked questions that you should ask yourself before going on with
choosing one approach.
I had suggested you using kern_path() earlier, since it doesn't makes use
of nameidata, but as you are telling its not working too. Here I would like
to know the actual context of the approach so as to figure out if something
I know that can work for you or maybe you shouldn't be doing it that way.
Enjoy life,
Rohan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150917/8a6be1e8/attachment.html