[image] Allow for zero embedded images

Having a default script containing

  #!gpxe
  autoboot

can cause problems when entering commands to load and start a kernel
manually; the default script image will still be present when the
kernel is started and so will be treated as an initrd.  It is possible
to work around this by typing "imgfree" before any other commands, but
this is counter-intuitive.

Fix by allowing the embedded image list to be empty (in which case we
just call autoboot()), and making this the default.

Reported by alkisg@gmail.com.
This commit is contained in:
Michael Brown
2009-02-24 05:51:21 +00:00
parent 43834f5d25
commit 4f3bab1a55
6 changed files with 32 additions and 20 deletions

View File

@@ -16,7 +16,8 @@
*
* @v refcnt Reference counter
*/
static void embedded_image_free ( struct refcnt *refcnt __unused ) {
static void __attribute__ (( unused ))
embedded_image_free ( struct refcnt *refcnt __unused ) {
/* Do nothing */
}
@@ -51,14 +52,18 @@ static struct image embedded_images[] = {
* Register all embedded images
*/
static void embedded_init ( void ) {
unsigned int i;
int i;
struct image *image;
void *data;
int rc;
/* Skip if we have no embedded images */
if ( ! sizeof ( embedded_images ) )
return;
/* Fix up data pointers and register images */
for ( i = 0 ; i < ( sizeof ( embedded_images ) /
sizeof ( embedded_images[0] ) ) ; i++ ) {
for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
sizeof ( embedded_images[0] ) ) ; i++ ) {
image = &embedded_images[i];
/* virt_to_user() cannot be used in a static