From patchwork Thu Aug 30 21:26:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 29140 Received: (qmail 15990 invoked by alias); 30 Aug 2018 21:26:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15794 invoked by uid 89); 30 Aug 2018 21:26:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f48.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=pyNXOSzKyB6h0HBCNoCMpcw/4tskKtoGadsaCV3zszQ=; b=AFLWl8jL04GrjjxSIVEaQmH6x2Dr5c74usJ0YkrhTG43Yl/pmxHFVlic8Bcz0FruQX VJxErkOMnyyyvpAyHGBoj36Fz7FXRygK5JvYVGpv9ll+FlZGtxtAectZjKp26hsE280b sQkRTCGft4IWXUZW7DgsfHtpou2XjBENJNM2XeV+RKyeOm5VKt1NWAuUVcezv4AtgOAU GCxPt3W7slyw+7McWzJcW7tv6ak1ALcbQzg9b2JKN5Yf66k2+HvkO++exvcBIR0izEF4 WhkwrhJNsj1A5smtC0qxeFHrcvGWoX8Pac58W/MUhpypAT5qPcWmTZqWMc3uBzTlFM+9 fjiA== MIME-Version: 1.0 From: "H.J. Lu" Date: Thu, 30 Aug 2018 14:26:49 -0700 Message-ID: Subject: [PATCH] test-container: Use copy_file_range_compat for cross-device copy [BZ #23597] To: DJ Delorie Cc: GNU C Library On Thu, Aug 30, 2018 at 12:10 PM, DJ Delorie wrote: > > Ah, thanks for figuring that out. I'll add a fallback unless someone > else feels like doing it before I do ;-) Something like this? From c6b06cc42ed58d6c8f9cdd7e21e89214ce7b2a18 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 30 Aug 2018 14:21:14 -0700 Subject: [PATCH] test-container: Use copy_file_range_compat for cross-device copy [BZ #23597] copy_file_range can't be used to copy a file from glibc source directory to glibc build directory since they may be on different filesystems. This uses copy_file_range_compat for cross-device copy. [BZ #23597] * io/copy_file_range-compat.c (COPY_FILE_RANGE): Allow cross-device copies for test-container.c. * support/test-container.c (COPY_FILE_RANGE_DECL): New. (COPY_FILE_RANGE): Likewise. (__libc_lseek64): Likewise. Include . (copy_one_file): Call copy_file_range_compat for cross-device copy. --- io/copy_file_range-compat.c | 3 +++ support/test-container.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/io/copy_file_range-compat.c b/io/copy_file_range-compat.c index 4ab22cad19..15860a7480 100644 --- a/io/copy_file_range-compat.c +++ b/io/copy_file_range-compat.c @@ -59,12 +59,15 @@ COPY_FILE_RANGE (int infd, __off64_t *pinoff, __set_errno (EINVAL); return -1; } +#ifndef SUPPORT_TEST_DRIVER_H + /* Allow cross-device copies for test-container.c. */ if (instat.st_dev != outstat.st_dev) { /* Cross-device copies are not supported. */ __set_errno (EXDEV); return -1; } +#endif } /* The output descriptor must not have O_APPEND set. */ diff --git a/support/test-container.c b/support/test-container.c index 2e91bdf9ec..ee99af2d55 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -47,6 +47,12 @@ #include "check.h" #include "test-driver.h" +/* Compile a local version of copy_file_range. */ +#define COPY_FILE_RANGE_DECL static +#define COPY_FILE_RANGE copy_file_range_compat +#define __libc_lseek64 lseek64 +#include + #ifndef __linux__ #define mount(s,t,fs,f,d) no_mount() int no_mount (void) @@ -383,7 +389,8 @@ copy_one_file (const char *sname, const char *dname) if (dfd < 0) FAIL_EXIT1 ("unable to open %s for writing\n", dname); - if (copy_file_range (sfd, 0, dfd, 0, st.st_size, 0) != st.st_size) + /* Use copy_file_range_compat for cross-device copy. */ + if (copy_file_range_compat (sfd, 0, dfd, 0, st.st_size, 0) != st.st_size) FAIL_EXIT1 ("cannot copy file %s to %s\n", sname, dname); xclose (sfd); -- 2.17.1