grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] always define config_directory and config_file as full pathn


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: [PATCH] always define config_directory and config_file as full pathname
Date: Tue, 10 Dec 2013 00:27:20 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10

Go ahead.
On 08.12.2013 22:05, Andrey Borzenkov wrote:
>> Adding ($root) to config_file/config_directory if none present would be
>> good.
> 
> Like this?
> 
> If configfile is relative pathname, extend it with current ($root) so its
> interpretation does not change if $root is changed later.
> 
> Suggested by Vladimir Serbienko.
> 
> ---
>  grub-core/normal/main.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
> index 991a595..84df360 100644
> --- a/grub-core/normal/main.c
> +++ b/grub-core/normal/main.c
> @@ -190,14 +190,26 @@ read_config_file (const char *config)
>    ctmp = grub_env_get ("config_directory");
>    if (ctmp)
>      old_dir = grub_strdup (ctmp);
> -  grub_env_set ("config_file", config);
> -  config_dir = grub_strdup (config);
> +  if (*config == '(')
> +    {
> +      grub_env_set ("config_file", config);
> +      config_dir = grub_strdup (config);
> +    }
> +  else
> +    {
> +      /* $root is guranteed to be defined, otherwise open above would fail */
> +      config_dir = grub_xasprintf ("(%s)%s", grub_env_get ("root"), config);
> +      if (config_dir)
> +     grub_env_set ("config_file", config_dir);
> +    }
>    if (config_dir)
> -    ptr = grub_strrchr (config_dir, '/');
> -  if (ptr)
> -    *ptr = 0;
> -  grub_env_set ("config_directory", config_dir);
> -  grub_free (config_dir);
> +    {
> +      ptr = grub_strrchr (config_dir, '/');
> +      if (ptr)
> +     *ptr = 0;
> +      grub_env_set ("config_directory", config_dir);
> +      grub_free (config_dir);
> +    }
>  
>    grub_env_export ("config_file");
>    grub_env_export ("config_directory");
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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