git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] copy.c: use `sendfile()` for in-kernel file copying on Linux

From
George Hu <integral@archlinux.org>
Date
Feb 14, 2026, 09:21 UTC
Message-ID
<e2a5c920-7f15-4ea8-9390-cf42ac33082d@archlinux.org>
In-Reply-To
<CAPx1GvfsnZiUkkXJSAtt4HECT6f+zb1+vtiT+UikcAq0WuFR8Q@mail.gmail.com>
On 2/13/26 11:36 PM, Chris Torek wrote:
Show 24 quoted lines
> On Fri, Feb 13, 2026 at 4:47 AM George Hu <integral@archlinux.org> wrote:
>> The `sendfile()` system call copies data between one file descriptor
>> and another within the kernel, which is more efficient than the
>> combination of `read()` and `write()`.
> sendfile() is found on other systems (notably BSDs), so perhaps ...
>
>> Signed-off-by: George Hu <integral@archlinux.org>
>> ---
>>   copy.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/copy.c b/copy.c
>> index b668209b6c..d4b7cde764 100644
>> --- a/copy.c
>> +++ b/copy.c
>> @@ -7,8 +7,23 @@
>>   #include "strbuf.h"
>>   #include "abspath.h"
>>
>> +#ifdef __linux__
> ... this and the subsequent ifdef should be based on the feature,
> rather than the OS.
>
> Chris
Hello,

Although the `sendfile()` system call exists in both Linux and BSDs, their semantics and APIs differ. The Linux prototype of `sendfile()` is:

ssize_t sendfile(int out_fd, int in_fd, off_t *_Nullable offset, size_t count);

While FreeBSD exposes:

int sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr, off_t *sbytes, int flags);

George
Previous: Chris TorekNext: Chris Torek
Message 3 of 9 in “copy.c: use `sendfile()` for in-kernel file copying on Linux”
  1. copy.c: use `sendfile()` for in-kernel file copying on LinuxGeorge Hu, Feb 13, 2026
  2. Chris TorekFeb 13, 2026
  3. George HuFeb 14, 2026
  4. Chris TorekFeb 14, 2026
  5. Ed MasteFeb 20, 2026
  6. Collin FunkFeb 20, 2026
  7. Phillip WoodFeb 14, 2026
  8. George HuFeb 15, 2026
  9. Jeff KingFeb 15, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.