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 C186CC77B7C for ; Fri, 26 May 2023 21:41:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAD2C85D24; Fri, 26 May 2023 23:41:20 +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="AGzdBy4m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B84286181; Fri, 26 May 2023 23:41:19 +0200 (CEST) Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) (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 C4D07846A2 for ; Fri, 26 May 2023 23:41:16 +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-qk1-x736.google.com with SMTP id af79cd13be357-75b050b4fa0so145837685a.0 for ; Fri, 26 May 2023 14:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685137275; x=1687729275; 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=OFvRnvWZ5ojEGD+P3tJPk0O9nSMWINK01i3+Wzf/ruY=; b=AGzdBy4mR0w+p/NwKGnUZteVJIwA8ddNjwFYsl1YvIYcht1NHWwlGBeOBhTIbWaBNg loFGRegP+yk6CdxJIP51/sDhgvSX/drudwesRJzA+BgYXSPtbu+7KI32gRDhjdM2ALLI C+CT4tIOw23GE1OvWFax8Jz5L4Cttd8cqd47Hk+MofPcKBWZEQ37vpYVoi05k7KmtlJi yDXj7fu5kDidqPnPoGGEGwQ2SyP0ADdjpH6rD6xZHwj+F+5PEjD2wqqdY/1WDXjI1fUT dr3zxqWXmD9sYykUNu6kA9XtS/5mSMDjJPtdGKuwlMZh24Brkvj7r3J1IU24G1TWjwdk dS8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685137275; x=1687729275; 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=OFvRnvWZ5ojEGD+P3tJPk0O9nSMWINK01i3+Wzf/ruY=; b=AnOoBRLMUPxCgwZT/Q6UbnGTxvUuumGsb7lk4BO0Tnx36NmoySYMvUT/ZHl94ySofK 8ypOLQkWvBTtFNLGMpYAt+97zc27Jh/jz5IxAMMUJjQ36rU+66oLJIy/aT0SZ7JO363r 1aeyREeVoJxyqwkFFLiX01NMg7YDlSF7bl5BweRDABxhwi1cB7RBKOdMLl654pyp/2LD sq/1uVNrqnkxIIwbbQvaFlFVGl6qmlqDiqEFPcqyClJwcYa48ouZEBuyeBmvgQEyO7Ug y9B4WMAnIITBFSLO4uIqIkhSvDUE+Fo5a0GvrqhwDkAxjX2wkEZw4RZzivrG1Z1PWMxZ tw9g== X-Gm-Message-State: AC+VfDyj9Ps1QbRXGutakxnq76s6aQ29XSELYCNpRkYq4IyvvPxG4Tcz 2qrvDk+NmToJJQ/Sdvd7fKNOmag0Ih0kuRon3tA= X-Google-Smtp-Source: ACHHUZ7q9KzxzNbTzEBghhRCO7l+wHxwIyQ7CiTO1kU8UvzdPv4PyHGXr15JC25REZaJgFyIq53VIg== X-Received: by 2002:a05:620a:8c0e:b0:75b:23a1:44f with SMTP id qz14-20020a05620a8c0e00b0075b23a1044fmr786523qkn.21.1685137275374; Fri, 26 May 2023 14:41:15 -0700 (PDT) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.114.251.9]) by smtp.gmail.com with ESMTPSA id p22-20020a05620a15f600b0075b196ae392sm1437529qkm.104.2023.05.26.14.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 14:41:15 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima Subject: [PATCH v6 3/3] Load option with short device path for boot vars Date: Fri, 26 May 2023 14:36:53 -0700 Message-Id: <20230526213650.990816-4-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230526213650.990816-1-raymond.mao@linaro.org> References: <20230526213650.990816-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 --- 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 48cd5f0636..7d0b4f3f90 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