summaryrefslogtreecommitdiffstats
path: root/src/usr/imgmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2011-03-02 20:29:24 +0100
committerMichael Brown2011-03-02 20:29:24 +0100
commit3c9c27b8e68f51ee008cdbf0a57ad3ab7483b631 (patch)
tree44bd9071244c8f1daacfa805de0bb107f97002b3 /src/usr/imgmgmt.c
parent[int13] Automatically reopen underlying block device as needed (diff)
downloadipxe-3c9c27b8e68f51ee008cdbf0a57ad3ab7483b631.tar.gz
ipxe-3c9c27b8e68f51ee008cdbf0a57ad3ab7483b631.tar.xz
ipxe-3c9c27b8e68f51ee008cdbf0a57ad3ab7483b631.zip
[image] Allow download job to complete before acting upon image
Allow the monojob controlling the download to complete before calling register_image() and friends. This allows the trailing "ok" from monojob.c to be printed before the image starts executing (and possibly printing output of its own). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r--src/usr/imgmgmt.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index e958bc19..6b150353 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -40,11 +40,11 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
* @v image Image
* @v uri URI
- * @v image_register Action to take upon a successful download
+ * @v action Action to take upon a successful download
* @ret rc Return status code
*/
int imgdownload ( struct image *image, struct uri *uri,
- int ( * image_register ) ( struct image *image ) ) {
+ int ( * action ) ( struct image *image ) ) {
size_t len = ( unparse_uri ( NULL, 0, uri, URI_ALL ) + 1 );
char uri_string_redacted[len];
const char *password;
@@ -62,14 +62,18 @@ int imgdownload ( struct image *image, struct uri *uri,
uri->password = password;
/* Create downloader */
- if ( ( rc = create_downloader ( &monojob, image, image_register,
- LOCATION_URI, uri ) ) != 0 )
+ if ( ( rc = create_downloader ( &monojob, image, LOCATION_URI,
+ uri ) ) != 0 )
return rc;
/* Wait for download to complete */
if ( ( rc = monojob_wait ( uri_string_redacted ) ) != 0 )
return rc;
+ /* Act upon downloaded image */
+ if ( ( rc = action ( image ) ) != 0 )
+ return rc;
+
return 0;
}
@@ -78,18 +82,18 @@ int imgdownload ( struct image *image, struct uri *uri,
*
* @v image Image
* @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
- * @v image_register Action to take upon a successful fetch
+ * @v action Action to take upon a successful download
* @ret rc Return status code
*/
int imgfetch ( struct image *image, const char *uri_string,
- int ( * image_register ) ( struct image *image ) ) {
+ int ( * action ) ( struct image *image ) ) {
struct uri *uri;
int rc;
if ( ! ( uri = parse_uri ( uri_string ) ) )
return -ENOMEM;
- rc = imgdownload ( image, uri, image_register );
+ rc = imgdownload ( image, uri, action );
uri_put ( uri );
return rc;