aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/archive.c30
-rw-r--r--src/image/gzip.c1
-rw-r--r--src/image/zlib.c1
-rw-r--r--src/include/ipxe/image.h1
4 files changed, 33 insertions, 0 deletions
diff --git a/src/core/archive.c b/src/core/archive.c
index cd024bd..7ef86bd 100644
--- a/src/core/archive.c
+++ b/src/core/archive.c
@@ -97,6 +97,36 @@ int image_extract ( struct image *image, const char *name,
return rc;
}
+/**
+ * Extract and execute image
+ *
+ * @v image Image
+ * @ret rc Return status code
+ */
+int image_extract_exec ( struct image *image ) {
+ struct image *extracted;
+ int rc;
+
+ /* Extract image */
+ if ( ( rc = image_extract ( image, NULL, &extracted ) ) != 0 )
+ goto err_extract;
+
+ /* Set image command line */
+ if ( ( rc = image_set_cmdline ( extracted, image->cmdline ) ) != 0 )
+ goto err_set_cmdline;
+
+ /* Set auto-unregister flag */
+ extracted->flags |= IMAGE_AUTO_UNREGISTER;
+
+ /* Tail-recurse into extracted image */
+ return image_exec ( extracted );
+
+ err_set_cmdline:
+ unregister_image ( extracted );
+ err_extract:
+ return rc;
+}
+
/* Drag in objects via image_extract() */
REQUIRING_SYMBOL ( image_extract );
diff --git a/src/image/gzip.c b/src/image/gzip.c
index 4072813..98376e1 100644
--- a/src/image/gzip.c
+++ b/src/image/gzip.c
@@ -163,4 +163,5 @@ struct image_type gzip_image_type __image_type ( PROBE_NORMAL ) = {
.name = "gzip",
.probe = gzip_probe,
.extract = gzip_extract,
+ .exec = image_extract_exec,
};
diff --git a/src/image/zlib.c b/src/image/zlib.c
index bc27142..a42c47e 100644
--- a/src/image/zlib.c
+++ b/src/image/zlib.c
@@ -159,4 +159,5 @@ struct image_type zlib_image_type __image_type ( PROBE_NORMAL ) = {
.name = "zlib",
.probe = zlib_probe,
.extract = zlib_extract,
+ .exec = image_extract_exec,
};
diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h
index c6e723d..0a5a260 100644
--- a/src/include/ipxe/image.h
+++ b/src/include/ipxe/image.h
@@ -200,6 +200,7 @@ extern int image_asn1 ( struct image *image, size_t offset,
struct asn1_cursor **cursor );
extern int image_extract ( struct image *image, const char *name,
struct image **extracted );
+extern int image_extract_exec ( struct image *image );
/**
* Increment reference count on an image