summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2012-03-24 02:16:37 +0100
committerMichael Brown2012-03-25 00:12:04 +0100
commit1c127a696215bd75917c3ba836c2db11636b3ffb (patch)
treebd883060a15bfae71aef090481f9ea67d4fb43bc /src/include/ipxe
parent[build] Fix compilation under Cygwin (diff)
downloadipxe-1c127a696215bd75917c3ba836c2db11636b3ffb.tar.gz
ipxe-1c127a696215bd75917c3ba836c2db11636b3ffb.tar.xz
ipxe-1c127a696215bd75917c3ba836c2db11636b3ffb.zip
[image] Simplify image management commands and internal API
Remove the name, cmdline, and action parameters from imgdownload() and imgdownload_string(). These functions now simply download and return an image. Add the function imgacquire(), which will interpret a "name or URI string" parameter and return either an existing image or a newly downloaded image. Use imgacquire() to merge similar image-management commands that currently differ only by whether they take the name of an existing image or the URI of a new image to download. For example, "chain" and "imgexec" can now be merged. Extend imgstat and imgfree commands to take an optional list of images. Remove the arbitrary restriction on the length of image names. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/image.h19
-rw-r--r--src/include/ipxe/parseopt.h2
2 files changed, 10 insertions, 11 deletions
diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h
index 500b216ed..ac97137bd 100644
--- a/src/include/ipxe/image.h
+++ b/src/include/ipxe/image.h
@@ -29,7 +29,7 @@ struct image {
/** URI of image */
struct uri *uri;
/** Name */
- char name[16];
+ char *name;
/** Flags */
unsigned int flags;
@@ -122,6 +122,10 @@ extern struct image *current_image;
#define for_each_image( image ) \
list_for_each_entry ( (image), &images, list )
+/** Iterate over all registered images, safe against deletion */
+#define for_each_image_safe( image, tmp ) \
+ list_for_each_entry_safe ( (image), (tmp), &images, list )
+
/**
* Test for existence of images
*
@@ -140,8 +144,8 @@ static inline struct image * first_image ( void ) {
return list_first_entry ( &images, struct image, list );
}
-extern struct image * alloc_image ( void );
-extern void image_set_uri ( struct image *image, struct uri *uri );
+extern struct image * alloc_image ( struct uri *uri );
+extern int image_set_name ( struct image *image, const char *name );
extern int image_set_cmdline ( struct image *image, const char *cmdline );
extern int register_image ( struct image *image );
extern void unregister_image ( struct image *image );
@@ -174,15 +178,12 @@ static inline void image_put ( struct image *image ) {
}
/**
- * Set image name
+ * Clear image command line
*
* @v image Image
- * @v name New image name
- * @ret rc Return status code
*/
-static inline int image_set_name ( struct image *image, const char *name ) {
- strncpy ( image->name, name, ( sizeof ( image->name ) - 1 ) );
- return 0;
+static inline void image_clear_cmdline ( struct image *image ) {
+ image_set_cmdline ( image, NULL );
}
/**
diff --git a/src/include/ipxe/parseopt.h b/src/include/ipxe/parseopt.h
index 8c456a647..e54dac66e 100644
--- a/src/include/ipxe/parseopt.h
+++ b/src/include/ipxe/parseopt.h
@@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stddef.h>
struct net_device;
-struct image;
/** A command-line option descriptor */
struct option_descriptor {
@@ -117,7 +116,6 @@ struct command_descriptor {
extern int parse_string ( const char *text, const char **value );
extern int parse_integer ( const char *text, unsigned int *value );
extern int parse_netdev ( const char *text, struct net_device **netdev );
-extern int parse_image ( const char *text, struct image **image );
extern int parse_flag ( const char *text __unused, int *flag );
extern void print_usage ( struct command_descriptor *cmd, char **argv );
extern int reparse_options ( int argc, char **argv,