mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[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>
This commit is contained in:
@@ -175,6 +175,30 @@ int image_set_cmdline ( struct image *image, const char *cmdline ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user