grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] Accept environment variables on the command line for Xen


From: Andrey Borzenkov
Subject: Re: [PATCH 2/4] Accept environment variables on the command line for Xen.
Date: Thu, 12 Dec 2013 19:48:05 +0400

В Thu, 12 Dec 2013 15:37:22 +0000
Colin Watson <address@hidden> пишет:

> * grub-core/kern/xen/init.c (fetch_command_line_word): New function.
> (parse_command_line): Likewise.
> (grub_machine_init): Call parse_command_line.
> ---
>  ChangeLog                 |  8 ++++++++
>  grub-core/kern/xen/init.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 766fe4b..fc86601 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,13 @@
>  2013-12-12  Colin Watson  <address@hidden>
>  
> +     Accept environment variables on the command line for Xen.
> +

Thank you!

It may make sense to generalize it to other archs. At least EFI
definitely comes in mind. In this case platform specific part is only
to fetch parameter string(s). What about

- move fetch_command_line_word and parse_command_line to separate file
  that is included for specific platforms only
- make each platform that can accept fetch parameters in platform
  specific way and call common code (parse_command_line)

Does it make sense?

I will add EFI part then later.

> +     * grub-core/kern/xen/init.c (fetch_command_line_word): New function.
> +     (parse_command_line): Likewise.
> +     (grub_machine_init): Call parse_command_line.
> +
> +2013-12-12  Colin Watson  <address@hidden>
> +
>       Add an option to exclude devices from search results.
>  
>       * grub-core/commands/search.c (struct search_ctx): Add excludes and
> diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c
> index 1d8eaec..eb9b8b3 100644
> --- a/grub-core/kern/xen/init.c
> +++ b/grub-core/kern/xen/init.c
> @@ -525,6 +525,48 @@ map_all_pages (void)
>    grub_mm_init_region ((void *) heap_start, heap_end - heap_start);
>  }
>  
> +static char *
> + (char *pos, char **word)
> +{
> +  while (grub_isspace (*pos))
> +    pos++;
> +
> +  if (!*pos)
> +    return NULL;
> +
> +  *word = pos;
> +  while (*pos && !grub_isspace (*pos))
> +    pos++;
> +  if (*pos)
> +    *pos++ = '\0';
> +  return pos;
> +}
> +
> +static void
> +parse_command_line (void)
> +{
> +  char *cmd_line;
> +  char *pos, *word;
> +
> +  cmd_line = grub_malloc (MAX_GUEST_CMDLINE + 1);
> +  grub_memcpy (cmd_line, grub_xen_start_page_addr->cmd_line,
> +            MAX_GUEST_CMDLINE);
> +  cmd_line[MAX_GUEST_CMDLINE] = '\0';
> +  pos = cmd_line;
> +  while ((pos = fetch_command_line_word (pos, &word)) != NULL)
> +    {
> +      char *equals;
> +
> +      equals = grub_strchr (word, '=');
> +      if (!equals)
> +     continue;
> +
> +      *equals = '\0';
> +      grub_env_set (word, equals + 1);
> +    }
> +  grub_free (cmd_line);
> +}
> +
>  extern char _end[];
>  
>  void
> @@ -547,6 +589,8 @@ grub_machine_init (void)
>    grub_xendisk_init ();
>  
>    grub_boot_init ();
> +
> +  parse_command_line ();
>  }
>  
>  void




reply via email to

[Prev in Thread] Current Thread [Next in Thread]