From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vr8KQ-0000e8-Gs for mharc-grub-devel@gnu.org; Thu, 12 Dec 2013 10:37:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr8KM-0000X6-UO for grub-devel@gnu.org; Thu, 12 Dec 2013 10:37:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vr8KL-0005np-HJ for grub-devel@gnu.org; Thu, 12 Dec 2013 10:37:26 -0500 Received: from v6.chiark.greenend.org.uk ([2001:ba8:1e3::]:46888 helo=chiark.greenend.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr8KL-0005nj-BY for grub-devel@gnu.org; Thu, 12 Dec 2013 10:37:25 -0500 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1Vr8KK-0001sP-Qt; Thu, 12 Dec 2013 15:37:24 +0000 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Vr8KK-0002OV-2o; Thu, 12 Dec 2013 15:37:24 +0000 Date: Thu, 12 Dec 2013 15:37:22 +0000 From: Colin Watson To: grub-devel@gnu.org, xen-devel@lists.xen.org Subject: [PATCH 2/4] Accept environment variables on the command line for Xen. Message-ID: <20131212153722.GC1431@riva.ucam.org> References: <20131212153643.GA1431@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131212153643.GA1431@riva.ucam.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:ba8:1e3:: 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:37:28 -0000 * 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. + + * 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 * +fetch_command_line_word (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 -- 1.8.4.4