Re: [PATCH v2 10/12] env: Add support for overwriting default environment via sysinfo

Simon Glass
2021-11-05T02:08:28Z

On Wed, 3 Nov 2021 at 17:23, Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> The default_environment[] buffer is built at compile time, but sometimes
> it makes sense for some default environment variables to be determined
> at runtime, for example:
> - one board code may support different boards, and needs that
> fdtfile, board, board_name
> are set appropriately when command
> env default -a
> is executed
> - some boards may want to prohibit the
> env default -a
> command to remove device MAC addresses stored in
> ethaddr, ethNaddr.
> This is the case for the ESPRESSObin board code, for example, where
> currently the board_late_init() function rewrites the default
> environment array to achieve this.
>
> Add new sysinfo IDs
> SYSINFO_ID_DEF_ENV_NAMES
> SYSINFO_ID_DEF_ENV_VALUES
> corresponding to sysinfo string list of names and values of default
> environment variables that are to take precedence over the
> default_environment[] buffer.
>
> Add code to default environemnt handlers in env/common.c, which iterate
> these sysinfo string lists correspondingly.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
> env/common.c | 107 +++++++++++++++++++++++++++++++++++++++++++++-
> include/sysinfo.h | 4 ++
> 2 files changed, 110 insertions(+), 1 deletion(-)
>

Seems OK to me, but see my earlier request to simplify the API and
reduce flexibility.

Regards,
Simon