From patchwork Mon Oct 7 05:59:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1172638 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="H/uNvAuh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46mqbq3hGNz9sP7 for ; Mon, 7 Oct 2019 17:01:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0568BC21EFB; Mon, 7 Oct 2019 06:00:36 +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 DAE4CC21F51; Mon, 7 Oct 2019 05:57:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B8575C21F2B; Mon, 7 Oct 2019 05:56:49 +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 09D12C21F37 for ; Mon, 7 Oct 2019 05:56:49 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id 23so7528131pgk.3 for ; Sun, 06 Oct 2019 22:56:48 -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=f7gg+N0gEHTtyIVaofbGVZ0I191T6OeVlDPa31psIFU=; b=H/uNvAuhoGQkGikC031JvS/H3N6DuocOmG5EcB5XNCAMCsY7RZDhbFXa8FjlkhnGJG SX53uL+SFhMXN58z3A3paUtc3Gr5pjg6VtU2pWeFisYn1WQin34D0t7qNULPU0KA03TP M7YRplZDEJu3bf1W3JOmbPTVjwFw27RruMEhWlqCVT1/6ycyVjqPfqhe5Xw4hgQRKgLZ AFccNO9Gg6uEIv155OuQUmM8/5Lgv2nF+o+J9G5g6z6ybGQcIrk3TwsJ5+Y4YFy4vS6a A0bVgVZjaGs5/2P53gTGjEx5eVZe5gVPTFj6GxcDTSthPDSTrjSgI403bR6nP0bU7+mm YopA== 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=f7gg+N0gEHTtyIVaofbGVZ0I191T6OeVlDPa31psIFU=; b=h1r8duopH0qxGT3wLMwNjNnaThnAb0MAL1z1YHQYs5ceYsyopW7g+lZ6Fh0S/BnpDq kCLDidUWqpKRDHq+RNo7X3MrsCJXOt6cNlYtZhsymPf9OIS1il2TKDs82exLtyZ0bgF2 5Niu5xlX3N5k0xFrraEpS2Q6+T4XqEtvVau/NuLm07o8OGSdBQcgsr8Jq88qreczJQ9e cFvbAn23lx9dP5J0sF588/L/aokaN1otTUy08c5TA2NOj89NeMzn3etR8efX1mhwW3Aa H1QAGd3zD6mNvP9zCSbsQP9Xrepca15dRa7VegIaubvQymo0EETn7SzC6mz6tG+qGF/3 IlAA== X-Gm-Message-State: APjAAAWngc0bIbaM9/Aqmaz+BQie0xzcUCirK97ZyqEyEqGoiF7bflyZ tE8wicvsYE7xZc/zLm6+sK4S8Q== X-Google-Smtp-Source: APXvYqxom2eqS0Xw/BSAF/dt22Db4RYvS+ageeB7RwGVBuG9AJTmQudxg+qzCI9GMEkYiZvrW8Hp9A== X-Received: by 2002:a62:4d45:: with SMTP id a66mr31430998pfb.24.1570427807705; Sun, 06 Oct 2019 22:56:47 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f62sm14351828pfg.74.2019.10.06.22.56.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Oct 2019 22:56:47 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Date: Mon, 7 Oct 2019 14:59:38 +0900 Message-Id: <20191007055939.17093-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191007055939.17093-1-takahiro.akashi@linaro.org> References: <20191007055939.17093-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 4/5] 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 9007a5f77f3d..861fcaf3747f 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,27 @@ efi_fs_from_path(struct efi_device_path *full_path) return handler->protocol_interface; } +/** + * efi_fs_exists() - check if a partition bears a file system + * + * @desc: block device descriptor + * @part: partition number + * Return: 1 if a file system exists on the partition + * 0 otherwise + */ +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 +337,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,