AW: Why doesn't "cat a b > foo" work?

Grant Edwards grant.b.edwards at gmail.com
Wed Jan 20 16:15:38 UTC 2021


On 2021-01-20, Walter Harms <wharms at bfs.de> wrote:

> can you give a hint what kernel version is problematic?

NB: prior to 2.6.33, sendfile() could only be used with a socket as
the destination.

I'm seeing the failure with 2.6.33.7

In 2.6.33.7, when used with a normal file as the output, it always
writes the data to offset 0 in the file.

That's fine if you only call it once and then close the output
fd. However, if you call it multiple times (as busybox 'cat' does when
copying multiple files), then you don't get the expected result. The
contents of the input files are not concatenated. Instead the contents
of each input file overwites the existing contents of the output file
starting at offset 0.

I do not know when that was fixed in the Linux kernel.

--
Grant



More information about the busybox mailing list