-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Bug Description
When running ls /tmp, the output incorrectly shows mount points (/dev, /proc, and /tmp itself) instead of the actual contents of the /tmp directory.
Expected Behavior
ls /tmp should show the files and directories contained within /tmp, not the global filesystem mount points.
Actual Behavior
$ ls /tmp
/dev
/proc
/tmpThe listing shows mount points that belong at the root level, not the contents of /tmp.
Root Cause
The issue is in the VFS layer's vfs_list() function. The "mountpoint injection" step runs for any filesystem root (when relative == "/"), not just the global root.
When you list /tmp:
- The code resolves to the tmpfs root (which is
/relative to that filesystem) - The mount iteration loop replays every mount including the one being listed
- Result:
/tmpshows all mount points instead of its own contents
Technical Analysis
The mountpoint injection logic in vfs_list() should:
- Only append mount points when listing the global root (
/) - Skip mount points when listing subdirectory roots of mounted filesystems
Current behavior:
// Simplified pseudocode
if (relative == "/") {
// This runs for ANY filesystem root, not just global root!
for (mount in all_mounts) {
append_mount_to_results(mount);
}
}Proposed Fix
Tighten the mountpoint injection logic with one of these approaches:
Option 1: Check if path is global root
// Only inject mounts when listing the actual global root
if (strcmp(resolved_path, "/") == 0 && relative == "/") {
for (mount in all_mounts) {
append_mount_to_results(mount);
}
}Option 2: Skip current mount
if (relative == "/") {
for (mount in all_mounts) {
// Skip the mount we're currently listing
if (strcmp(mount->path, current_listing_path) == 0) {
continue;
}
append_mount_to_results(mount);
}
}Impact
- Severity: Medium - breaks basic filesystem navigation expectations
- User Experience: Confusing for users expecting standard Unix behavior
- Workaround: None - incorrect behavior on every tmpfs listing
- Affected: All mounted filesystems when listing their root directories
Files Affected
src/kernel/fs/vfs/vfs.c-vfs_list()function- Mountpoint injection logic
Reproduction
# This should show /tmp contents but shows mount points instead
$ ls /tmp
# Compare with expected behavior:
$ ls / # Should show mount points (correct)
$ ls /proc # Should show proc contents, not mount points (currently broken)
$ ls /dev # Should show dev contents, not mount points (currently broken)Testing Requirements
After fix:
-
ls /shows mount points:/dev,/proc,/tmp, etc. ✓ -
ls /tmpshows tmpfs contents only (no mount points) -
ls /procshows procfs contents only (no mount points) -
ls /devshows devfs contents only (no mount points) - Nested mounts work correctly
Priority
Medium - Functional bug affecting filesystem navigation, but workaround exists (use full paths or navigate into subdirectories).
Related Issues
- Implement VFS (Virtual File System) layer #65 - VFS layer implementation
- Implement tmpfs/ramfs in-memory filesystem for /tmp #151 - tmpfs validation (may have revealed this issue)