From patchwork Fri Sep 13 13:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11144755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3DA917E6 for ; Fri, 13 Sep 2019 13:02:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2C8D2084F for ; Fri, 13 Sep 2019 13:02:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HE8xia3O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388205AbfIMNC5 (ORCPT ); Fri, 13 Sep 2019 09:02:57 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:43933 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388196AbfIMNC4 (ORCPT ); Fri, 13 Sep 2019 09:02:56 -0400 Received: by mail-ed1-f68.google.com with SMTP id c19so26921650edy.10 for ; Fri, 13 Sep 2019 06:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=feuJkzJI/SWfV7q4mtYOBaQBB5fBDWpeiqXQ3Lw+ILY=; b=HE8xia3O13wOYxUZ9JcjjJX4GdGkg0SFvzSielw3m0z4XbqpKFxlYX7wDB2/sTuh2P 20hVR5N5A2rZwRkouSDKjZmYMK9d6SbeFvJhNYvOrAnAgGPS7Shi/MXymNl3PqzSLewv MMucDrAbTngey2oQBeC2sm4KlpP32XGqRpmOgZ+4T13y+W4mO24FTjGipZiOJRzUFsBB 6WFpOQY7K22jC8a4okmz3brGml/UDmL/3eK51WOlDg4v81XTSuR7/YiD6NDbNElzBhHY MjO/ah0vRHc1mzFzP7mndTifpiU/tAUZ10yGfEZUNtiAExznjEJ1Sz6zEeIwyJHzXWFj Zyiw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=feuJkzJI/SWfV7q4mtYOBaQBB5fBDWpeiqXQ3Lw+ILY=; b=WlpR0Cmzahk95nole7IBESQV5M2Bq1Nm84Gh+X34+PIJRY9Yaw/QkViU4UOfU0FIhy 6MwfNnnTQsBP/WCCXrsZ7QJADjvp9380LwP0/m+DOIEv8fDgDyPshIylyBHl+mcX2/ST B6WRYiTkjeXXACo6oxd3hIE+BWd2siy2HSCRYXoXNWuJ5qr8Wtg+rB8IwlfQ2J0D5o7S AIfjcK68aWcpcRzYIbPRK+hUshVLuJO76jgySrBl4bh1fHpKsWydCj9LMiTvkVWiy/6s vRFcK0tzUvsFdyv6UNvyJfrJij9xbI/z3uetu+zNIuSdKdo1XsSgF1BTcmlHHcYiDpBf 8qoQ== X-Gm-Message-State: APjAAAWYtU5KoYSDR7A7SsOeLEW47oo6sK7+4GXLFxcgWUJb4Rrr+Pcq Y2L3N+M8XkPs/oF/uYOQcr3HpLgj X-Google-Smtp-Source: APXvYqzqT5yrIV/zzlA42J9tsaW9je/oRwi9maOjoMX6sWsdQIBoB+z7KeHzkImuO8BP3u8QZfK25Q== X-Received: by 2002:a50:9734:: with SMTP id c49mr48057458edb.93.1568379774506; Fri, 13 Sep 2019 06:02:54 -0700 (PDT) Received: from ubuntu-N150ZU.booking.pcln.com (access-114.38.rev.fr.colt.net. [213.41.38.114]) by smtp.gmail.com with ESMTPSA id c14sm2846570ejx.31.2019.09.13.06.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 06:02:53 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Christian Couder , Ramsay Jones Subject: [RFC PATCH 07/10] csum-file: introduce hashfile_total() Date: Fri, 13 Sep 2019 15:02:23 +0200 Message-Id: <20190913130226.7449-8-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.23.0.46.gd213b4aca1.dirty In-Reply-To: <20190913130226.7449-1-chriscool@tuxfamily.org> References: <20190913130226.7449-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King We will need this helper function in a following patch to give us total number of bytes fed to the hashfile so far. Signed-off-by: Jeff King Signed-off-by: Christian Couder --- csum-file.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/csum-file.h b/csum-file.h index a98b1eee53..f9cbd317fb 100644 --- a/csum-file.h +++ b/csum-file.h @@ -42,6 +42,15 @@ void hashflush(struct hashfile *f); void crc32_begin(struct hashfile *); uint32_t crc32_end(struct hashfile *); +/* + * Returns the total number of bytes fed to the hashfile so far (including ones + * that have not been written out to the descriptor yet). + */ +static inline off_t hashfile_total(struct hashfile *f) +{ + return f->total + f->offset; +} + static inline void hashwrite_u8(struct hashfile *f, uint8_t data) { hashwrite(f, &data, sizeof(data));