diff options
author | Michael Brown | 2007-08-02 21:18:32 +0200 |
---|---|---|
committer | Michael Brown | 2007-08-02 21:18:32 +0200 |
commit | d4947c05b27449b4320179d57028a0542fd1394f (patch) | |
tree | dc9732c85f3904d04c2d7addf511c01c99dfb7fd /src/usr | |
parent | Allowed zero-cost enforced ordering of features in startup banner (diff) | |
download | ipxe-d4947c05b27449b4320179d57028a0542fd1394f.tar.gz ipxe-d4947c05b27449b4320179d57028a0542fd1394f.tar.xz ipxe-d4947c05b27449b4320179d57028a0542fd1394f.zip |
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')
-rw-r--r-- | src/usr/autoboot.c | 16 | ||||
-rw-r--r-- | src/usr/imgmgmt.c | 34 |
2 files changed, 17 insertions, 33 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 53283d18..b5f4e9b2 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -60,25 +60,15 @@ static int boot_filename ( const char *filename ) { printf ( "Out of memory\n" ); return -ENOMEM; } - if ( ( rc = imgfetch ( image, filename, 0 ) ) != 0 ) { + if ( ( rc = imgfetch ( image, filename, + register_and_autoexec_image ) ) != 0 ) { printf ( "Could not retrieve %s: %s\n", filename, strerror ( rc ) ); image_put ( image ); return rc; } - if ( ( rc = imgload ( image ) ) != 0 ) { - printf ( "Could not load %s: %s\n", image->name, - strerror ( rc ) ); - image_put ( image ); - return rc; - } - if ( ( rc = imgexec ( image ) ) != 0 ) { - printf ( "Could not execute %s: %s\n", image->name, - strerror ( rc ) ); - image_put ( image ); - return rc; - } + image_put ( image ); return 0; } diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index ab4897bf..0a77469a 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" ); } |