On 18/11/2026 15:30, Martin Mirchev wrote:
Hi,
Source: coreutils master 75e1b68 (2026-11-18); elide_tail_lines_seekable()
is unchanged since at least 35492ca.
These commits have nothing to do with the issue,
so it's best not to mention arbitrary commits.
elide_tail_lines_seekable() in src/head.c reads each block with a single
read() and treats the result as the whole block. POSIX allows read() to
return fewer bytes than requested even when more data follows, and this
happens for instance on FUSE files opened with direct I/O. In that case the
missing part of the block is never output, and head exits 0 without a
diagnostic.
To reproduce, I used a FUSE file of 300000 bytes opened with
FOPEN_DIRECT_IO, whose server answers only the first READ request (head's
backward scan at offset 294912, 5088 bytes) with 2544 bytes. "head -n -0"
on that file then prints 297456 bytes instead of 300000, with exit status
0. With full reads, all 300000 bytes are printed.
The attached patch uses full_read() for both reads in that function, as
head already does in its other code paths. With it, the same file is
printed in full, and the head tests pass (7/7). I didn't add a test, as it
needs a filesystem that returns short reads; I can share the FUSE server
script I used if that helps.
Found by an LLM-assisted tool, verified manually.
This does look correct.
I'll see if I can add a short read regression test.
thanks,
Padraig