diff options
author | Michael Brown | 2021-01-20 19:03:16 +0100 |
---|---|---|
committer | Michael Brown | 2021-01-22 19:34:47 +0100 |
commit | 99ac69b8a9a48207913e98ac6b357c029b0eef81 (patch) | |
tree | 22f88f44671cb1fc29fe5ac47b50b5fa54b34586 /src/core/image.c | |
parent | [build] Allow an initrd script to be provided via genfsimg (diff) | |
download | ipxe-99ac69b8a9a48207913e98ac6b357c029b0eef81.tar.gz ipxe-99ac69b8a9a48207913e98ac6b357c029b0eef81.tar.xz ipxe-99ac69b8a9a48207913e98ac6b357c029b0eef81.zip |
[image] Provide image_set_data()
Extract part of the logic in initrd_init() to a standalone function
image_set_data().
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/image.c')
-rw-r--r-- | src/core/image.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/image.c b/src/core/image.c index 078ce1bb..54b99802 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -176,6 +176,30 @@ int image_set_cmdline ( struct image *image, const char *cmdline ) { } /** + * Set image data + * + * @v image Image + * @v data Image data + * @v len Length of image data + * @ret rc Return status code + */ +int image_set_data ( struct image *image, userptr_t data, size_t len ) { + userptr_t new; + + /* (Re)allocate image data */ + new = urealloc ( image->data, len ); + if ( ! new ) + return -ENOMEM; + image->data = new; + + /* Copy in new image data */ + memcpy_user ( image->data, 0, data, 0, len ); + image->len = len; + + return 0; +} + +/** * Determine image type * * @v image Executable image |