size_t offset;
size_t pad_len;
- /* Do not include kernel image itself as an initrd */
- if ( initrd == image )
- return 0;
-
/* Create cpio header for non-prebuilt images */
offset = cpio_header ( initrd, &cpio );
/* Calculate total loaded length of initrds */
for_each_image ( initrd ) {
- /* Skip kernel */
- if ( initrd == image )
- continue;
-
/* Calculate length */
len += bzimage_load_initrd ( image, initrd, UNULL );
len = bzimage_align ( len );
break;
}
- /* Do not include kernel image itself as a module */
- if ( module_image == image )
- continue;
-
/* Page-align the module */
start = ( ( start + 0xfff ) & ~0xfff );
/* 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.
+ /* Take out a temporary reference to the image, so that it
+ * does not get freed when temporarily unregistered.
*/
current_image = image_get ( image );
/* Record boot attempt */
syslog ( LOG_NOTICE, "Executing \"%s\"\n", image->name );
+ /* Temporarily unregister the image during its execution */
+ unregister_image ( image );
+
/* Try executing the image */
if ( ( rc = image->type->exec ( image ) ) != 0 ) {
DBGC ( image, "IMAGE %s could not execute: %s\n",
image->name, strerror ( rc ) );
}
+ /* Re-register image (unless due to be replaced) */
+ if ( ! image->replacement )
+ register_image ( image );
+
/* Pick up replacement image before we drop the original
* image's temporary reference. The replacement image must
* already be registered, so we don't need to hold a temporary
size_t saved_offset;
int rc;
- /* Temporarily de-register image, so that a "boot" command
- * doesn't throw us into an execution loop.
- */
- unregister_image ( image );
-
/* Preserve state of any currently-running script */
saved_offset = script_offset;
/* Restore saved state */
script_offset = saved_offset;
- /* Re-register image (unless we have been replaced) */
- if ( ! image->replacement )
- register_image ( image );
-
return rc;
}
len = 0;
for_each_image ( image ) {
- /* Ignore currently executing image */
- if ( image == current_image )
- continue;
-
/* Pad to alignment boundary */
pad_len = ( ( -reader->pos ) & ( INITRD_ALIGN - 1 ) );
if ( pad_len ) {
* instance only if the initrd is non-empty, since Linux does
* not gracefully handle a zero-length initrd.
*/
- load = ( list_is_singular ( &images ) ? NULL : &efi_file_initrd.load );
+ load = ( have_images() ? &efi_file_initrd.load : NULL );
if ( ( rc = efi_file_path_install ( &efi_file_initrd_path.vendor.Header,
load ) ) != 0 ) {
goto err_initrd;