From: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] multiboot: Support quotable commas in module list
Date: Fri, 15 Apr 2011 09:56:26 +0200 [thread overview]
Message-ID: <1302854186-6772-1-git-send-email-adam@os.inf.tu-dresden.de> (raw)
Support quoting of ',' (and '\') to allow commas in the parameter list of
modules.
Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
hw/multiboot.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/hw/multiboot.c b/hw/multiboot.c
index 394ed01..73f01aa 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -95,13 +95,26 @@ typedef struct {
int mb_mods_count;
} MultibootState;
+static int mb_is_cmdline_quote(const char *c)
+{
+ return c[0] == '\\' && (c[1] == '\\' || c[1] == ',');
+}
+
static uint32_t mb_add_cmdline(MultibootState *s, const char *cmdline)
{
int len = strlen(cmdline) + 1;
+ int ci, bi;
target_phys_addr_t p = s->offset_cmdlines;
+ char *b = (char *)s->mb_buf + p;
- pstrcpy((char *)s->mb_buf + p, len, cmdline);
- s->offset_cmdlines += len;
+ for (ci = 0, bi = 0; ci < len - 1; ci++, bi++) {
+ if (mb_is_cmdline_quote(&cmdline[ci])) {
+ ci++;
+ }
+ b[bi] = cmdline[ci];
+ }
+ b[bi] = 0;
+ s->offset_cmdlines += bi + 1;
return s->mb_buf_phys + p;
}
@@ -124,6 +137,18 @@ static void mb_add_mod(MultibootState *s,
s->mb_mods_count++;
}
+static const char *mb_cmdline_next_module(const char *c)
+{
+ for (; *c; c++) {
+ if (mb_is_cmdline_quote(c)) {
+ c++;
+ } else if (c[0] == ',') {
+ return c;
+ }
+ }
+ return 0;
+}
+
int load_multiboot(void *fw_cfg,
FILE *f,
const char *kernel_filename,
@@ -238,7 +263,7 @@ int load_multiboot(void *fw_cfg,
const char *r = initrd_filename;
mbs.mb_buf_size += strlen(r) + 1;
mbs.mb_mods_avail = 1;
- while ((r = strchr(r, ','))) {
+ while ((r = mb_cmdline_next_module(r))) {
mbs.mb_mods_avail++;
r++;
}
@@ -261,7 +286,7 @@ int load_multiboot(void *fw_cfg,
int mb_mod_length;
uint32_t offs = mbs.mb_buf_size;
- next_initrd = strchr(initrd_filename, ',');
+ next_initrd = (char *)mb_cmdline_next_module(initrd_filename);
if (next_initrd)
*next_initrd = '\0';
/* if a space comes after the module filename, treat everything
--
1.7.4.1
next reply other threads:[~2011-04-15 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 7:56 Adam Lackorzynski [this message]
2011-04-15 9:09 ` [Qemu-devel] [PATCH] multiboot: Support quotable commas in module list Stefan Hajnoczi
2011-04-15 13:17 ` Kevin Wolf
2011-04-16 9:42 ` Adam Lackorzynski
2011-04-16 11:21 ` Stefan Hajnoczi
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=1302854186-6772-1-git-send-email-adam@os.inf.tu-dresden.de \
--to=adam@os.inf.tu-dresden.de \
--cc=qemu-devel@nongnu.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).