diff options
author | Michael Brown <mcb30@etherboot.org> | 2007-08-02 20:18:32 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2007-08-02 20:18:32 +0100 |
commit | d4947c05b27449b4320179d57028a0542fd1394f (patch) | |
tree | dc9732c85f3904d04c2d7addf511c01c99dfb7fd /src/usr/imgmgmt.c | |
parent | 9fd6a0418f38461d6d87f2c88785028d65fd6a1c (diff) | |
download | ipxe-d4947c05b27449b4320179d57028a0542fd1394f.tar.gz |
Allow images to hold references to the originating URI.
Some shuffling around of the image management code; this needs tidying up.
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r-- | src/usr/imgmgmt.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index ab4897bf3..0a77469a9 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -24,6 +24,7 @@ #include <gpxe/downloader.h> #include <gpxe/monojob.h> #include <gpxe/open.h> +#include <gpxe/uri.h> #include <usr/imgmgmt.h> /** @file @@ -32,36 +33,29 @@ * */ -static int imgfetch_autoload ( struct image *image ) { - int rc; - - if ( ( rc = register_image ( image ) ) != 0 ) - return rc; - - if ( ( rc = image_autoload ( image ) ) != 0 ) - return rc; - - return 0; -} - /** * Fetch an image * * @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz") * @v name Name for image, or NULL - * @ret new_image Newly created image + * @v register_image Image registration routine * @ret rc Return status code */ -int imgfetch ( struct image *image, const char *uri_string, int load ) { +int imgfetch ( struct image *image, const char *uri_string, + int ( * image_register ) ( struct image *image ) ) { + struct uri *uri; int rc; - if ( ( rc = create_downloader ( &monojob, image, - ( load ? imgfetch_autoload : - register_image ), - LOCATION_URI_STRING, - uri_string ) ) == 0 ) + if ( ! ( uri = parse_uri ( uri_string ) ) ) + return -ENOMEM; + + image_set_uri ( image, uri ); + + if ( ( rc = create_downloader ( &monojob, image, image_register, + LOCATION_URI, uri ) ) == 0 ) rc = monojob_wait(); + uri_put ( uri ); return rc; } @@ -118,7 +112,7 @@ void imgstat ( struct image *image ) { printf ( " [%s]", image->type->name ); if ( image->flags & IMAGE_LOADED ) printf ( " [LOADED]" ); - if ( image->cmdline[0] ) + if ( image->cmdline ) printf ( " \"%s\"", image->cmdline ); printf ( "\n" ); } |