ls: prevent ReadDir from closing before entries are processed
The issue occurred because ReadDir was being consumed by the for loop,
causing it to be dropped immediately after iteration. This closed the
directory file descriptor (FD 3) before metadata() could be called on
the entries, since /proc/self/fd shows the process's own open FDs.
By using read_dir.by_ref() in the loop, we borrow the iterator instead
of consuming it, keeping the ReadDir (and its underlying FD) alive until
enter_directory() completes.
Fixes: #9332