summaryrefslogtreecommitdiffstats
path: root/src/usr/imgmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2007-06-28 18:55:29 +0200
committerMichael Brown2007-06-28 18:55:29 +0200
commit4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56 (patch)
tree7bf42f686105cb65dc79bad8b789deca22f01d6e /src/usr/imgmgmt.c
parentUse monojob and dhcp_configure_netdev(). (diff)
downloadipxe-4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56.tar.gz
ipxe-4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56.tar.xz
ipxe-4b08f4cf0f06b3345466f7d5d7ef4c04d45ecc56.zip
Quick hack to get image booting working again
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r--src/usr/imgmgmt.c60
1 files changed, 23 insertions, 37 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 9fe2e149..df251955 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 );
}