mirror of https://github.com/ipxe/ipxe.git
[image] Allow single-member archive images to be executed transparently
Provide image_extract_exec() as a helper method to allow single-member archive images (such as gzip compressed images) to be executed without an explicit "imgextract" step. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/373/head
parent
a6a8bb1a9a
commit
191f8825cb
|
|
@ -97,6 +97,36 @@ int image_extract ( struct image *image, const char *name,
|
||||||
return rc;
|
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() */
|
/* Drag in objects via image_extract() */
|
||||||
REQUIRING_SYMBOL ( image_extract );
|
REQUIRING_SYMBOL ( image_extract );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,4 +163,5 @@ struct image_type gzip_image_type __image_type ( PROBE_NORMAL ) = {
|
||||||
.name = "gzip",
|
.name = "gzip",
|
||||||
.probe = gzip_probe,
|
.probe = gzip_probe,
|
||||||
.extract = gzip_extract,
|
.extract = gzip_extract,
|
||||||
|
.exec = image_extract_exec,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -159,4 +159,5 @@ struct image_type zlib_image_type __image_type ( PROBE_NORMAL ) = {
|
||||||
.name = "zlib",
|
.name = "zlib",
|
||||||
.probe = zlib_probe,
|
.probe = zlib_probe,
|
||||||
.extract = zlib_extract,
|
.extract = zlib_extract,
|
||||||
|
.exec = image_extract_exec,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@ extern int image_asn1 ( struct image *image, size_t offset,
|
||||||
struct asn1_cursor **cursor );
|
struct asn1_cursor **cursor );
|
||||||
extern int image_extract ( struct image *image, const char *name,
|
extern int image_extract ( struct image *image, const char *name,
|
||||||
struct image **extracted );
|
struct image **extracted );
|
||||||
|
extern int image_extract_exec ( struct image *image );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment reference count on an image
|
* Increment reference count on an image
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue