From patchwork Fri Oct 4 03:05:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1171535 X-Patchwork-Delegate: xypron.glpk@gmx.de 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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="l/WeDJMp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46kvnv1QTLz9sPd for ; Fri, 4 Oct 2019 13:03:15 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DC01BC21EFD; Fri, 4 Oct 2019 03:02:30 +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_H2, 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 F4186C21F0F; Fri, 4 Oct 2019 03:02:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 82B99C21DFA; Fri, 4 Oct 2019 03:02:10 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by lists.denx.de (Postfix) with ESMTPS id 5738EC21F0F for ; Fri, 4 Oct 2019 03:02:10 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id 23so2923417pgk.3 for ; Thu, 03 Oct 2019 20:02:10 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=sDAJSiL92Z4i7X7aHvhtkTV+rG2TeOZzZNIoxx+SyJ4=; b=l/WeDJMpL/XPIp6CQVBcXXfcEtsspZpas+EKHQWk42Lr6kO4TCjOK9cBsjQsEql1mO FBciunsgpvKTj5UFySyKcsmLsJFv0EutHbOmclvxTPTjieAihEnxwWEMuOh3LIT8dbri zTfTey3zJIEi+Kxz+6tPQ1ySN68O+3MTV/zgcb3F33Vl+atRWJ5wmxQEBhhJbrUY4jPL BViKVhxHS0JxY/JU8KlESM158bNpsis5fanNA/aYprhRXmDDm03oGPKKogYS7FMY2K33 /P/gGo6/SEpJnQita7g2WPDMPM1PJngop343EZxlHGJmliEDRF7ojL+RfDQ0G4CxPEOF Jtog== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sDAJSiL92Z4i7X7aHvhtkTV+rG2TeOZzZNIoxx+SyJ4=; b=r+uzIx3tZw2RHHHxxfTgptu7c9YzsFyinKT+JwwCQ84VjYFEb/yeMkvBbeN1nkgcsc hTSSpY+n3in1FbWNNgNuKtMvOURWVQrHtIDcKZ9OdxhRo8FhfTYaolMYz2aXnwd86+zD NtudDGAilGN+wDwpxjjmeCjRG5T2MSSxbcD5D9Xp4fNudmv6QsFAtb+TMRlN619QeO8t DD0jFOcQFUdiZdzf0fbSJAsWmuoIh7/6aml7/WCGDJreshE11+2fTQi5Be6XI0uxEikN uCvNYttYb6AHtBMFX52qzRe1yTpzZbelEyl9MdlXkU0S3daozoTKhZCHFp4gmPsDdDh8 d++Q== X-Gm-Message-State: APjAAAXFLdKtPNM+IEOQhk9jtXrytea4rAVLGxHP2Xbia7TBBKqfQt6B igZf7j6dNWujORfjXVhMql9Glw== X-Google-Smtp-Source: APXvYqwW/duOd/SnDfAJ5qj/qLfum3anb8XOlxqljYscDmXRLuZtIPdYAWMDzLp7pKE6FsDLaTYT3g== X-Received: by 2002:a63:dd0c:: with SMTP id t12mr12526144pgg.82.1570158128870; Thu, 03 Oct 2019 20:02:08 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id t14sm3633563pgv.84.2019.10.03.20.02.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Oct 2019 20:02:08 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Date: Fri, 4 Oct 2019 12:05:22 +0900 Message-Id: <20191004030523.21579-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191004030523.21579-1-takahiro.akashi@linaro.org> References: <20191004030523.21579-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 3/4] efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if available 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In the current implementation, EFI_SIMPLEFILE_SYSTEM_PROTOCOL is always installed to all the partitions even if some of them may house no file system. With this patch, that protocol will be installed only if any file system exists. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_disk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 9007a5f77f3d..27329cadb6f1 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -262,6 +263,19 @@ efi_fs_from_path(struct efi_device_path *full_path) return handler->protocol_interface; } +static int efi_fs_exists(struct blk_desc *desc, int part) +{ + if (fs_set_blk_dev_with_part(desc, part)) + return 0; + + if (fs_get_type() == FS_TYPE_ANY) + return 0; + + fs_close(); + + return 1; +} + /* * Create a handle for a partition or disk * @@ -315,7 +329,7 @@ static efi_status_t efi_disk_add_dev( diskobj->dp); if (ret != EFI_SUCCESS) return ret; - if (part >= 1) { + if (part >= 1 && efi_fs_exists(desc, part)) { diskobj->volume = efi_simple_file_system(desc, part, diskobj->dp); ret = efi_add_protocol(&diskobj->header,