diff options
author | Michael Brown <mcb30@etherboot.org> | 2007-06-28 17:55:29 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2007-06-28 17:55:29 +0100 |
commit | 4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56 (patch) | |
tree | 7bf42f686105cb65dc79bad8b789deca22f01d6e /src/usr/imgmgmt.c | |
parent | 7d6e4aab6fd9d53d9118a7913c44b6c568117597 (diff) | |
download | ipxe-4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56.tar.gz |
Quick hack to get image booting working again
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r-- | src/usr/imgmgmt.c | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 9fe2e1493..df2519552 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -21,8 +21,9 @@ #include <stdio.h> #include <errno.h> #include <gpxe/image.h> -#include <gpxe/umalloc.h> -#include <gpxe/download.h> +#include <gpxe/downloader.h> +#include <gpxe/monojob.h> +#include <gpxe/open.h> #include <usr/imgmgmt.h> /** @file @@ -31,6 +32,18 @@ * */ +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 * @@ -39,39 +52,18 @@ * @ret new_image Newly created image * @ret rc Return status code */ -int imgfetch ( const char *uri_string, const char *name, - struct image **new_image ) { - struct image *image; - struct async async; +int imgfetch ( struct image *image, const char *uri_string, int load ) { int rc; - /* Allocate new image */ - image = malloc ( sizeof ( *image ) ); - if ( ! image ) - return -ENOMEM; - memset ( image, 0, sizeof ( *image ) ); + printf ( "uri_string = %s\n", uri_string ); - /* Fill in image name */ - if ( name ) - strncpy ( image->name, name, ( sizeof ( image->name ) - 1 ) ); + if ( ( rc = create_downloader ( &monojob, image, + ( load ? imgfetch_autoload : + register_image ), + LOCATION_URI_STRING, + uri_string ) ) == 0 ) + rc = monojob_wait(); - /* Download the file */ - if ( ( rc = async_block_progress ( &async, - start_download ( uri_string, &async, - &image->data, - &image->len )))!=0) - goto err; - - /* Register the image */ - if ( ( rc = register_image ( image ) ) != 0 ) - goto err; - - *new_image = image; - return 0; - - err: - ufree ( image->data ); - free ( image ); return rc; } @@ -88,10 +80,6 @@ int imgload ( struct image *image ) { if ( ( rc = image_autoload ( image ) ) != 0 ) return rc; - /* If we succeed, move the image to the start of the list */ -#warning "No longer exists" - // promote_image ( image ); - return 0; } @@ -144,6 +132,4 @@ void imgstat ( struct image *image ) { */ void imgfree ( struct image *image ) { unregister_image ( image ); - ufree ( image->data ); - free ( image ); } |