Reputation: 321
Is it possible to construct absolute path from the given dentry and inode?
Thanks all
Upvotes: 4
Views: 4618
Reputation: 927
yes, just one dentry is enough, back traversing through dentry->parent. take care when you meet a mountpoint, for linux support "one dentry mounts multiple devices" ... well, it's easy to code,just switch to vfsmnt->mnt_parent .
BTW: i was often confused why linux builds the mountpoint-linklist with a field "mnt_parent" rather than "mnt_child", when writing this answer, i seemed to guess out somthing.
Upvotes: 1
Reputation: 5696
Take a look at dentry_path()
. It will fill a buffer with the path up to the mount's root. To keep going past there, you'll need iterate through your file's f_vfsmount
and it's mnt_parent
s until you reach the real root of the file system.
Upvotes: 1
Reputation: 26910
If you have a struct path
(or can construct one), look at how tomoyo do this:
http://lxr.linux.no/linux+v2.6.37/security/tomoyo/realpath.c#L86
Upvotes: 1