Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDE7DEB64D9 for ; Mon, 19 Jun 2023 21:24:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C87B862DA; Mon, 19 Jun 2023 23:24:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BUr+98mh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CE1786093; Mon, 19 Jun 2023 23:24:12 +0200 (CEST) Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 25A5B862FA for ; Mon, 19 Jun 2023 23:24:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-62fec6068bbso34816136d6.2 for ; Mon, 19 Jun 2023 14:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687209847; x=1689801847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sWcf3RgoUCTFh3c4Azp6zMqCvDyeD5uEWRLLJQnCX5Y=; b=BUr+98mhbrAPV8UkBb7GsIVIgmMgOeag6WAX4Wzk5cJCDTArDFnZbeKiWP3kxOQcj+ YC5UZ0ndGA+UN7k9nLJbZfLVVzT2zFW4zEklQPfSm23knLfEmtKpdX2PgiD5xSN+PsyS CGLX5Yf4rlJ4NqYFrhMUgmYdyHyuUWp5KUVyg3lJfE0oeXOaENGIkdmPCSa5P/API+Ku cFmeWeAMDADtrGGhVi1f64C4wjHGPp43lILF7xs95nAzBu7MBw0Vs+EKxpgeewmaVVs+ 7qLyHGTHS5HR2SKY0seTN44YQQ3JnLjNpFMrITBUBlYIRcgabw+d946aTurHCmRKxuBO hi2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687209847; x=1689801847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sWcf3RgoUCTFh3c4Azp6zMqCvDyeD5uEWRLLJQnCX5Y=; b=btQ4WaAyzuWJFVGMq1ZDzcdQsANWL8H3q6ijRJn/shYufOgjlv1FnrbtKxoIAH3liC WHl0RXe76BBLJ3Iv9nUxcgKMX2yEmNVU03+liKFxdUDURWFcmlqtSHXUsOQGuA2grPlB x9lAoMxDH/ptrZz9BxTfIgiFpRODwhMXouvD+pzt0DLJxvZxAfvvxOQju1VHjKJty2NS BUKAWcVm6d662b4t5oWMu8oX7jDl8xuhpMuvixvjLH4DjChgiaa+fI4O4668URH+e15W u1c3zA6va2t+NxAZtbFmGDfw+ji3gvZkDLMw/pXUzyLwshGgc7wmK875ejI6Df4ub8ok qzrQ== X-Gm-Message-State: AC+VfDw1R/RBSqSRY8K992AGCC5zXim3uDBq8unP7nsMYbSWoiZP3X8C WX3n640nvZZyzdy/OEOHGIllxDg8AFML9WxvV4g= X-Google-Smtp-Source: ACHHUZ7NLKy4K02PrJJVwy2zXeXKmsIme+4YwVDo44UgUI9TvFRv9TvO+F01a/ZrIPKPsGeg3I0qDA== X-Received: by 2002:a05:6214:e6c:b0:631:e696:7bb with SMTP id jz12-20020a0562140e6c00b00631e69607bbmr3044929qvb.41.1687209847634; Mon, 19 Jun 2023 14:24:07 -0700 (PDT) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.114.251.9]) by smtp.gmail.com with ESMTPSA id e8-20020a0ce3c8000000b005ef442226bbsm412407qvl.8.2023.06.19.14.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 14:24:07 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima Subject: [PATCH v10 4/4] Load option with short device path for boot vars Date: Mon, 19 Jun 2023 14:23:01 -0700 Message-Id: <20230619212303.128288-5-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230619212303.128288-1-raymond.mao@linaro.org> References: <20230619212303.128288-1-raymond.mao@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The boot variables automatically generated for removable medias should be with short form of device path without device nodes. This is a requirement for the case that a removable media is plugged into a different port but is still able to work with the existing boot variables. Signed-off-by: Raymond Mao Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- Changes in v2 - Ignore EFI_NOT_FOUND returned from efi_bootmgr_update_media_device_boot_option which means no boot options scanned. Changes in v3 - Split the patch into moving and renaming functions and individual patches for each changed functionality Changes in v4 - Revert v2 change of introducing a bool parameter when updating the boot option. Use short-form of device path by default Changes in v5 - Add warning log when a short-form device path doesn't exist Changes in v6 - Revert v5 change and use original device path if short-form does not exist lib/efi_loader/efi_bootmgr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 28e800499c..398b0f89e2 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -371,6 +371,7 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo struct efi_load_option lo; char buf[BOOTMENU_DEVICE_NAME_MAX]; struct efi_device_path *device_path; + struct efi_device_path *short_dp; ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler); if (ret != EFI_SUCCESS) @@ -387,6 +388,11 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo p = dev_name; utf8_utf16_strncpy(&p, buf, strlen(buf)); + /* prefer to short form device path */ + short_dp = efi_dp_shorten(device_path); + if (short_dp) + device_path = short_dp; + lo.label = dev_name; lo.attributes = LOAD_OPTION_ACTIVE; lo.file_path = device_path; -- 2.25.1