diff options
author | Michael Brown | 2011-03-09 14:38:56 +0100 |
---|---|---|
committer | Michael Brown | 2011-03-09 14:38:56 +0100 |
commit | ae92700fd4594afc50f057ccb07690567327e508 (patch) | |
tree | d7e588d813e7f50211350408cbc801d806878c6f /src/core/image.c | |
parent | [image] Move the register_and_{select|boot}_image() functions to imgmgmt.c (diff) | |
download | ipxe-ae92700fd4594afc50f057ccb07690567327e508.tar.gz ipxe-ae92700fd4594afc50f057ccb07690567327e508.tar.xz ipxe-ae92700fd4594afc50f057ccb07690567327e508.zip |
[image] Generalise "currently-running script" to "currently-running image"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/image.c')
-rw-r--r-- | src/core/image.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core/image.c b/src/core/image.c index afb647d2..d205768a 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -39,6 +39,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); /** List of registered images */ struct list_head images = LIST_HEAD_INIT ( images ); +/** Currently-executing image */ +struct image *current_image; + /** * Free executable image * @@ -200,6 +203,7 @@ int image_probe ( struct image *image ) { * @ret rc Return status code */ int image_exec ( struct image *image ) { + struct image *saved_current_image; struct image *replacement; struct uri *old_cwuri; int rc; @@ -212,11 +216,14 @@ int image_exec ( struct image *image ) { old_cwuri = uri_get ( cwuri ); churi ( image->uri ); + /* Preserve record of any currently-running image */ + saved_current_image = current_image; + /* Take out a temporary reference to the image. This allows * the image to unregister itself if necessary, without * automatically freeing itself. */ - image_get ( image ); + current_image = image_get ( image ); /* Try executing the image */ if ( ( rc = image->type->exec ( image ) ) != 0 ) { @@ -233,6 +240,9 @@ int image_exec ( struct image *image ) { /* Drop temporary reference to the original image */ image_put ( image ); + /* Restore previous currently-running image */ + current_image = saved_current_image; + /* Reset current working directory */ churi ( old_cwuri ); uri_put ( old_cwuri ); |