From patchwork Mon Jul 9 12:15:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 141396 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2595550ljj; Mon, 9 Jul 2018 05:16:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe6G6Q6j4Xa0FPe/jfJmcf7JEiP4x7MEjZ70JcTLbqitCA9PeJRua6iJoXg5YKuB8y8fjgY X-Received: by 2002:aa7:d68b:: with SMTP id d11-v6mr22033134edr.196.1531138562241; Mon, 09 Jul 2018 05:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531138562; cv=none; d=google.com; s=arc-20160816; b=UKa7OvP+GtRKDedvOY3STJ9gmW3Ps6MADr33DUJadRjimWD+wpIO4Pt6/sv6z/l5qV 6KvkBB/IcXkM4Mk18nG0pt6jSmBaCVXpvGpTqeMWQ3kWF0wBn7+4wu7lSEuONzI72ano 0LZ1iY0y+70xw413HSV4sZlZeWWdGDxF7ptObuT2Ytcsp3vQO6/wJAb/b8ZnU6r4cLcT ux+iW44x8vZEzCQLqEXK4TMfwO2v7k6RarqZMNE+HAP3QFNQJ3KtDRxFzbTJdRIxqvDb PdxGOPoA2FOrMT2bt4aLqKs+GIbnmTm9bG+GrMmJWM6n/FBbLJVa2H/z+KCPGwMni5Lv x1AA== 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=ZG83Q0AsdHa5ZQ4XVJKdws58IlLmx2uz+vfKID6RuvU=; b=UW6W/TrWL1MJ+ec0NrrBKTeZDt8i3JwU//TzUny3c2JIduzinskGO4yJYxz2UIUKGw AdCuWXU+vp7D/G4bTBXI0RX7wSs+svC/q1LIS3iyqcxMcTwdhZkgFAIcMHfkN4sKNW2q YzS8CI6aU7in3ib2oCYZ5/5qCkPkNDZY2sqHIfpW8k+MMSigqbLkhjBp/ZTWi4v5G+bz a6u8fMv3ZTvSy2xzl38AFGsbtiWQebEUmm5Co34quYLaGnQriuWHuyFic5kBofJ7o6fl +gs6Ae3gkSDoYxBZIcJZ3i5UFNTxOvU1ZqMNdwoDoX/Byt6yilKPiCCbg9z708KbthHp kLng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ujk3sFsq; 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 t17-v6si7345283eds.246.2018.07.09.05.16.02; Mon, 09 Jul 2018 05:16:02 -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=Ujk3sFsq; 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 CFBA2C21E18; Mon, 9 Jul 2018 12:16:01 +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 75F45C21DF3; Mon, 9 Jul 2018 12:15:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0B60C21DF3; Mon, 9 Jul 2018 12:15:56 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 7CC74C21D4A for ; Mon, 9 Jul 2018 12:15:56 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id h20-v6so4617480wmb.4 for ; Mon, 09 Jul 2018 05:15:56 -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=oNqjYNoE707enDlD0ykyiYTikBJ6F4e/acGHOMpXhpY=; b=Ujk3sFsqc7FMxGfryQw5GJqEYfwxArZ5cEcPQgSyRNe3Oxdb8uANEO5ef5MeDbLcr6 l/eHJZBWYHq/+7FCv0vTR8tfmHjUY5oswF2fdBlxk/BIl80tusUNDt2ENzCtlJ+MfPqK mV6jkS5PWZRAGt0UzuxMMYHmtwDAOBuSrvNLg= 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=oNqjYNoE707enDlD0ykyiYTikBJ6F4e/acGHOMpXhpY=; b=N6OJSgnDSunXey1FnesVd//XDRFyAGaSbt0vnPfnQMUHDgtXnOQ09e+JnYWRfR0TH/ W5K5flPK5Riobp21/m7zfUGLFMBtjHl/gzbbgdetOJp5SW/DXXIrFiUWN9WSJpFQCZJz jTXYlxk5hcbP9YJIsTFl9M5hRpwkRLaG6YKtaCpeZZsdbePS5hf3iibyYR3BlG0xi0q+ 2LnqFmPI5OV2VinQd6cAQxPS3xdZgzmDPSYUxBvsmEuDBTgnCvfvOC0Gcosu5OWL1n/1 etaWodcdmZ/0Hnuphi7iAw9V4CSV7ZKk67yxxgZt+FpZbuOoLDI1OapEYCD8RaInRnk5 vLvw== X-Gm-Message-State: APt69E1MnCvXiVOV/VjaJVxO/d9cJbROe8SgjFFwrUOMNkj5/7mrcORH j9+w5o/r2zdhoNNrIpFRfV0t8idcsvY+9g== X-Received: by 2002:a1c:3282:: with SMTP id y124-v6mr11629085wmy.11.1531138555842; Mon, 09 Jul 2018 05:15:55 -0700 (PDT) Received: from localhost ([195.238.93.254]) by smtp.gmail.com with ESMTPSA id j43-v6sm30939143wrj.1.2018.07.09.05.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 05:15:55 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Mon, 9 Jul 2018 15:15:54 +0300 Message-Id: <1531138554-7429-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 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 Reviewed-by: Sam Protsenko --- 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..5eabab0 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_IO; + + 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;