summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/image.c14
-rw-r--r--src/image/script.c19
-rw-r--r--src/usr/imgmgmt.c3
3 files changed, 18 insertions, 18 deletions
diff --git a/src/core/image.c b/src/core/image.c
index e270540a..08a129ff 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -107,20 +107,6 @@ void unregister_image ( struct image *image ) {
}
/**
- * Move image to start of list of registered images
- *
- * @v image Executable/loadable image
- *
- * Move the image to the start of the image list. This makes it
- * easier to keep track of which of the images marked as loaded is
- * likely to still be valid.
- */
-void promote_image ( struct image *image ) {
- list_del ( &image->list );
- list_add ( &image->list, &images );
-}
-
-/**
* Find image by name
*
* @v name Image name
diff --git a/src/image/script.c b/src/image/script.c
index 84432435..8e511d21 100644
--- a/src/image/script.c
+++ b/src/image/script.c
@@ -44,6 +44,13 @@ static int script_exec ( struct image *image ) {
char *eol;
int rc;
+ /* Temporarily de-register image, so that a "boot" command
+ * doesn't throw us into an execution loop. Hold a reference
+ * to avoid the image's being freed.
+ */
+ image_get ( image );
+ unregister_image ( image );
+
while ( offset < image->len ) {
/* Read up to cmdbuf bytes from script into buffer */
@@ -60,7 +67,8 @@ static int script_exec ( struct image *image ) {
if ( ! eol ) {
DBG ( "Script line too long (max %d bytes)\n",
sizeof ( cmdbuf ) );
- return -ENOEXEC;
+ rc = -ENOEXEC;
+ goto done;
}
/* Mark end of line and execute command */
@@ -69,14 +77,19 @@ static int script_exec ( struct image *image ) {
if ( ( rc = system ( cmdbuf ) ) != 0 ) {
DBG ( "Command \"%s\" exited with status %d\n",
cmdbuf, rc );
- return rc;
+ goto done;
}
/* Move to next line */
offset += ( ( eol - cmdbuf ) + 1 );
}
- return 0;
+ rc = 0;
+ done:
+ /* Re-register image and return */
+ register_image ( image );
+ image_put ( image );
+ return rc;
}
/**
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 28801fe8..9fe2e149 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -89,7 +89,8 @@ int imgload ( struct image *image ) {
return rc;
/* If we succeed, move the image to the start of the list */
- promote_image ( image );
+#warning "No longer exists"
+ // promote_image ( image );
return 0;
}