Repository navigation
Add support for symlink resolution - #1566
Conversation
|
Agents found the following issue: stat on /proc/self/fd/ no longer works for paths written in any non-canonical form Where: litebox_shim_linux/src/syscalls/file.rs • do_path_stat , line 1530: path.starts_with("/proc/self/fd/") What changed: before this PR, do_path_stat called pathname.normalized() before checking for the hardcoded /proc/self/fd/ prefix. The PR removes that call and now matches the raw path string. Neither caller normalizes the path either: resolve_path (used by stat and lstat ) and FsPath::new (used by newfstatat and statx ) only add the cwd prefix to relative paths. So the check now sees the path exactly as the guest wrote it. Effect: any path that reaches the same entry but isn't written in canonical form misses the special case. It then goes to the real filesystem, which has no /proc/self/fd entries, and the call fails with ENOENT instead of returning the status of /dev/stdin , /dev/stdout or /dev/stderr : ┌─────────────────────────────────────┬────────┬───────────────────────────────────────────────────────────────────────┐ The relative-path case is the one a real program is most likely to hit. Suggested fix: don't just put the old lexical normalized() back. Now that symlinks exist, .. has to be resolved against the real directories, so collapsing it as text could give the wrong answer. Two options:
Either way, please add regression tests for the equivalent spellings above. Related, but not introduced by this PR: do_readlink hits _ => unimplemented!() for any fd above 2 ( file.rs:1420 ). That means a guest calling stat("/proc/self/fd/5") can panic the shim. It's worth returning an errno, or looking up the real fd, while this code is being changed. |
|
Two more issues reported by agents:
Location: litebox/src/fs/composer.rs , in the AncestorOfMount branch of walk_directories and in read_link_at (line 597). I set up a root InMem plus a second InMem mounted at /a/b , which contains x : ┌────────────────────────┬─────────────────────────────────────────┬─────────────┬────────────────┐ The symlink silently skips the mount, and readlink succeeds on a path that lstat says doesn't exist. Today's composers only mount at / and /dev , so nothing hits this yet. Suggested fix: apply checked_child_path in read_link_at , and either don't follow a backend symlink in an ancestor-of-mount position or reject that setup.
• Before this PR, it created a regular file named missing . |
|
Thanks Weidong. For the issues your agents found:
Thus, no changes to the code due to these. I'll rebase to account for the conflicts and then merge soon. |
8ab4e4b to
df68f90
Compare
df68f90 to
ec54f37
Compare
|
🤖 SemverChecks 🤖 Click for details |
This PR introduces initial support for symlinks to our file system. Specifically, it introduces symlink resolution and support for initializing the in-memory file system with symlinks. Future PRs will introduce more support, such as the guest being able to create symlinks, and other backends supporting symlinks.