* ls: restore WASI ".." metadata fallback in collect_directory_entries
The ls refactor in #9851 dropped the WASI guard added in #11633, so
`ls -al` at a preopened root once again fails with "Capabilities
insufficient" when stat'ing "..". Extract the logic into a small
`dotdot_path` helper and add a regression test covering `ls -al`.
* Update spell-checker ignore words in test_ls.rs
* refactor uu_ls so that crate users can call the command without having
the internal print stdout output
* redo changes
* clippy
* help cspell understand dired
* rebase
* try and optimize for memory and speed performance.
update output handling to add streaming mode.
* work on ci issues, optimize uid and gid cache handling, improve dired output calculations
* test fx: change read_dir parameter to mutable reference in collect_directory_entries and enter_directory functions
* update documentation
* more perf tweaks
* fmt
* tweak perf
* Add back (and shorten) comment for 31_556_952
* Update src/uu/ls/src/ls.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/ls/src/ls.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
The `+1` accounting for the ACL/context indicator was applied once per
item inside the padding loop, so N files with ACLs inflated the
link-count column width by N. Apply it a single time after the loop.
Fixes#10980
* ls: fall back to "." metadata for ".." on WASI
On WASI the sandbox blocks access to the parent directory at the
preopened root, causing ls -a to show an error and display ".."
with question marks. Fall back to the current directory metadata
so the entry appears with valid information.
* refactor: simplify DisplayItemName struct and improve dired position handling
This commit refactors the `display_item_name` function to return a `DisplayItemName` struct containing both the displayed name and its dired length, rather than just the OsString. This change simplifies the code by:
1. Eliminating the need to call `dired_name_len()` separately after getting the displayed name
2. Reducing redundant length calculations in the dired position handling
3. Making the code more maintainable by encapsulating related data together
The change also fixes an issue where dired positions were being calculated incorrectly for symlink names that required quoting, ensuring proper highlighting in dired mode.
Closes: #10248
Colors: make StyleManager rely on lscolors’ explicit-style
flags, avoid unnecessary metadata/stat probes, and ensure
ln=target, or=, mi= honor GNU coloring semantics.
Tests: update test_ls_color_norm expectations so the fi=
and fi=0 cases now match GNU ls output, ensuring the new
color handling is verified.
Add seven ls tests mirroring GNU tests/ls/ls-misc.pl
sl-dangle3..9 to validate combinations of `ln=`, `or=` and `mi=`
settings. The tests verify both file-level output and directory
listings, including the `\x1b[m` reset requirement when `or=:` is
set.
Adjust existing Rust tests to GNU output.
Existing color tests were updated to match GNU output.
This includes the following fixes:
- style_for_indicator uses fallbacks in case ca= is not defined in
LS_COLORS. This led to the normal file style being used, even if there
was a more specific one. The fix is to use has_color_for instead.
There is also a new test for that case (a specific style for .txt).
- has_acl always returns true on a system with SELinux, as each file has
an acl named "security.selinux".
This adds a more specific method has_security_cap_acl that checks for an
acl named "security.capability". This matches the behavior of GNU's ls.
These problems already existed when capability coloring was added in
9a97c18877.