diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-07-08 03:50:44 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-07-08 03:50:44 +0100 |
commit | 0436e417bcb9acd658b73a65172474a71eb12b83 (patch) | |
tree | f943d7ba1a70016b8a2d8246b6d60a599c68e73a /src/usr/imgmgmt.c | |
parent | 4f2861a3767700f3acb6320b10a67ea983f9ba0c (diff) | |
download | ipxe-0436e417bcb9acd658b73a65172474a71eb12b83.zip ipxe-0436e417bcb9acd658b73a65172474a71eb12b83.tar.gz ipxe-0436e417bcb9acd658b73a65172474a71eb12b83.tar.bz2 |
[image] Fail "imgexec"/"boot" if the image to execute is ambiguous
If there is more than one loaded image, refuse to automatically select
the image to execute. There are at least two possible cases, with
different "correct" answers:
1. User loads image A by mistake, then loads image B and types "boot".
User wants to execute image B.
2. User loads image A, then loads image B (which patches image A), then
types "boot". User wants to execute image A.
If a user actually wants to load multiple images, they must explicitly
specify which image is to be executed.
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r-- | src/usr/imgmgmt.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index bead486..be153f8 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -86,19 +86,23 @@ int imgexec ( struct image *image ) { } /** - * Identify the first loaded image + * Identify the only loaded image * - * @ret image Image, or NULL + * @ret image Image, or NULL if 0 or >1 images are loaded */ struct image * imgautoselect ( void ) { struct image *image; + struct image *selected_image = NULL; + int flagged_images = 0; for_each_image ( image ) { - if ( image->flags & IMAGE_LOADED ) - return image; + if ( image->flags & IMAGE_LOADED ) { + selected_image = image; + flagged_images++; + } } - return NULL; + return ( ( flagged_images == 1 ) ? selected_image : NULL ); } /** |