How to know the path for a corresponding inode number
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
If i know the inode reference i.e.
struct inode *inode;
and struct dentry structure will be containing path information for a particular dentry in d_iname variable.
How can I map from &inode->i_dentry to know the path of corresponding inode? also How to map from struct inode to struct dentry?
linux kernel
add a comment |
up vote
1
down vote
favorite
If i know the inode reference i.e.
struct inode *inode;
and struct dentry structure will be containing path information for a particular dentry in d_iname variable.
How can I map from &inode->i_dentry to know the path of corresponding inode? also How to map from struct inode to struct dentry?
linux kernel
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
If i know the inode reference i.e.
struct inode *inode;
and struct dentry structure will be containing path information for a particular dentry in d_iname variable.
How can I map from &inode->i_dentry to know the path of corresponding inode? also How to map from struct inode to struct dentry?
linux kernel
If i know the inode reference i.e.
struct inode *inode;
and struct dentry structure will be containing path information for a particular dentry in d_iname variable.
How can I map from &inode->i_dentry to know the path of corresponding inode? also How to map from struct inode to struct dentry?
linux kernel
linux kernel
asked Oct 14 '15 at 8:25
LinuxLerner
163
163
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
In the general case, you can't. There isn't a one-to-one correspondence between inodes and directory entries:
$ touch file1.txt
$ ln file1.txt file2.txt
$ ls -li file*.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file1.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file2.txt
Which path is the "real" one for inode 1332145968
?
$ rm file2.txt
$ tail -f file1.txt &
[1] 7781
$ rm file1.txt
What about now? Inode 1332145968
is still in use, as you can see using lsof
, but it has no path.
add a comment |
up vote
0
down vote
Path you can trace using d_parent field from d_entry and saving the names. This will take you till the root of the file system. But be careful in case the inode object belongs to mounted file system, in such case the trace back will stop at mount point.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
In the general case, you can't. There isn't a one-to-one correspondence between inodes and directory entries:
$ touch file1.txt
$ ln file1.txt file2.txt
$ ls -li file*.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file1.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file2.txt
Which path is the "real" one for inode 1332145968
?
$ rm file2.txt
$ tail -f file1.txt &
[1] 7781
$ rm file1.txt
What about now? Inode 1332145968
is still in use, as you can see using lsof
, but it has no path.
add a comment |
up vote
1
down vote
In the general case, you can't. There isn't a one-to-one correspondence between inodes and directory entries:
$ touch file1.txt
$ ln file1.txt file2.txt
$ ls -li file*.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file1.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file2.txt
Which path is the "real" one for inode 1332145968
?
$ rm file2.txt
$ tail -f file1.txt &
[1] 7781
$ rm file1.txt
What about now? Inode 1332145968
is still in use, as you can see using lsof
, but it has no path.
add a comment |
up vote
1
down vote
up vote
1
down vote
In the general case, you can't. There isn't a one-to-one correspondence between inodes and directory entries:
$ touch file1.txt
$ ln file1.txt file2.txt
$ ls -li file*.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file1.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file2.txt
Which path is the "real" one for inode 1332145968
?
$ rm file2.txt
$ tail -f file1.txt &
[1] 7781
$ rm file1.txt
What about now? Inode 1332145968
is still in use, as you can see using lsof
, but it has no path.
In the general case, you can't. There isn't a one-to-one correspondence between inodes and directory entries:
$ touch file1.txt
$ ln file1.txt file2.txt
$ ls -li file*.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file1.txt
1332145968 -rw-r--r-- 2 mark mark 0 Oct 17 17:02 file2.txt
Which path is the "real" one for inode 1332145968
?
$ rm file2.txt
$ tail -f file1.txt &
[1] 7781
$ rm file1.txt
What about now? Inode 1332145968
is still in use, as you can see using lsof
, but it has no path.
answered Oct 18 '15 at 0:13
Mark
1,98411327
1,98411327
add a comment |
add a comment |
up vote
0
down vote
Path you can trace using d_parent field from d_entry and saving the names. This will take you till the root of the file system. But be careful in case the inode object belongs to mounted file system, in such case the trace back will stop at mount point.
add a comment |
up vote
0
down vote
Path you can trace using d_parent field from d_entry and saving the names. This will take you till the root of the file system. But be careful in case the inode object belongs to mounted file system, in such case the trace back will stop at mount point.
add a comment |
up vote
0
down vote
up vote
0
down vote
Path you can trace using d_parent field from d_entry and saving the names. This will take you till the root of the file system. But be careful in case the inode object belongs to mounted file system, in such case the trace back will stop at mount point.
Path you can trace using d_parent field from d_entry and saving the names. This will take you till the root of the file system. But be careful in case the inode object belongs to mounted file system, in such case the trace back will stop at mount point.
answered Oct 17 '15 at 21:08
Vishal Sahu
787
787
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f236024%2fhow-to-know-the-path-for-a-corresponding-inode-number%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown