Linux kernel and inode

Is it possible to build an absolute path from a given dentin and inode?

Thank you all

+4
source share
3 answers

If you have a struct path (or can build one), see how to do it tomoyo: http://lxr.linux.no/linux+v2.6.37/security/tomoyo/realpath.c#L86

+1
source

Take a look at dentry_path() . It will fill the buffer using the path to the mount root. To continue moving, you will need to f_vfsmount over the f_vfsmount and mnt_parent until you reach the real root of the file system.

+1
source

yes, one gear is enough, the back passing through dentry-> parent. take care when you meet the mount point, to support linux β€œone cable mounts multiple devices” ... well, it's easy to encode it, just switch to vfsmnt-> mnt_parent.

BTW: I was often confused why linux is building a mountpoint-linklist listing with the "mnt_parent" field and not the "mnt_child" field, when I write this answer, I seemed to be guessing something.

+1
source

Source: https://habr.com/ru/post/1334624/


All Articles