Currently the VFS layer does not track parent directories. .. is silently skipped in walk_with_depth() and resolve_path_nofollow() falls back to resolve_path() when encountering ... This means:
cd /tmp/foo/.. resolves to /tmp/foo instead of /tmp
stat("/tmp/..") returns the stat of /tmp instead of /
- Paths like
/a/b/../c resolve to /a/b/c instead of /a/c
Proposed approach
Track the parent node during path resolution. Options:
-
Walk-time parent stack: Maintain a stack of parent nodes during walk_with_depth(). When encountering .., pop the stack. This is the simplest approach and doesn't require storing parent refs on nodes.
-
Per-node parent ref: Store a Weak<dyn VfsNode> parent reference on each TmpfsDir/TmpfsFile. Set on creation. More complex but enables getcwd() to walk up the tree.
Option 1 is likely sufficient — Linux also resolves .. during path walk, not via stored parent pointers.
Files involved
kernel/src/fs/vfs.rs — walk_with_depth(), resolve_path_nofollow(), resolve_parent()
kernel/src/syscalls/fs_ops.rs — resolve_stat_node() dirfd-relative .. handling
Current workaround (commit 42eb6f6)
.. is skipped in walk_with_depth and treated as . in resolve_path_nofollow / resolve_stat_node. This unblocks ls -alh but is semantically incorrect for programs that rely on .. for navigation.
Created by Claude Code
Currently the VFS layer does not track parent directories.
..is silently skipped inwalk_with_depth()andresolve_path_nofollow()falls back toresolve_path()when encountering... This means:cd /tmp/foo/..resolves to/tmp/fooinstead of/tmpstat("/tmp/..")returns the stat of/tmpinstead of//a/b/../cresolve to/a/b/cinstead of/a/cProposed approach
Track the parent node during path resolution. Options:
Walk-time parent stack: Maintain a stack of parent nodes during
walk_with_depth(). When encountering.., pop the stack. This is the simplest approach and doesn't require storing parent refs on nodes.Per-node parent ref: Store a
Weak<dyn VfsNode>parent reference on eachTmpfsDir/TmpfsFile. Set on creation. More complex but enablesgetcwd()to walk up the tree.Option 1 is likely sufficient — Linux also resolves
..during path walk, not via stored parent pointers.Files involved
kernel/src/fs/vfs.rs—walk_with_depth(),resolve_path_nofollow(),resolve_parent()kernel/src/syscalls/fs_ops.rs—resolve_stat_node()dirfd-relative..handlingCurrent workaround (commit 42eb6f6)
..is skipped inwalk_with_depthand treated as.inresolve_path_nofollow/resolve_stat_node. This unblocksls -alhbut is semantically incorrect for programs that rely on..for navigation.Created by Claude Code