How to get dentry from inode number?
Hello, every body.
How can I get a full pathname from an inode number ? (Our data structure only keep track inode number instead of pathname in order to keep thin, so don't have any information but inode number.)
I used iget_locked() to get a struct inode * from an inode number, and use d_find_alias() to get a dentry, finally use d_path() to get a absoulte path to the file.
But it only works when I opened the target file before I run my program, or the d_find_alias() will return NULL.
I also tried d_alloc_anno() and d_splice_alias(), but it crashed in the d_splice_alias().
So, which function should I check to find the answer?
Quoted 2 lines · ?X??
How can I get a full pathname from an inode number ?
That's fundamentally impossible to do. Any given inode may have multiple paths associated to it. Think of hard links.
Jörn
Signature · 3 lines
"[One] doesn't need to know [...] how to cause a headache in order to take an aspirin." -- Scott Culp, Manager of the Microsoft Security Response Center, 2001