From 2876197306df09f003024784feb197d7ef14b0f8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 12 Jan 2007 07:32:46 +0000 Subject: Allow "imgexec" with no arguments to boot the file that was loaded with "kernel". --- src/hci/commands/image_cmd.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/hci/commands/image_cmd.c') diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 0dc16557..8055f686 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -304,7 +304,7 @@ static int imgexec_exec ( int argc, char **argv ) { { NULL, 0, NULL, 0 }, }; struct image *image; - const char *name; + const char *name = NULL; int c; int rc; @@ -320,19 +320,29 @@ static int imgexec_exec ( int argc, char **argv ) { } } - /* Need exactly one image name */ - if ( optind != ( argc - 1 ) ) { + /* Need no more than one image name */ + if ( optind != argc ) + name = argv[optind++]; + if ( optind != argc ) { imgexec_syntax ( argv ); return 1; } - name = argv[optind]; /* Execute specified image */ - image = find_image ( name ); - if ( ! image ) { - printf ( "No such image: %s\n", name ); - return 1; + if ( name ) { + image = find_image ( name ); + if ( ! image ) { + printf ( "No such image: %s\n", name ); + return 1; + } + } else { + image = imgautoselect(); + if ( ! image ) { + printf ( "No loaded images\n" ); + return 1; + } } + if ( ( rc = imgexec ( image ) ) != 0 ) { printf ( "Could not execute %s: %s\n", name, strerror ( rc ) ); return 1; @@ -448,7 +458,6 @@ static int imgfree_exec ( int argc, char **argv ) { return 0; } - /** Image management commands */ struct command image_commands[] __command = { { -- cgit v1.2.3-55-g7522