From patchwork Tue Jul 17 11:44:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 142135 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3549222ljj; Tue, 17 Jul 2018 04:44:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfQPAMh8oBwb7Vza1m4MvkiqV44XPCzDt2ZkA+Ttwn/uYms/wyJp13+rUh6IGhu/W9NImh/ X-Received: by 2002:aa7:c641:: with SMTP id z1-v6mr2219309edr.9.1531827866566; Tue, 17 Jul 2018 04:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531827866; cv=none; d=google.com; s=arc-20160816; b=sHV21OBuO9l3is8wbCdRbIw1WHIW31+N4H/Q5Y0k0UDk+nnnHtSlWdk6WG2sz7DQcC xYv+gvu715rmu4Px6ZczC4+Ny8yGvsR02MlwFRNc33EUAdocs9PDvKb8858FZioA/Gyi YizGKXOfqR+8xFH8zXietIgOc7F+aacpMAH9riDFrWCYQkXDT69s/ZsLSYOE2QsJUJZv Or07J8z0RurmPWS0GqrMrP29mmFSOMKMs+N9xIPlGikQTf0PnbB8ZE5rN53whwkV4Ir5 XnmBK4SwgBo5nXWSGp5Oe0z4iqqAP+WqFDS6asFXfgvvt1pC3vV99e8HfIbxxygXHxcK I7Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=EVZD+CvcCkc1r06sTKv5qDeo5fBwoAzchq0O16DRO64=; b=py7/43tnOW6BF2S4aNIzzEHY4oh9CmCMLLplISlF0E0vZc2RBp2gLyjylNg+HOz4zP yDsHcDPcT8XfdFo9jQzLti774TQgEQyQ+TjI6DB7T4x8oykofJvmpMlaqD+oor4FAiza OHiR2FvRLrI1lw66iWrlyWHt2MHhOCn8o55tHKGVYZu5jDGZl51H9Iqj9/hFs0vjZd5B G40OzUHWi80pxy4mGGUZ5vh0akm5JjC9F5ucXDtA8dfIdbZ1eD6Ra3VrztsMYAbnKpep PXi/4N33cZKPkO4bHui0oKILkdwkWOB3LDu7NtvvJZ2kDPpro7lhzITV9QxDMXgqGlqA fXMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MdkcMTeW; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id c18-v6si52437eds.3.2018.07.17.04.44.26; Tue, 17 Jul 2018 04:44:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MdkcMTeW; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 1CC63C21E0B; Tue, 17 Jul 2018 11:44:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5F12AC21C3F; Tue, 17 Jul 2018 11:44:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 876E8C21C3F; Tue, 17 Jul 2018 11:44:20 +0000 (UTC) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by lists.denx.de (Postfix) with ESMTPS id 1BE8CC21C27 for ; Tue, 17 Jul 2018 11:44:20 +0000 (UTC) Received: by mail-lf0-f65.google.com with SMTP id m13-v6so592630lfb.12 for ; Tue, 17 Jul 2018 04:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=PGHvM9zKo7zaYWhgzNxybKYURlTj+Jd0/YScShhERVU=; b=MdkcMTeW83co2vQ9dXlESZGnQdW3w+E4kk5u3Z0FxVXQ/AYu26hvV4KNT4O/juG4NG Y96c2but7xIyhOCA/9m8qQ+idRoYLR4cb+Kehr/saK72dC5MaoM56iz120FCqHofl4L5 og4EnkZ9zHm2uOioA1ZImjA3dLRLYZotuubEI= 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; bh=PGHvM9zKo7zaYWhgzNxybKYURlTj+Jd0/YScShhERVU=; b=VDW1yLJpiezrfkALumxNSE2C7LKi7RUJmIyhdkU38itngpzc867+GEuJwnkd9iT706 I8Hs0mjV18nXtV/9V4k3G28jd63x4Y7a411l7fXAUMyY/V9B+/DyWQrwd/dWWVBK0lFo DVftO4pIachwCk9gzv/dQ/xCAC2cxeJpSWMZa1qEGHuAD7vHjaUsLQnnrZuGcGszy6fw AUeoA4MDag7f2tc5UwWYyfyGiHITvRIorMAoDiyR/6+gSuHK8sCFLYbugCD/f1T1YGFd X2RCwCcsVIpWBYJL7dJ1p6BbpopmtJdGQPv4zEQ/Fs/p1m58zRXBqc0tbjJ5kgelsvmG 2mpA== X-Gm-Message-State: AOUpUlHz4VJ6VhcAWRK5AOv9QUkVkdxdARltlXpMUemOUCX/QxpBzfH4 echQnPnq6++EfM7Z05M4hYCsSln0xAfvzA== X-Received: by 2002:a19:1190:: with SMTP id 16-v6mr1108133lfr.122.1531827859233; Tue, 17 Jul 2018 04:44:19 -0700 (PDT) Received: from localhost (host-176-36-145-117.la.net.ua. [176.36.145.117]) by smtp.gmail.com with ESMTPSA id v136-v6sm127935lfa.10.2018.07.17.04.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 04:44:18 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Tue, 17 Jul 2018 14:44:17 +0300 Message-Id: <1531827857-21243-1-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: trini@konsulko.com, praneeth@ti.com, misael.lopez@ti.com, erosca@de.adit-jv.com, joakim.bech@linaro.org Subject: [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Implement get_size_of_partition() operation, which is required by the latest upstream libavb [1]. [1] https://android.googlesource.com/platform/external/avb/+/master/README.md Signed-off-by: Igor Opaniuk Acked-by: Andrew F. Davis --- Changes for v2: - changed the return code for the case when out_size_num_bytes is NULL (s/AVB_IO_RESULT_ERROR_IO/AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE/g) common/avb_verify.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/common/avb_verify.c b/common/avb_verify.c index f9a00f8..ab5f9aa 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -699,6 +699,37 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps *ops, } /** + * get_size_of_partition() - gets the size of a partition identified + * by a string name + * + * @ops: contains AVB ops handlers + * @partition: partition name (NUL-terminated UTF-8 string) + * @out_size_num_bytes: returns the value of a partition size + * + * @return: + * AVB_IO_RESULT_OK, on success (GUID found) + * AVB_IO_RESULT_ERROR_IO, out_size_num_bytes is NULL + * AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION, if partition was not found + */ +static AvbIOResult get_size_of_partition(AvbOps *ops, + const char *partition, + u64 *out_size_num_bytes) +{ + struct mmc_part *part; + + if (!out_size_num_bytes) + return AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE; + + part = get_partition(ops, partition); + if (!part) + return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION; + + *out_size_num_bytes = part->info.blksz * part->info.size; + + return AVB_IO_RESULT_OK; +} + +/** * ============================================================================ * AVB2.0 AvbOps alloc/initialisation/free * ============================================================================ @@ -721,7 +752,7 @@ AvbOps *avb_ops_alloc(int boot_device) ops_data->ops.read_is_device_unlocked = read_is_device_unlocked; ops_data->ops.get_unique_guid_for_partition = get_unique_guid_for_partition; - + ops_data->ops.get_size_of_partition = get_size_of_partition; ops_data->mmc_dev = boot_device; return &ops_data->ops;