问题描述
是否可以从给定的dentry和inode构造绝对路径?
Is it possible to construct absolute path from the given dentry and inode?
谢谢
推荐答案
是的,只需一个dentry就足够了,可以遍历dentry-> parent.遇到挂载点时请多加注意,因为linux支持一个dentry挂载多个设备" ...好吧,编写代码很容易,只需切换到vfsmnt-> mnt_parent即可.
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 .
顺便说一句:我经常感到困惑,为什么linux用一个字段"mnt_parent"而不是"mnt_child"来构建mountpoint-linklist,在写这个答案时,我似乎猜出了什么.
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.
这篇关于Linux内核dentry和inode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!