How to get the dentry value - no path_lookup
Hi, I happened to come across the below discussion. http://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-August/005914.ht... 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 Mon, Sep 7, 2015 at 12:10 PM, Pria Mn <pria.mn9@gmail.com> wrote:
Hi,
I happened to come across the below discussion.
http://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-August/005914.ht...
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 ?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Pria, This is in regards with which kernel version? also what are you trying to do, please be more detailed. Enjoy life, Rohan
Hi Rohan, I am using 3.10.0-123.el7.x86_64 kernel (RHEL-7). I am trying to obtain 'dentry' value from file path information. For this: earlier I had written the code as below : #if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) err= kern_path_parent(tmp,nd); #else err= path_lookup(tmp, 0, nd); #endif Now that "nameidata" structure is not exposed with kernel version >= 3.6.0 I used kern_path_create() which is returning invalid dentry value. dentry =kern_path_create(AT_FDCWD, tmp, path, 1); So, I tried using : user_path_at() , kern_path() which are not helping me. How to fetch 'dentry' data from file name ? On Mon, Sep 7, 2015 at 12:45 PM, Rohan Puri <rohan.puri15@gmail.com> wrote:
On Mon, Sep 7, 2015 at 12:10 PM, Pria Mn <pria.mn9@gmail.com> wrote:
Hi,
I happened to come across the below discussion.
http://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-August/005914.ht...
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 ?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Pria,
This is in regards with which kernel version? also what are you trying to do, please be more detailed.
Enjoy life, Rohan
On Mon, Sep 7, 2015 at 1:11 PM, Pria Mn <pria.mn9@gmail.com> wrote:
Hi Rohan,
I am using 3.10.0-123.el7.x86_64 kernel (RHEL-7). I am trying to obtain 'dentry' value from file path information. For this: earlier I had written the code as below :
#if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
err= kern_path_parent(tmp,nd);
#else
err= path_lookup(tmp, 0, nd);
#endif Now that "nameidata" structure is not exposed with kernel version >= 3.6.0 I used kern_path_create() which is returning invalid dentry value.
dentry =kern_path_create(AT_FDCWD, tmp, path, 1);
So, I tried using : user_path_at() , kern_path() which are not helping me.
How to fetch 'dentry' data from file name ?
On Mon, Sep 7, 2015 at 12:45 PM, Rohan Puri <rohan.puri15@gmail.com> wrote:
On Mon, Sep 7, 2015 at 12:10 PM, Pria Mn <pria.mn9@gmail.com> wrote:
Hi,
I happened to come across the below discussion.
http://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-August/005914.ht...
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 ?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Pria,
This is in regards with which kernel version? also what are you trying to do, please be more detailed.
Enjoy life, Rohan
Hi Pria, Yes, just checked nameidata is moved to fs/internal.h file, I think you can make use of kern_path <http://lxr.free-electrons.com/ident?v=2.6.34;i=kern_path>() here. NOTE: Also please post reply at the bottom. Enjoy life, Rohan
On Mon, 07 Sep 2015 12:10:56 +0530, Pria Mn said:
return valid dentry value. My requirement is to fetch directory name from filepath.
First off, unless this is a class assignment, your *requirement* isn't to fetch a directory name. Fetching the directory name is a *solution* you're thinking of using for a problem you're trying to solve. So take a step back, and explain what you're trying to do, and why you thought getting the directory name from filepath was a solution - it's quite likely that you should be using some other API and approach entirely. (I'd estimate that 75% of the "I can't get this API to work" questions on the Linux kernel are because the person should be using a different API....)
On 7 Sep 2015 23:25, <Valdis.Kletnieks@vt.edu> wrote:
On Mon, 07 Sep 2015 12:10:56 +0530, Pria Mn said:
return valid dentry value. My requirement is to fetch directory name
from
filepath.
First off, unless this is a class assignment, your *requirement* isn't to fetch a directory name.
Fetching the directory name is a *solution* you're thinking of using for a problem you're trying to solve.
So take a step back, and explain what you're trying to do, and why you thought getting the directory name from filepath was a solution - it's quite likely that you should be using some other API and approach entirely.
(I'd estimate that 75% of the "I can't get this API to work" questions on the Linux kernel are because the person should be using a different API....)
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Yes Valdis is absolutely right about being clear as to what you want to do and why you would be doing that. Also for what does the api do you need to understand the code and browse using tools(cscope ctags maybe others) to check for other APIs doing the same and you would definitely find one for your need. The way I would suggest is don't rush through, enjoy the process and not the result. Enjoy life, Rohan
participants (3)
-
Pria Mn -
Rohan Puri -
Valdis.Kletnieks@vt.edu