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: 143927 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3391186ljj; Fri, 10 Aug 2018 07:00:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyG8/PogfTcZcUi69ymDlRdszxU17x02StxbXV4PVzunX3zHsu/22SYyybB5iBycraFeZ+g X-Received: by 2002:a50:ad55:: with SMTP id z21-v6mr8549929edc.142.1533909611102; Fri, 10 Aug 2018 07:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533909611; cv=none; d=google.com; s=arc-20160816; b=TOdla14wjZaCtj2uMkRxkQdCpTxq0JhXNfe2nharVolPxWwjGvDUaRobBojQEKjES6 ULEft8TVwoHafw3gL/HIpTAGM+Svn7R1YwdkgrSaX1L2EKkN6nXMOSE0SHlQJxjEr8v5 dCzqircb7PUWX8ZwwO95rcT6vgEBv2qmty5M0Gm9chWEh9PBcqqiVAxoZxbzmrMM4JXC YB8eIXIiMOCxq68N3yP7WXzxqDDyyML96wgddPlxR5Pe0P/n5aTmdTPu+vFDA+E53D8s l7Df6RGllT8k2u1ezkkBFXl2t5zFZ6a++bPFd0VpMxorgqpW7ZpuJLTuDJYEi8wmVjMh HEIg== 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=dy+4JvB0SQHxlEJQnUJ2oJdoKCtrAC8PR3raCnd5h0w=; b=mxocBADc75PzWkDWuP32rfPrtMnIWdRM2DISmKOn96royVcLFs8vkeblEztVOwFape y7oCRQAngOqJCEMqdQjyEvTA1UA3AvP/2hA0w/DaUpbqLZruMYg1y7l8nYz4P/tGk6tp QViBvURBuTQuRH8J6ZXXptsUBmArwjaqT7V/6AMH/1vUXjtouqYp7QG3faEyNIZNT39M 3dnWMwaoC+/EjQRYMMU93IKqKQ67YsmuxW50V9MgUX2Kx/KMLVCPwe5thk8QTJDKaaYN h+u7BEuSCZUBcXsEOB4MuzMo8M5hJ+i9RVooRaJcoXu7p/EA+w2IIfome/oI1B6Q7sSQ NOFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MrX1FdDh; 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 e18-v6si1160863edb.332.2018.08.10.07.00.10; Fri, 10 Aug 2018 07:00:11 -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=MrX1FdDh; 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 90A16C21E16; 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-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;