From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v1 34/54] efi: loader: support formatting only first device path node to text
Date: Thu, 18 Dec 2025 11:37:54 +0100 [thread overview]
Message-ID: <20251218111242.1527495-35-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20251218111242.1527495-1-a.fatoum@pengutronix.de>
For use in the follow-up efi_device_path_to_text, teach
device_path_to_str_buf() to support formatting the first node only.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/efi_handle_dump.c | 2 +-
drivers/efi/efi-device.c | 2 +-
efi/devicepath.c | 17 +++++++++++------
efi/loader/devicepath.c | 4 ++--
efi/payload/init.c | 2 +-
include/efi/devicepath.h | 5 +++--
lib/vsprintf.c | 2 +-
7 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/commands/efi_handle_dump.c b/commands/efi_handle_dump.c
index c5c6b6bbc3bc..183a7d4bc3a6 100644
--- a/commands/efi_handle_dump.c
+++ b/commands/efi_handle_dump.c
@@ -28,7 +28,7 @@ static void efi_devpath(struct efi_boot_services *bs,
if (EFI_ERROR(efiret))
return;
- dev_path_str = device_path_to_str(devpath);
+ dev_path_str = device_path_to_str(devpath, true);
if (dev_path_str) {
printf(" %s: \n %s\n", desc, dev_path_str);
free(dev_path_str);
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index 6bf43cebea8d..490faff6f53d 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -196,7 +196,7 @@ static int efi_register_device(struct efi_device *efidev)
if (ret)
return ret;
- dev_path_str = device_path_to_str(efidev->devpath);
+ dev_path_str = device_path_to_str(efidev->devpath, true);
if (dev_path_str) {
dev_add_param_fixed(&efidev->dev, "devpath", "%s", dev_path_str);
free(dev_path_str);
diff --git a/efi/devicepath.c b/efi/devicepath.c
index e4170d701e47..8298073572ae 100644
--- a/efi/devicepath.c
+++ b/efi/devicepath.c
@@ -674,7 +674,7 @@ struct {
};
static void __device_path_to_str(struct string *str,
- const struct efi_device_path *dev_path)
+ const struct efi_device_path *dev_path, bool all_nodes)
{
const struct efi_device_path *dev_path_node;
void (*dump_node) (struct string *, const void *);
@@ -702,6 +702,9 @@ static void __device_path_to_str(struct string *str,
dump_node(str, dev_path_node);
+ if (!all_nodes)
+ return;
+
dev_path_node = next_device_path_node(dev_path_node);
}
}
@@ -712,19 +715,20 @@ static void __device_path_to_str(struct string *str,
* @dev_path: The EFI device path to format
* @buf: The buffer to format into or optionally NULL if @len is zero
* @len: The number of bytes that may be written into @buf
+ * @all_nodes: Whether to format the whole path or only the first node
* Return: total number of bytes that are required to store the formatted
* result, excluding the terminating NUL byte, which is always
* written.
*/
size_t device_path_to_str_buf(const struct efi_device_path *dev_path,
- char *buf, size_t len)
+ char *buf, size_t len, bool all_nodes)
{
struct string str = {
.str = buf,
.allocated = len,
};
- __device_path_to_str(&str, dev_path);
+ __device_path_to_str(&str, dev_path, all_nodes);
return str.used;
}
@@ -733,20 +737,21 @@ size_t device_path_to_str_buf(const struct efi_device_path *dev_path,
* device_path_to_str() - formats a device path into a newly allocated buffer
*
* @dev_path: The EFI device path to format
+ * @all_nodes: Whether to format the whole path or only the first node
* Return: A pointer to the nul-terminated formatted device path.
*/
-char *device_path_to_str(const struct efi_device_path *dev_path)
+char *device_path_to_str(const struct efi_device_path *dev_path, bool all_nodes)
{
void *buf;
size_t size;
- size = device_path_to_str_buf(dev_path, NULL, 0);
+ size = device_path_to_str_buf(dev_path, NULL, 0, all_nodes);
buf = malloc(size + 1);
if (!buf)
return NULL;
- device_path_to_str_buf(dev_path, buf, size + 1);
+ device_path_to_str_buf(dev_path, buf, size + 1, all_nodes);
return buf;
}
diff --git a/efi/loader/devicepath.c b/efi/loader/devicepath.c
index cd783477ef3e..17c659e4c5d8 100644
--- a/efi/loader/devicepath.c
+++ b/efi/loader/devicepath.c
@@ -1050,7 +1050,7 @@ struct efi_device_path *efi_dp_from_file(int dirfd, const char *path)
/**
* efi_dp_from_file_tostr() - format barebox VFS path as EFI device path string
*
- * Convert any barebox virtual file system path to an UEFI device path
+ * Convert any barebox virtual file system path to a full UEFI device path
* and then return its full string representation.
*
* @dirfd: directory fd
@@ -1065,7 +1065,7 @@ char *efi_dp_from_file_tostr(int dirfd, const char *path)
dp = efi_dp_from_file(dirfd, path);
if (dp)
- dpstr = device_path_to_str(dp);
+ dpstr = device_path_to_str(dp, true);
efi_free_pool(dp);
diff --git a/efi/payload/init.c b/efi/payload/init.c
index 7e361bab8ab3..d8a4410f22e6 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -94,7 +94,7 @@ static struct efi_boot *efi_get_boot(int num)
boot->path = memdup(ptr, boot->file_path_len);
- printf("path: %s\n", device_path_to_str(boot->path));
+ printf("path: %s\n", device_path_to_str(boot->path, true));
return boot;
}
diff --git a/include/efi/devicepath.h b/include/efi/devicepath.h
index 405f4446310e..125f114bd846 100644
--- a/include/efi/devicepath.h
+++ b/include/efi/devicepath.h
@@ -397,8 +397,9 @@ struct efi_device_path_bbs_bbs {
#define DEVICE_PATH_END_LENGTH (sizeof(struct efi_device_path))
const struct efi_device_path *device_path_from_handle(efi_handle_t handle);
-char *device_path_to_str(const struct efi_device_path *dev_path);
-size_t device_path_to_str_buf(const struct efi_device_path *dev_path, char buf[], size_t size);
+char *device_path_to_str(const struct efi_device_path *dev_path, bool all_nodes);
+size_t device_path_to_str_buf(const struct efi_device_path *dev_path,
+ char buf[], size_t size, bool all_nodes);
u8 device_path_to_type(const struct efi_device_path *dev_path);
u8 device_path_to_subtype(const struct efi_device_path *dev_path);
char *device_path_to_partuuid(const struct efi_device_path *dev_path);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 5ef4a075d0f6..6c9dae467496 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -395,7 +395,7 @@ static char *device_path_string(char *buf, const char *end, const struct efi_dev
if (!dp)
return string(buf, end, NULL, field_width, precision, flags);
- return buf + device_path_to_str_buf(dp, buf, end - buf);
+ return buf + device_path_to_str_buf(dp, buf, end - buf, true);
}
static noinline_for_stack
--
2.47.3
next prev parent reply other threads:[~2025-12-18 11:39 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 10:37 [PATCH v1 00/54] efi: implement EFI loader support in barebox Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 01/54] efi: payload: initrd: fix type mismatch on 32-bit Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 02/54] efi: loader: switch over event/memory key type to efi_uintn_t Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 03/54] lib: vsprintf: print human-readable EFI GUIDs with %pUs Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 04/54] fs: fat: don't duplicate dentries when resolving differently cased paths Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 05/54] efi: loader: add memory accounting Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 06/54] efi: loader: add pool allocator Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 07/54] efi: types: add EFI_RUNTIME_SECTION Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 08/54] resource: assign memory banks a default type and attr Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 09/54] ARM: lds: add EFI runtime service section Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 10/54] ARM: move needed assembly routines into EFI runtime section Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 11/54] crypto: crc32: implement position independent CRC32 Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 12/54] efi: loader: add support for tracing calls back into UEFI Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 13/54] efi: loader: add table utility functions Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 14/54] lib: add charset helpers Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 15/54] efi: loader: add object handling API Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 16/54] efi: loader: add devicepath support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 17/54] efi: loader: add debug support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 18/54] efi: loader: add boot services support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 19/54] efi: loader: add support for runtime services before ExitBootServices Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 20/54] efi: loader: setup root node Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 21/54] efi: loader: add watchdog support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 22/54] efi: loader: move PE implementation out of common code Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 23/54] efi: loader: protocol: add file protocol support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 24/54] efi: loader: protocol: add Block IO support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 25/54] efi: loader: protocol: implement efi_file_from_path Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 26/54] efi: loader: boot: implement LoadImage BootService Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 27/54] efi: loader: add EFI load option handling Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 28/54] efi: loader: protocol: add graphical output protocol support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 29/54] efi: loader: protocol: add console support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 30/54] efi: loader: protocol: add HII support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 31/54] efi: loader: protocol: add unicode collation support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 32/54] efi: loader: protocol: add random number generator protocol Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 33/54] efi: loader: protocol: add device_path_utilities Ahmad Fatoum
2025-12-18 10:37 ` Ahmad Fatoum [this message]
2025-12-18 10:37 ` [PATCH v1 35/54] efi: loader: protocol: add efi_device_path_to_text support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 36/54] restart: allow drivers to register runtime restart handler Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 37/54] poweroff: allow drivers to register runtime poweroff handler Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 38/54] ARM: psci: client: register runtime service " Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 39/54] ARM: psci: client: register runtime service restart handler Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 40/54] hardening: disable some features when EFI runtime support is enabled Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 41/54] filetype: add new filetype for efi-stubbed ARM zImages Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 42/54] bootm: add global.bootm.efi toggle Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 43/54] efi: loader: add ESP boot entry provider Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 44/54] efi: loader: add rudimentary EFI boot manager Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 45/54] efi: loader: implement bootm handler Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 46/54] efi: runtime: add EFI variable support Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 47/54] efi: loader: populate OsIndicationsSupported/PlatformLang variables Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 48/54] ARM: don't disable MMU when EFI booting Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 49/54] efi: runtime: add runtime service support after ExitBootServices Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 50/54] efi: runtime: add relocation check Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 51/54] efi: loader: CONFIG_EFI_RT_VOLATILE_STORE Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 52/54] efi: loader: support ExitBootServices Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 53/54] efi: loader: pass along SMBIOS table Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 54/54] ARM: configs: add multi_v7/8_efiloader_defconfig Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251218111242.1527495-35-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox