From: Jeremy Kerr Date: Tue, 9 Jul 2013 08:12:51 +0000 (+0800) Subject: discover/pxe: Handle initrds X-Git-Tag: v1.0.0~553 X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=ec80a0397adc1fd405dedce961a17d164241851a discover/pxe: Handle initrds We may see initrds specified on the kernel argument line, or as their own configuration directive. Signed-off-by: Jeremy Kerr --- diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c index 67cb788..810396a 100644 --- a/discover/pxe-parser.c +++ b/discover/pxe-parser.c @@ -1,4 +1,5 @@ +#define _GNU_SOURCE #include #include @@ -21,6 +22,13 @@ static void pxe_process_pair(struct conf_context *ctx, struct discover_boot_option *opt = ctx->parser_info; struct pb_url *url; + /* quirk in the syslinux config format: initrd can be separated + * by an '=' */ + if (!name && !strncasecmp(value, "initrd=", strlen("initrd="))) { + name = "initrd"; + value += strlen("initrd="); + } + if (!name) return; @@ -45,10 +53,26 @@ static void pxe_process_pair(struct conf_context *ctx, url = pb_url_join(ctx->dc, ctx->dc->conf_url, value); opt->boot_image = create_url_resource(opt, url); + } else if (streq(name, "INITRD")) { + url = pb_url_join(ctx->dc, ctx->dc->conf_url, value); + opt->initrd = create_url_resource(opt, url); + } else if (streq(name, "APPEND")) { + char *str, *end; + opt->option->boot_args = talloc_strdup(opt->option, value); - /* todo: initrd extraction */ + + str = strcasestr(value, "INITRD="); + if (str) { + str += strlen("INITRD="); + end = strchrnul(str, ' '); + *end = '\0'; + + url = pb_url_join(ctx->dc, ctx->dc->conf_url, str); + opt->initrd = create_url_resource(opt, url); + } } + } static int pxe_parse(struct discover_context *dc, char *buf, int len)