diff options
author | Michael Brown | 2012-07-20 11:37:24 +0200 |
---|---|---|
committer | Michael Brown | 2012-07-20 13:44:40 +0200 |
commit | d3c660b6718c8d85b34d5c7ca8c4ed12659e1cc7 (patch) | |
tree | c2c20f097fc46b59a02a903186fc1f9c30fa89cc /src/hci | |
parent | [libc] Add missing wchar.h header (diff) | |
download | ipxe-d3c660b6718c8d85b34d5c7ca8c4ed12659e1cc7.tar.gz ipxe-d3c660b6718c8d85b34d5c7ca8c4ed12659e1cc7.tar.xz ipxe-d3c660b6718c8d85b34d5c7ca8c4ed12659e1cc7.zip |
[image] Add "--autofree" option
Allow images to be automatically freed after execution completes
(successfully or otherwise).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r-- | src/hci/commands/image_cmd.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 1ae33074..38d814cd 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -38,19 +38,24 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct imgsingle_options { /** Image name */ const char *name; + /** Free image after execution */ + int autofree; }; /** "img{single}" option list */ static struct option_descriptor imgsingle_opts[] = { OPTION_DESC ( "name", 'n', required_argument, struct imgsingle_options, name, parse_string ), + OPTION_DESC ( "autofree", 'a', no_argument, + struct imgsingle_options, autofree, parse_flag ), }; /** "img{single}" command descriptor */ static struct command_descriptor imgsingle_cmd = COMMAND_DESC ( struct imgsingle_options, imgsingle_opts, 1, MAX_ARGUMENTS, - "[--name <name>] <uri|image> [<arguments>...]" ); + "[--name <name>] [--autofree] " + "<uri|image> [<arguments>...]" ); /** An "img{single}" family command descriptor */ struct imgsingle_descriptor { @@ -134,6 +139,10 @@ static int imgsingle_exec ( int argc, char **argv, } } + /* Set the auto-unregister flag, if applicable */ + if ( opts.autofree ) + image->flags |= IMAGE_AUTO_UNREGISTER; + /* Carry out command action, if applicable */ if ( desc->action ) { if ( ( rc = desc->action ( image ) ) != 0 ) { @@ -160,7 +169,7 @@ static int imgsingle_exec ( int argc, char **argv, static struct command_descriptor imgfetch_cmd = COMMAND_DESC ( struct imgsingle_options, imgsingle_opts, 1, MAX_ARGUMENTS, - "[--name <name>] <uri> [<arguments>...]" ); + "[--name <name>] [--autofree] <uri> [<arguments>...]" ); /** "imgfetch" family command descriptor */ struct imgsingle_descriptor imgfetch_desc = { @@ -202,7 +211,7 @@ static int imgselect_exec ( int argc, char **argv ) { static struct command_descriptor imgexec_cmd = COMMAND_DESC ( struct imgsingle_options, imgsingle_opts, 0, MAX_ARGUMENTS, - "[--name <name>] [<uri|image> [<arguments>...]]" ); + "[--autofree] [<uri|image> [<arguments>...]]" ); /** "imgexec" family command descriptor */ struct imgsingle_descriptor imgexec_desc = { |