From d972192520af6db45b502130b5b1e2dfb21b89a1 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 26 Oct 2023 14:31:16 -0400 Subject: env: Move env_set() out of cmd/nvedit.c and in to env/common.c Inside of env/common.c we already have our helper env_set_xxx functions, and even have a comment that explains why env_set() itself wasn't moved. We now handle that move. This requires that we rename the previous _do_env_set() to env_do_env_set() and note it as an internal env function. Add comments about this function to explain why we do this when we add the prototype. Add a new function, env_inc_id() to allow for the counter to be updated by both commands and callers, and document this as well by the prototype. Signed-off-by: Tom Rini --- include/env.h | 8 ++++++++ include/env_internal.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) (limited to 'include') diff --git a/include/env.h b/include/env.h index 430c4fa94a4..9778e3e4f2c 100644 --- a/include/env.h +++ b/include/env.h @@ -72,6 +72,14 @@ enum env_redund_flags { */ int env_get_id(void); +/** + * env_inc_id() - Increase the sequence number for the environment + * + * Increment the value that is used by env_get_id() to inform callers + * if the environment has changed since they last checked. + */ +void env_inc_id(void); + /** * env_init() - Set up the pre-relocation environment * diff --git a/include/env_internal.h b/include/env_internal.h index 6a694946468..ae7816d38e5 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -193,6 +193,18 @@ struct env_driver { extern struct hsearch_data env_htab; +/** + * env_do_env_set() - Perform the actual setting of an environment variable + * + * Due to the number of places we may need to set an environmental variable + * from we have an exposed internal function that performs the real work and + * then call this from both the command line function as well as other + * locations. + * + * Return: 0 on success or 1 on failure + */ +int env_do_env_set(int flag, int argc, char *const argv[], int env_flag); + /** * env_ext4_get_intf() - Provide the interface for env in EXT4 * -- cgit v1.3.1