From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] always define config_directory and config_file as full pathname
Date: Tue, 10 Dec 2013 00:27:20 +0100 [thread overview]
Message-ID: <52A651D8.2010900@gmail.com> (raw)
In-Reply-To: <1386536710-30180-1-git-send-email-arvidjaar@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1765 bytes --]
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]
prev parent reply other threads:[~2013-12-09 23:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-07 19:51 [PATCH] trivial fix for config_file without directory part Andrey Borzenkov
2013-12-07 19:57 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-07 20:06 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-08 21:05 ` [PATCH] always define config_directory and config_file as full pathname Andrey Borzenkov
2013-12-09 23:27 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A651D8.2010900@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).