aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2024-01-17 18:59:11 +0100
committerKever Yang <kever.yang@rock-chips.com>2024-01-19 10:57:36 +0800
commit23c1ab92be6332fb528efc2d549898a5f1d17bf9 (patch)
tree52cd26e59568ff44b75562c40d3eafa9d7dfbfb9 /include
parent56bb09f5022d46d1244ba02680b6a7f2a0317598 (diff)
downloadu-boot-23c1ab92be6332fb528efc2d549898a5f1d17bf9.zip
u-boot-23c1ab92be6332fb528efc2d549898a5f1d17bf9.tar.gz
u-boot-23c1ab92be6332fb528efc2d549898a5f1d17bf9.tar.bz2
env: allow to copy value from default environment into a buffer
env_get_default suffers from a particular issue int that it can only return a value truncated to gd->env_buf (32) characters. This may be enough for most variables but it isn't for others, so let's allow users to provide a preallocated buffer to copy the value into instead, allowing for more control, though it'll still be truncated if the value size is bigger than the preallocated buffer. Cc: Quentin Schulz <foss+uboot@0leil.net> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Diffstat (limited to 'include')
-rw-r--r--include/env.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/env.h b/include/env.h
index 9778e3e..d2a5954 100644
--- a/include/env.h
+++ b/include/env.h
@@ -356,6 +356,16 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
*/
char *env_get_default(const char *name);
+/**
+ * env_get_default_into() - Look up a variable from the default environment and
+ * copy its value in buf.
+ *
+ * @name: Variable to look up
+ * Return: actual length of the variable value excluding the terminating
+ * NULL-byte, or -1 if the variable is not found
+ */
+int env_get_default_into(const char *name, char *buf, unsigned int len);
+
/* [re]set to the default environment */
void env_set_default(const char *s, int flags);