From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vr8Uw-0000RM-Ua for mharc-grub-devel@gnu.org; Thu, 12 Dec 2013 10:48:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr8Up-0000I6-H7 for grub-devel@gnu.org; Thu, 12 Dec 2013 10:48:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vr8Uj-0001UN-OD for grub-devel@gnu.org; Thu, 12 Dec 2013 10:48:15 -0500 Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]:51390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr8Uj-0001Tk-Fj for grub-devel@gnu.org; Thu, 12 Dec 2013 10:48:09 -0500 Received: by mail-la0-f41.google.com with SMTP id eo20so461591lab.28 for ; Thu, 12 Dec 2013 07:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=sFme/B6kQ+2+SrDjHcchat7oG3VCX6VBs6chyEKxNeQ=; b=M2b4mGc8iH8VvX9d1teRRdZfvso+Lq6okqVKMxPib+2G38kltKMXy+0AThVvuNo042 X53SFYAX+5sKureoSSpy933/cv/5pzU7yf2iF6BjFb67P92/c/JbPrmrt6pTII12FBxw RIPOUoevM2SjpbVhwoKwVYwgJvL3bwgTOSBDW/MC7H+1hE53g8PHKiHqN7NQ6mm8zyQt 9UKGn6WoYB/6drMKSYozeJa99ZA3EaGJ33Zkee7TR05u237yUqy5+HkOigDUrYkx26ZP LDFNgg7nKETHLj9tgFdKQFcK6IiYd3R2TS2dkLA1m0OBWQHWnRy4IIvE0QEjb1FTBXez LdFQ== X-Received: by 10.152.87.142 with SMTP id ay14mr4048473lab.7.1386863287203; Thu, 12 Dec 2013 07:48:07 -0800 (PST) Received: from opensuse.site (ppp91-76-134-134.pppoe.mtu-net.ru. [91.76.134.134]) by mx.google.com with ESMTPSA id sd11sm35567348lab.2.2013.12.12.07.48.06 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 12 Dec 2013 07:48:06 -0800 (PST) Date: Thu, 12 Dec 2013 19:48:05 +0400 From: Andrey Borzenkov To: grub-devel@gnu.org Subject: Re: [PATCH 2/4] Accept environment variables on the command line for Xen. Message-ID: <20131212194805.5d81a2e7@opensuse.site> In-Reply-To: <20131212153722.GC1431@riva.ucam.org> References: <20131212153643.GA1431@riva.ucam.org> <20131212153722.GC1431@riva.ucam.org> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::229 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Dec 2013 15:48:21 -0000 В Thu, 12 Dec 2013 15:37:22 +0000 Colin Watson пишет: > * 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 > > + 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 > + > 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