From patchwork Fri Aug 10 13:59:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 956257 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="MrX1FdDh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41n6Fk392yz9s4Z for ; Sat, 11 Aug 2018 00:00:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F082CC21DFB; Fri, 10 Aug 2018 14:00:07 +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 D7349C21C29; Fri, 10 Aug 2018 14:00:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 17CB1C21C29; Fri, 10 Aug 2018 14:00:03 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 0658AC21C27 for ; Fri, 10 Aug 2018 14:00:02 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id w24-v6so2030915wmc.1 for ; Fri, 10 Aug 2018 07:00:02 -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=usZSOyQHi+3FezXpmqap43aB584tZOgkSdZ3605q6Zg=; b=MrX1FdDhI0QjPEzRjy1ffKmEWjv9SMq+To5eNQ7dP0u6e8Wj7YZw8G+gfjT/YlIeLk aelUdKTBNSDkJO67AJgI9IT2B6STcHmdWEH9c9SjejuYt3h5Hv0YA7CJviLgZ9LX1QQ/ fNTkgaV6eVAP8F/NF+z7qA6acno1LUtvYqxi4= 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=usZSOyQHi+3FezXpmqap43aB584tZOgkSdZ3605q6Zg=; b=IXX3ucXRdP+bYWmQLO4zlPgRwkWyU9HScBxEfFCZTs2FWFWwKjbcnOJGQusF1InKMh nAabh9Y3iRWKEsWo9Zd7sLlqeZuApNgtD+bAjtsJABf0i8e9ME9niKJjbLirwCgoHT5R JUK/0pZOh6ruoTnHaKH4Tz9/NaDrNLsh1GfoUl33N2r6CK3pdEsgryn8gUYnSoxV5Gzd ibZlGvVSc1+2lSuxAwcVljXsMPACfbYb2qBHYbsX5Nw8eP6MhuvnZ/JKaUjPuZb5R5xO la/9snefyYG+lMvZBMDJ0pU3t28QCQXpBteoMyOgPfh3Szsxd8t3KbiEHVAkQAXsv1EU phxg== X-Gm-Message-State: AOUpUlFdjO2YHyb/WfvOw0xqI6kcyOIgFCLr5HshOgqJoqhohBtNUoel ua1jcQF3YOovSf1ZTJSTVByxK8IhITY4Wg== X-Google-Smtp-Source: AA+uWPzWipzXDk7DcE4A9lupgUmijvA9nr6ulgA1ny5bh7czLQBbDNrhFobcNoNppO5L1rhdzLwnuw== X-Received: by 2002:a1c:3e8f:: with SMTP id l137-v6mr1596215wma.132.1533909601216; Fri, 10 Aug 2018 07:00:01 -0700 (PDT) Received: from localhost (host-176-38-103-11.la.net.ua. [176.38.103.11]) by smtp.gmail.com with ESMTPSA id m13-v6sm9787555wru.93.2018.08.10.07.00.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 07:00:00 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Fri, 10 Aug 2018 16:59:59 +0300 Message-Id: <1533909599-26263-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 v3 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/+/android-p-preview-5 Signed-off-by: Igor Opaniuk Acked-by: Andrew F. Davis Reviewed-by: Sam Protsenko --- Changes for v3: - reword commit message, added avblib repository link, that stick to specific tag - fix get_size_of_partition() function description. Changes for v2: - change 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 20e35ad..82ddebc 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -700,6 +700,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_INSUFFICIENT_SPACE, 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 * ============================================================================ @@ -722,7 +753,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;