From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14581 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?q?=C3=81rni=20Dagur?= Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] Add copy_file_range system call Date: Mon, 19 Aug 2019 23:41:14 +0000 Message-ID: <20190819234114.19848-1-arni@dagur.eu> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="244474"; mail-complaints-to="usenet@blaine.gmane.org" Cc: =?UTF-8?q?=C3=81rni=20Dagur?= To: musl@lists.openwall.com Original-X-From: musl-return-14597-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 20 01:47:55 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hzrNR-0011Qe-Kc for gllmg-musl@m.gmane.org; Tue, 20 Aug 2019 01:47:54 +0200 Original-Received: (qmail 31757 invoked by uid 550); 19 Aug 2019 23:47:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 26619 invoked from network); 19 Aug 2019 23:41:07 -0000 Authentication-Results: out.migadu.com; auth=pass (plain) X-Mailer: git-send-email 2.23.0 DKIM-Signature: v=1;a=rsa-sha256;bh=N2H0bGHqgNIVQORO+kYXVC08wpQpRNi3l0MlZ7YXb60=;c=relaxed/simple;d=dagur.eu;h=from:subject:date:to;s=default;b=Rs9RgdB0pR/H8qlkCTdOFoBSNN9EF/Mjxr1wYD1deDLNnGZ+3LZnkQ3mLlY54PB4WONjLekh+SiC5suwiu8L6TZhhXnHaGCWFiS3EFofDiE1/StNlgF7cV/xt9VV2qMINA4jlBFFGds3pmgAI8hcYZks0IiEDBrNTLmjgoEguh4= Xref: news.gmane.org gmane.linux.lib.musl.general:14581 Archived-At: This patch was based on commit 53147f9, which added splice and vmsplice. --- The function signature in the glibc manpage specifies `loff_t` instead of `off_t`, for both `copy_file_range` and `splice`. In musl, however, the function signature for `splice` specifies `off_t`, so I did the same here. I'm not an experienced C programmer, so that may have been wrong. include/unistd.h | 1 + src/linux/copy_file_range.c | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 src/linux/copy_file_range.c diff --git a/include/unistd.h b/include/unistd.h index 9485da7a..00cc7042 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -188,6 +188,7 @@ char *get_current_dir_name(void); int syncfs(int); int euidaccess(const char *, int); int eaccess(const char *, int); +ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) diff --git a/src/linux/copy_file_range.c b/src/linux/copy_file_range.c new file mode 100644 index 00000000..34742588 --- /dev/null +++ b/src/linux/copy_file_range.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags) +{ + return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags); +} -- 2.23.0