From d4947c05b27449b4320179d57028a0542fd1394f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 2 Aug 2007 20:18:32 +0100 Subject: Allow images to hold references to the originating URI. Some shuffling around of the image management code; this needs tidying up. --- src/arch/i386/image/bzimage.c | 2 +- src/arch/i386/image/multiboot.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/arch') diff --git a/src/arch/i386/image/bzimage.c b/src/arch/i386/image/bzimage.c index 8a8b254b5..ad2a04cf8 100644 --- a/src/arch/i386/image/bzimage.c +++ b/src/arch/i386/image/bzimage.c @@ -190,7 +190,7 @@ static size_t bzimage_load_initrd ( struct image *image, return 0; /* Create cpio header before non-prebuilt images */ - if ( filename[0] ) { + if ( filename && filename[0] ) { size_t name_len = ( strlen ( filename ) + 1 ); DBGC ( image, "bzImage %p inserting initrd %p as %s\n", diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c index 76114130f..dfd872cb8 100644 --- a/src/arch/i386/image/multiboot.c +++ b/src/arch/i386/image/multiboot.c @@ -135,6 +135,7 @@ multiboot_build_module_list ( struct image *image, unsigned int insert; physaddr_t start; physaddr_t end; + char *cmdline; unsigned int i; /* Add each image as a multiboot module */ @@ -169,7 +170,9 @@ multiboot_build_module_list ( struct image *image, ( ( count - insert ) * sizeof ( *module ) )); module->mod_start = start; module->mod_end = end; - module->string = virt_to_phys ( module_image->cmdline); + cmdline = ( module_image->cmdline ? + module_image->cmdline : "" ); + module->string = virt_to_phys ( cmdline ); module->reserved = 0; /* We promise to page-align modules */ @@ -222,6 +225,7 @@ static struct multiboot_module __bss16_array ( mbmodules, [MAX_MODULES] ); */ static int multiboot_exec ( struct image *image ) { physaddr_t entry = image->priv.phys; + char *cmdline; /* Populate multiboot information structure */ memset ( &mbinfo, 0, sizeof ( mbinfo ) ); @@ -229,7 +233,8 @@ static int multiboot_exec ( struct image *image ) { MBI_FLAG_CMDLINE | MBI_FLAG_MODS ); multiboot_build_memmap ( image, &mbinfo, mbmemmap, ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) ); - mbinfo.cmdline = virt_to_phys ( image->cmdline ); + cmdline = ( image->cmdline ? image->cmdline : "" ); + mbinfo.cmdline = virt_to_phys ( cmdline ); mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules, ( sizeof(mbmodules) / sizeof(mbmodules[0]) ) ); mbinfo.mods_addr = virt_to_phys ( mbmodules ); -- cgit v1.2.3-55-g7522