summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Oreman2009-06-16 20:46:13 +0200
committerMichael Brown2009-06-23 11:53:33 +0200
commitf8448735b09af59760eb10fa4c8e759274d0830c (patch)
tree064bc12f892ba751bf83ef946ff0ff2bf8b2ba2b
parent[netdevice] Adjust maximum link-layer header length for 802.11 (diff)
downloadipxe-f8448735b09af59760eb10fa4c8e759274d0830c.tar.gz
ipxe-f8448735b09af59760eb10fa4c8e759274d0830c.tar.xz
ipxe-f8448735b09af59760eb10fa4c8e759274d0830c.zip
[image] Modify imgfree command to accept an argument
This resolves potential difficulties occurring when more than one script is used. Total cost: 88 bytes uncompressed. Signed-off-by: Michael Brown <mcb30@etherboot.org>
-rw-r--r--src/hci/commands/image_cmd.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c
index 68f1e87d..33994b51 100644
--- a/src/hci/commands/image_cmd.c
+++ b/src/hci/commands/image_cmd.c
@@ -499,9 +499,9 @@ static int imgstat_exec ( int argc, char **argv ) {
*/
static void imgfree_syntax ( char **argv ) {
printf ( "Usage:\n"
- " %s\n"
+ " %s [<image name>]\n"
"\n"
- "Free all executable/loadable images\n",
+ "Free one or all executable/loadable images\n",
argv[0] );
}
@@ -519,6 +519,7 @@ static int imgfree_exec ( int argc, char **argv ) {
};
struct image *image;
struct image *tmp;
+ const char *name = NULL;
int c;
/* Parse options */
@@ -533,15 +534,27 @@ static int imgfree_exec ( int argc, char **argv ) {
}
}
- /* No arguments */
+ /* Need no more than one image name */
+ if ( optind != argc )
+ name = argv[optind++];
if ( optind != argc ) {
imgfree_syntax ( argv );
return 1;
}
- /* Free all images */
- list_for_each_entry_safe ( image, tmp, &images, list ) {
+ if ( name ) {
+ /* Free specified image (may leak) */
+ image = find_image ( name );
+ if ( ! image ) {
+ printf ( "No such image: %s\n", name );
+ return 1;
+ }
imgfree ( image );
+ } else {
+ /* Free all images */
+ list_for_each_entry_safe ( image, tmp, &images, list ) {
+ imgfree ( image );
+ }
}
return 0;
}