我们是否需要提供完整路径或仅提供对象(文件/目录)的名称,它是否会处理路径中的已安装目录以及LOOKUP_FOLLOW的含义是什么?
答案 0 :(得分:2)
您可能知道,path_lookup用于查找与路径名字符串对应的dentry。搜索将按以下方式进行:
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 - 如果指定,它将在搜索过程中遵循符号链接。
是否负责路径中的挂载目录
不确定你在这里是什么意思。
有关详细信息,请参阅: http://www2.comp.ufscar.br/lxr/source/Documentation/filesystems/path-lookup.txt?a=ia64