From patchwork Thu Nov 26 02:38:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 1406387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ChMQ264cvz9sTv for ; Thu, 26 Nov 2020 13:38:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=QqljHa/A; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4ChMQ254rvzDqvn for ; Thu, 26 Nov 2020 13:38:34 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=QqljHa/A; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4ChMPx74mKzDqvR for ; Thu, 26 Nov 2020 13:38:26 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id n137so300337pfd.3 for ; Wed, 25 Nov 2020 18:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cS7gHavXvnEjtxB6xMzAu7KhDz5WcCfIZChFy+sT9CQ=; b=QqljHa/AG3f/xJqds60V9mU+MI6XZ/zfs+K69aw6sdGPVZKzeyDPwjJimLnv4EiuhX BXQm7DRghveMgcH4WNZTxRZAo8p3+TTWn8rCw0i8Wn8sdB1ZoJ82lYjHnNspV0IjKwt6 5IS/ndkIjdhgSgi+weR0oZ2g1Esobg2IAIL4VGrf4ZlfQZLQ/qd71aSUMcobjjZnfIdC D3glievMRjbU7ipvkJWY9d+G2VLSO29gB7cO1FhbS3Q054tqRIoJ8AS6/lRxkS+pUWnB GSmpWCOo/rg1A/Ff6Dn4EtRG1FkFKbX+Ln+Vy2OJIvTJDvCOP6c8kK0aPD2VdKDyj4VA CAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cS7gHavXvnEjtxB6xMzAu7KhDz5WcCfIZChFy+sT9CQ=; b=Ovycp+DkKVaUkEMN2dFEIAgyVLkeUyXiQQKbNG26N57Mt0lh368fsbizLi+MCm2B7F hAg4CTf4CiMLcIWj1Ecoeg4mD5xGZ7APvnKeRXoCOnOcarvVl+CuMyvJoVPKOQpaI5X4 9Lf+ypGpa67r3T2fOjQ/F8lWz4YaBmCbWPw+q+j4dpNvwkQnqDRs7BxNqhyza7eDY8v4 lNvOLA4oHTywXV1EfH6EHVMhsbt6jbnOxM6Mg1Myh++CLMLToHf+PudpDUFItMnQAA1H jZctw+LM6HWExSHLDBDgrVcoBGLl2ROX1PT/lv68RKWuQQHZmhUUBtjLpHnC2esy1gWV v+xg== X-Gm-Message-State: AOAM532XwOitI8WVw4fi1APaim+OBMJx2qfyxkUcMlfoSxwVilSvrwUG QK8V91ntl8NeD3Ciyn6Nof6uWIAfVrW44A== X-Google-Smtp-Source: ABdhPJww1f8fapw4hhweK+jgIinCKizpBsAjw/DstDgWicWXMFzrxWiyHEsZbD4FRAYhZl5kdLoFDQ== X-Received: by 2002:a63:4d5c:: with SMTP id n28mr785438pgl.88.1606358303059; Wed, 25 Nov 2020 18:38:23 -0800 (PST) Received: from rashmica.home.majoof.com (150.24.220.111.sta.wbroadband.net.au. [111.220.24.150]) by smtp.gmail.com with ESMTPSA id 143sm3108845pfc.119.2020.11.25.18.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:38:22 -0800 (PST) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Thu, 26 Nov 2020 13:38:14 +1100 Message-Id: <20201126023814.1322133-1-rashmica.g@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Pdbg] [PATCH] Revert "htm: Use splice() to copy dump" X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This reverts commit 436eb8c74fb4a762b61837ee27ddbd6b5fe21334. Unable to use splice on newer kernels due to 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops"). So revert back to plain old read/write. Signed-off-by: Rashmica Gupta --- libpdbg/htm.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 0d755dd..43cef84 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -966,39 +966,41 @@ static int do_htm_status(struct htm *htm) return 1; } +#define COPY_BUF_SIZE getpagesize() static int copy_file(int output, int input, uint64_t size) { + char *buf; size_t r; - int pipefd[2]; - int rc = -1; - if (pipe(pipefd)) { - perror("pipe"); - exit(1); + buf = malloc(COPY_BUF_SIZE); + if (!buf) { + PR_ERROR("Can't malloc buffer\n"); + return -1; } while (size) { - r = splice(input, 0, pipefd[1], 0, size, 0); + r = read(input, buf, MIN(COPY_BUF_SIZE, size)); if (r == -1) { PR_ERROR("Failed to read\n"); goto out; } if (r == 0) { - PR_ERROR("Unexpect EOF\n"); + PR_ERROR("EOF\n"); goto out; } - if (splice(pipefd[0], 0, output, 0, r, 0) != r) { + if (write(output, buf, r) != r) { PR_ERROR("Short write!\n"); goto out; } size -= r; } - rc = 0; + + return 0; + out: - close(pipefd[1]); - close(pipefd[0]); - return rc; + free(buf); + return -1; }