public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: George Hu <integral@archlinux.org>
To: Chris Torek <chris.torek@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] copy.c: use `sendfile()` for in-kernel file copying on Linux
Date: Sat, 14 Feb 2026 17:21:59 +0800	[thread overview]
Message-ID: <e2a5c920-7f15-4ea8-9390-cf42ac33082d@archlinux.org> (raw)
In-Reply-To: <CAPx1GvfsnZiUkkXJSAtt4HECT6f+zb1+vtiT+UikcAq0WuFR8Q@mail.gmail.com>

On 2/13/26 11:36 PM, Chris Torek wrote:

> 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

  reply	other threads:[~2026-02-14  9:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13 12:46 [PATCH] copy.c: use `sendfile()` for in-kernel file copying on Linux George Hu
2026-02-13 15:36 ` Chris Torek
2026-02-14  9:21   ` George Hu [this message]
2026-02-14 16:50     ` Chris Torek
2026-02-20 16:35       ` Ed Maste
2026-02-20 16:48         ` Collin Funk
2026-02-14 16:43 ` Phillip Wood
2026-02-15  6:23   ` George Hu
2026-02-15  7:43 ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2a5c920-7f15-4ea8-9390-cf42ac33082d@archlinux.org \
    --to=integral@archlinux.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox