mirror of https://github.com/ipxe/ipxe.git
[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>pull/1/head
parent
254bdc2a8e
commit
f8448735b0
|
@ -499,9 +499,9 @@ static int imgstat_exec ( int argc, char **argv ) {
|
||||||
*/
|
*/
|
||||||
static void imgfree_syntax ( char **argv ) {
|
static void imgfree_syntax ( char **argv ) {
|
||||||
printf ( "Usage:\n"
|
printf ( "Usage:\n"
|
||||||
" %s\n"
|
" %s [<image name>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Free all executable/loadable images\n",
|
"Free one or all executable/loadable images\n",
|
||||||
argv[0] );
|
argv[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,6 +519,7 @@ static int imgfree_exec ( int argc, char **argv ) {
|
||||||
};
|
};
|
||||||
struct image *image;
|
struct image *image;
|
||||||
struct image *tmp;
|
struct image *tmp;
|
||||||
|
const char *name = NULL;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Parse options */
|
/* Parse options */
|
||||||
|
@ -533,16 +534,28 @@ 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 ) {
|
if ( optind != argc ) {
|
||||||
imgfree_syntax ( argv );
|
imgfree_syntax ( argv );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
/* Free all images */
|
||||||
list_for_each_entry_safe ( image, tmp, &images, list ) {
|
list_for_each_entry_safe ( image, tmp, &images, list ) {
|
||||||
imgfree ( image );
|
imgfree ( image );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue