Linux kernel linux内核中的路径查找是如何工作的?
我们需要提供完整的路径还是只提供对象的名称(文件/目录),它是否负责路径中的挂载目录,以及查找的含义是什么?正如您所知,路径查找用于查找与路径名称字符串对应的dentry。搜索将按以下方式进行:Linux kernel linux内核中的路径查找是如何工作的?,linux-kernel,Linux Kernel,我们需要提供完整的路径还是只提供对象的名称(文件/目录),它是否负责路径中的挂载目录,以及查找的含义是什么?正如您所知,路径查找用于查找与路径名称字符串对应的dentry。搜索将按以下方式进行: 245 dentry 0 246 +---------------------+ rcu-walk begins here, we note d_seq, check the 247 | name: "/" | inode's permission,
245 dentry 0
246 +---------------------+ rcu-walk begins here, we note d_seq, check the
247 | name: "/" | inode's permission, and then look up the next
248 | inode: 10 | path element which is "home"...
249 | children:"home", ...|
250 +---------------------+
251 |
252 dentry 1 V
253 +---------------------+ ... which brings us here. We find dentry1 via
254 | name: "home" | hash lookup, then note d_seq and compare name
255 | inode: 678 | string and parent pointer. When we have a match,
256 | children:"npiggin" | we now recheck the d_seq of dentry0. Then we
257 +---------------------+ check inode and look up the next element.
258 |
259 dentry2 V
260 +---------------------+ Note: if dentry0 is now modified, lookup is
261 | name: "npiggin" | not necessarily invalid, so we need only keep a
262 | inode: 543 | parent for d_seq verification, and grandparents
263 | children:"a.c", ... | can be forgotten.
264 +---------------------+
265 |
266 dentry3 V
267 +---------------------+ At this point we have our destination dentry.
268 | name: "a.c" | We now take its d_lock, verify d_seq of this
269 | inode: 14221 | dentry. If that checks out, we can increment
270 | children:NULL | its refcount because we're holding d_lock.
所以问题第一部分的答案是——应该指定完整的路径。
关于查找\u FOLLOW-如果指定,它将在搜索期间跟随符号链接
它是否负责路径中装入的目录
不知道你在这里是什么意思
有关更多详细信息,请参阅:
看起来不像是编程问题。可能要迁移到。@asgs这是一个纯粹的编程问题,关于内核函数如何工作。如果你不理解这个问题,为什么需要混淆作者?谢谢你的回答Alex。关于最后一个问题,我的意思是它如何发现特定的dentry是路径中的一个装入点?实际上,根据文档,它必须遍历装入点,这到底是如何做到的-我不知道。我看到dentry结构中有d_安装的字段。如果dentry是装载点,则将其设置为1。我认为这就是Linux如何分离这个“挂载点dentries”并跳转到新fs的方式。