linux_getdents64() rounds its native read size up to DEV_BSIZE before
converting entries. For an unaligned caller buffer, the native batch
can contain more entries than fit in the Linux buffer. Conversion then
returns EINVAL even after copying complete entries, and the native read
has already advanced the directory position.
For counts of at least DEV_BSIZE, round the native batch down instead.
A 768-byte request, such as rustix's initial directory read, now reads
512 native bytes rather than 1024. The converted Linux dirent64 records
are no larger than their native counterparts, so the whole translated
batch fits. Returning a short batch is allowed, and consuming the whole
native batch avoids needing to rewind the position or change the NFS
client.
Keep the existing sizing for counts below DEV_BSIZE. This fixes the
oversized-batch case, not the remaining small-buffer, copyout-failure,
or legacy getdents/readdir problems.
Fixes: 110f2567cb51 ("linux_file.c: Fix handling of NFS getdents() emulation")