mirror of
https://github.com/ipxe/ipxe
synced 2025-12-27 01:52:39 +03:00
Allow images to hold references to the originating URI.
Some shuffling around of the image management code; this needs tidying up.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user