ngo icon indicating copy to clipboard operation
ngo copied to clipboard

Get the full path(absolute path) of file or inode

Open liqinggd opened this issue 3 years ago • 0 comments

Problem 1

Many functions need to know the abs path of the file, e.g., the realpath() function or readlink from /proc/[pid]/fd/N.

In the previous implementation, we remember the path when opening the file, so it is easy to get the path for the opened file. However, if the file has been renamed, it can not influence the path for the opened file to use the new path.

Problem 2

In the current implementation, we just record the string of the path of cwd. If the dir of cwd itself is renamed, the cwd cannot be changed to the new path.

TODO

Obviously, the kernel should record the inode instead of the path of the file. However, It is incorrect to use the inode to get the full path, because the parent of one inode is not unique.

We need to handle the path of file or inode in a new way, maybe introducing dentry cache(DCache) is a solution.

liqinggd avatar Nov 10 '21 09:11 liqinggd