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: 944932 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MdkcMTeW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41VJNG191rz9s0n for ; Tue, 17 Jul 2018 21:44:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D59F1C21E0B; 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-Google-Smtp-Source: AAOMgpfMJ8/ls8f4Yhi1GvV2Z5oUFnjWW1TFRL0RAsv7fWfLkZdBTVYvLfQC21oMC9hvnBFYGMO7aw== 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;