Skip to content

ls: don't show . and .. on orphaned directories - #13924

Open
zveihander wants to merge 2 commits into
uutils:mainfrom
zveihander:ls-orphan-directory-dots
Open

ls: don't show . and .. on orphaned directories#13924
zveihander wants to merge 2 commits into
uutils:mainfrom
zveihander:ls-orphan-directory-dots

Conversation

@zveihander

Copy link
Copy Markdown

Fixes #12968

When a directory is deleted and replaced by another file system object while a process still has it open as its working directory, runing ls with the -a flag from the orphaned directory still shows . and ... the GNU ls does not show anything in this case.

The dots were being added unconditionally whenever -a was used, without checking whether the directory is still in the filesystem tree.

It now checks whether the directory is still reachable from the parent by comparing inode and device against the parent's stats before it adds the dots.

@sylvestre

Copy link
Copy Markdown
Contributor

please add a test to make sure we don't regress, thanks

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 148.97 MB (-132 KB, -0.09%)

Significant per-binary changes:
  [           1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  test        1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  install     1.25 MB ->    1.32 MB  (+72 KB, +5.62%)
  mkdir       1.10 MB ->    1.17 MB  (+72 KB, +6.38%)
  mkfifo      1.09 MB ->    1.16 MB  (+72 KB, +6.45%)
  mknod       1.10 MB ->    1.17 MB  (+72 KB, +6.41%)
  chmod       1.15 MB ->    1.22 MB  (+68 KB, +5.76%)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout-group (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cat/splice is no longer failing!
Congrats! The gnu test tests/cut/mb-non-utf8 is no longer failing!
Congrats! The gnu test tests/ls/stat-free-symlinks is no longer failing!
Congrats! The gnu test tests/mv/dir2dir is no longer failing!
Congrats! The gnu test tests/mv/mv-exchange is no longer failing!
Congrats! The gnu test tests/nl/multibyte is no longer failing!
Congrats! The gnu test tests/od/od-j is no longer failing!
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Congrats! The gnu test tests/dd/no-allocate is now passing!
Note: The gnu test tests/misc/write-errors was skipped on 'main' but is now failing.

@codspeed-hq

codspeed-hq Bot commented Aug 14, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 53.8%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 4 regressed benchmarks
✅ 348 untouched benchmarks
⏩ 50 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ls_recursive_long_all_wide_tree[(15000, 1500)] 231.4 ms 7,723.9 ms -97%
Simulation ls_recursive_long_all_balanced_tree[(6, 4, 15)] 284.4 ms 335.2 ms -15.16%
Simulation ls_recursive_long_all_mixed_tree 5.6 ms 6.5 ms -13.82%
Simulation ls_recursive_long_all_deep_tree[(100, 4)] 6.3 ms 6.8 ms -7.43%
Simulation complex_relative_date 330.6 µs 318.6 µs +3.77%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing zveihander:ls-orphan-directory-dots (c2e3bc7) with main (a56bff2)

Open in CodSpeed

Footnotes

  1. 50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ls): when the current cwd swapped to a /dev/null copy file it returns . and .. even must not

2 participants