gpt4 book ai didi

linux-kernel - linux 内核中的 path_lookup 如何工作?

转载 作者:行者123 更新时间:2023-12-05 05:25:24 29 4
gpt4 key购买 nike

我们是否需要提供完整路径或仅提供对象名称(文件/目录),它是否处理路径中的挂载目录以及 LOOKUP_FOLLOW 是什么意思?

最佳答案

您可能知道,path_lookup 用于查找与路径名字符串对应的目录。搜索将按以下方式进行:

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.

所以问题第一部分的答案是——应该指定完整路径。关于 LOOKUP_FOLLOW - 如果指定,它将在搜索期间遵循符号链接(symbolic link)。

Does it take care of mounted directory in the path

不知道你在这里是什么意思。

详情请见: http://www2.comp.ufscar.br/lxr/source/Documentation/filesystems/path-lookup.txt?a=ia64

关于linux-kernel - linux 内核中的 path_lookup 如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31342628/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com