iPXE
|
Executable images. More...
Go to the source code of this file.
Data Structures | |
struct | image |
An executable image. More... | |
struct | image_type |
An executable image type. More... | |
Macros | |
#define | IMAGE_REGISTERED 0x00001 |
Image is registered. More... | |
#define | IMAGE_SELECTED 0x0002 |
Image is selected for execution. More... | |
#define | IMAGE_TRUSTED 0x0004 |
Image is trusted. More... | |
#define | IMAGE_AUTO_UNREGISTER 0x0008 |
Image will be automatically unregistered after execution. More... | |
#define | PROBE_MULTIBOOT 01 |
Multiboot image probe priority. More... | |
#define | PROBE_NORMAL 02 |
Normal image probe priority. More... | |
#define | PROBE_PXE 03 |
PXE image probe priority. More... | |
#define | IMAGE_TYPES __table ( struct image_type, "image_types" ) |
Executable image type table. More... | |
#define | __image_type(probe_order) __table_entry ( IMAGE_TYPES, probe_order ) |
An executable image type. More... | |
#define | for_each_image(image) list_for_each_entry ( (image), &images, list ) |
Iterate over all registered images. More... | |
#define | for_each_image_safe(image, tmp) list_for_each_entry_safe ( (image), (tmp), &images, list ) |
Iterate over all registered images, safe against deletion. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | have_images (void) |
Test for existence of images. More... | |
static struct image * | first_image (void) |
Retrieve first image. More... | |
struct image * | alloc_image (struct uri *uri) |
Allocate executable image. More... | |
int | image_set_uri (struct image *image, struct uri *uri) |
Set image URI. More... | |
int | image_set_name (struct image *image, const char *name) |
Set image name. More... | |
int | image_set_cmdline (struct image *image, const char *cmdline) |
Set image command line. More... | |
int | image_set_len (struct image *image, size_t len) |
Set image length. More... | |
int | image_set_data (struct image *image, userptr_t data, size_t len) |
Set image data. More... | |
int | register_image (struct image *image) |
Register executable image. More... | |
void | unregister_image (struct image *image) |
Unregister executable image. More... | |
struct image * | find_image (const char *name) |
Find image by name. More... | |
int | image_exec (struct image *image) |
Execute image. More... | |
int | image_replace (struct image *replacement) |
Set replacement image. More... | |
int | image_select (struct image *image) |
Select image for execution. More... | |
struct image * | image_find_selected (void) |
Find selected image. More... | |
int | image_set_trust (int require_trusted, int permanent) |
Change image trust requirement. More... | |
struct image * | image_memory (const char *name, userptr_t data, size_t len) |
Create registered image from block of memory. More... | |
int | image_pixbuf (struct image *image, struct pixel_buffer **pixbuf) |
Create pixel buffer from image. More... | |
int | image_asn1 (struct image *image, size_t offset, struct asn1_cursor **cursor) |
Extract ASN.1 object from image. More... | |
int | image_extract (struct image *image, const char *name, struct image **extracted) |
Extract archive image. More... | |
int | image_extract_exec (struct image *image) |
Extract and execute image. More... | |
static struct image * | image_get (struct image *image) |
Increment reference count on an image. More... | |
static void | image_put (struct image *image) |
Decrement reference count on an image. More... | |
static void | image_clear_cmdline (struct image *image) |
Clear image command line. More... | |
static void | image_trust (struct image *image) |
Set image as trusted. More... | |
static void | image_untrust (struct image *image) |
Set image as untrusted. More... | |
Variables | |
struct image | __attribute__ |
struct list_head | images |
List of registered images. More... | |
struct image * | current_image |
Currently-executing image. More... | |
Executable images.
Definition in file image.h.
#define IMAGE_SELECTED 0x0002 |
#define IMAGE_AUTO_UNREGISTER 0x0008 |
#define PROBE_MULTIBOOT 01 |
#define PROBE_PXE 03 |
#define IMAGE_TYPES __table ( struct image_type, "image_types" ) |
#define __image_type | ( | probe_order | ) | __table_entry ( IMAGE_TYPES, probe_order ) |
#define for_each_image | ( | image | ) | list_for_each_entry ( (image), &images, list ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Test for existence of images.
existence | Some images exist |
Definition at line 169 of file image.h.
References images, and list_empty.
|
inlinestatic |
Retrieve first image.
image | Image, or NULL |
Definition at line 178 of file image.h.
References images, image::list, and list_first_entry.
Referenced by ipxe().
Allocate executable image.
uri | URI, or NULL |
image | Executable image |
Definition at line 90 of file image.c.
References free_image(), image_put(), image_set_uri(), NULL, rc, ref_init, image::refcnt, and zalloc().
Referenced by image_extract(), image_memory(), and imgdownload().
Set image URI.
image | Image |
uri | New image URI |
rc | Return status code |
Definition at line 119 of file image.c.
References basename(), image_set_name(), image::name, name, uri::path, rc, image::uri, uri_get(), and uri_put().
Referenced by alloc_image(), and downloader_vredirect().
int image_set_name | ( | struct image * | image, |
const char * | name | ||
) |
Set image name.
image | Image |
name | New image name |
rc | Return status code |
Definition at line 144 of file image.c.
References ENOMEM, free, image::name, name, and strdup().
Referenced by image_extract(), image_memory(), image_set_uri(), imgsingle_exec(), and register_image().
int image_set_cmdline | ( | struct image * | image, |
const char * | cmdline | ||
) |
Set image command line.
image | Image |
cmdline | New image command line, or NULL |
rc | Return status code |
Definition at line 166 of file image.c.
References cmdline, image::cmdline, ENOMEM, free, NULL, and strdup().
Referenced by image_clear_cmdline(), image_extract_exec(), and imgsingle_exec().
Set image length.
image | Image |
len | Length of image data |
rc | Return status code |
Definition at line 185 of file image.c.
References image::data, ENOMEM, len, image::len, and urealloc().
Referenced by gzip_extract(), image_set_data(), and zlib_deflate().
Set image data.
image | Image |
data | Image data |
len | Length of image data |
rc | Return status code |
Definition at line 206 of file image.c.
References data, image::data, image_set_len(), len, memcpy_user(), and rc.
Referenced by image_memory().
int register_image | ( | struct image * | image | ) |
Register executable image.
image | Executable image |
rc | Return status code |
Definition at line 251 of file image.c.
References image::data, DBGC, image::flags, image_find_selected(), image_get(), image_probe(), IMAGE_REGISTERED, IMAGE_SELECTED, image_set_name(), images, image::len, image::list, list_add_tail, image::name, name, rc, snprintf(), image::type, and user_to_phys().
Referenced by asn1_okx(), cmdline_init(), embedded_init(), image_extract(), image_memory(), imgdownload(), pixbuf_okx(), script_exec(), and test_init().
void unregister_image | ( | struct image * | image | ) |
Unregister executable image.
image | Executable image |
Definition at line 293 of file image.c.
References DBGC, image::flags, image_put(), IMAGE_REGISTERED, image::list, list_del, and image::name.
Referenced by asn1_okx(), bzimage_exec(), cert_exec(), com32_exec_loop(), comboot_exec_loop(), console_exec(), gzip_okx(), image_exec(), image_extract(), image_extract_exec(), imgextract_exec(), imgfree_exec(), imgverify_exec(), pixbuf_okx(), script_exec(), and zlib_okx().
struct image* find_image | ( | const char * | name | ) |
Find image by name.
name | Image name |
image | Executable image, or NULL |
Definition at line 311 of file image.c.
References images, image::list, list_for_each_entry, image::name, name, NULL, and strcmp().
Referenced by imgacquire(), and imgmulti_exec().
int image_exec | ( | struct image * | image | ) |
Execute image.
image | Executable image |
rc | Return status code |
The image must already be registered. Note that executing an image may cause it to unregister itself. The caller must therefore assume that the image pointer becomes invalid.
Definition at line 332 of file image.c.
References assert(), churi(), current_image, cwuri, DBGC, EACCES_UNTRUSTED, ENOEXEC, image_type::exec, image::flags, IMAGE_AUTO_UNREGISTER, image_exec(), image_get(), image_put(), IMAGE_REGISTERED, IMAGE_TRUSTED, LOG_ERR, LOG_NOTICE, image::name, NULL, rc, image::replacement, require_trusted_images, strerror(), syslog, image::type, unregister_image(), image::uri, uri_get(), and uri_put().
Referenced by image_exec(), image_extract_exec(), imgexec(), ipxe(), and uriboot().
int image_replace | ( | struct image * | replacement | ) |
Set replacement image.
replacement | Replacement image |
rc | Return status code |
The replacement image must already be registered, and must remain registered until the currently-executing image returns.
Definition at line 437 of file image.c.
References assert(), current_image, DBGC, ENOEXEC, ENOTTY, image_type::exec, image::flags, image_get(), image_put(), IMAGE_REGISTERED, image::name, rc, image::replacement, strerror(), and image::type.
Referenced by comboot_fetch_kernel(), and imgexec().
int image_select | ( | struct image * | image | ) |
Select image for execution.
image | Executable image |
rc | Return status code |
Definition at line 473 of file image.c.
References ENOEXEC, image_type::exec, image::flags, for_each_image, IMAGE_SELECTED, tmp, and image::type.
Referenced by embedded_init(), and imgselect().
struct image* image_find_selected | ( | void | ) |
Find selected image.
image | Executable image, or NULL |
Definition at line 495 of file image.c.
References image::flags, for_each_image, IMAGE_SELECTED, and NULL.
Referenced by imgsingle_exec(), and register_image().
int image_set_trust | ( | int | require_trusted, |
int | permanent | ||
) |
Change image trust requirement.
require_trusted | Require trusted images |
permanent | Make trust requirement permanent |
rc | Return status code |
Definition at line 512 of file image.c.
References EACCES_PERMANENT, require_trusted_images, and require_trusted_images_permanent.
Referenced by imgtrust_exec().
Create registered image from block of memory.
name | Name |
data | Image data |
len | Length |
image | Image, or NULL on error |
Definition at line 537 of file image.c.
References alloc_image(), data, ENOMEM, image_put(), image_set_data(), image_set_name(), len, name, NULL, rc, and register_image().
Referenced by efi_autoexec_startup(), gzip_okx(), imgmem(), initrd_init(), and zlib_okx().
int image_pixbuf | ( | struct image * | image, |
struct pixel_buffer ** | pixbuf | ||
) |
Create pixel buffer from image.
image | Image |
pixbuf | Pixel buffer to fill in |
rc | Return status code |
Definition at line 97 of file pixbuf.c.
References DBGC, ENOTSUP, image::name, image_type::pixbuf, rc, strerror(), and image::type.
Referenced by console_exec(), and pixbuf_okx().
int image_asn1 | ( | struct image * | image, |
size_t | offset, | ||
struct asn1_cursor ** | cursor | ||
) |
Extract ASN.1 object from image.
image | Image |
offset | Offset within image |
cursor | ASN.1 cursor to fill in |
next | Offset to next image, or negative error |
The caller is responsible for eventually calling free() on the allocated ASN.1 cursor.
Definition at line 854 of file asn1.c.
References image_type::asn1, assert(), DBGC, ENOTSUP, len, image::name, next, offset, rc, strerror(), and image::type.
Referenced by asn1_okx(), image_x509(), and imgverify().
Extract archive image.
image | Image |
name | Extracted image name |
extracted | Extracted image to fill in |
rc | Return status code |
Definition at line 44 of file archive.c.
References alloc_image(), DBGC, ENOMEM, ENOTSUP, image_type::extract, image::flags, image_put(), image_set_name(), image_trust(), IMAGE_TRUSTED, image::name, name, NULL, rc, register_image(), strerror(), strrchr(), image::type, unregister_image(), and image::uri.
Referenced by gzip_okx(), image_extract_exec(), imgextract(), and zlib_okx().
int image_extract_exec | ( | struct image * | image | ) |
Extract and execute image.
image | Image |
rc | Return status code |
Definition at line 110 of file archive.c.
References image::cmdline, image::flags, IMAGE_AUTO_UNREGISTER, image_exec(), image_extract(), image_set_cmdline(), NULL, rc, and unregister_image().
Increment reference count on an image.
image | Image |
image | Image |
Definition at line 211 of file image.h.
References ref_get, and image::refcnt.
Referenced by bzimage_exec(), create_downloader(), efi_file_open(), image_exec(), image_replace(), and register_image().
|
inlinestatic |
Decrement reference count on an image.
image | Image |
Definition at line 221 of file image.h.
References ref_put, and image::refcnt.
Referenced by alloc_image(), cmdline_init(), downloader_free(), efi_file_free(), free_image(), image_exec(), image_extract(), image_memory(), image_replace(), imgdownload(), and unregister_image().
|
inlinestatic |
Clear image command line.
image | Image |
Definition at line 230 of file image.h.
References image_set_cmdline(), and NULL.
|
inlinestatic |
Set image as trusted.
image | Image |
Definition at line 239 of file image.h.
References image::flags, and IMAGE_TRUSTED.
Referenced by embedded_init(), image_extract(), and imgverify().
|
inlinestatic |
Set image as untrusted.
image | Image |
Definition at line 248 of file image.h.
References image::flags, and IMAGE_TRUSTED.
Referenced by imgverify().
struct image __attribute__ |
struct list_head images |
List of registered images.
Definition at line 56 of file image.c.
Referenced by efi_file_find(), find_image(), first_image(), have_images(), initrd_dump(), initrd_reshuffle(), initrd_squash_high(), initrd_swap(), and register_image().
struct image* current_image |
Currently-executing image.
Definition at line 59 of file image.c.
Referenced by efi_file_read_initrd(), goto_exec(), image_exec(), and image_replace().