[image] Add "imgextract" command for extracting archive images

Add the concept of extracting an image from an archive (which could be
a single-file archive such as a gzip-compressed file), along with an
"imgextract" command to expose this functionality to scripts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2021-05-06 13:11:31 +01:00
parent de4f31cdca
commit 5c9c8d2b9b
9 changed files with 326 additions and 0 deletions

View File

@@ -301,6 +301,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_png ( ERRFILE_IMAGE | 0x00070000 )
#define ERRFILE_der ( ERRFILE_IMAGE | 0x00080000 )
#define ERRFILE_pem ( ERRFILE_IMAGE | 0x00090000 )
#define ERRFILE_archive ( ERRFILE_IMAGE | 0x000a0000 )
#define ERRFILE_asn1 ( ERRFILE_OTHER | 0x00000000 )
#define ERRFILE_chap ( ERRFILE_OTHER | 0x00010000 )

View File

@@ -113,6 +113,14 @@ struct image_type {
*/
int ( * asn1 ) ( struct image *image, size_t offset,
struct asn1_cursor **cursor );
/**
* Extract archive image
*
* @v image Image
* @v extracted Extracted image
* @ret rc Return status code
*/
int ( * extract ) ( struct image *image, struct image *extracted );
};
/**
@@ -190,6 +198,8 @@ extern struct image * image_memory ( const char *name, userptr_t data,
extern int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf );
extern int image_asn1 ( struct image *image, size_t offset,
struct asn1_cursor **cursor );
extern int image_extract ( struct image *image, const char *name,
struct image **extracted );
/**
* Increment reference count on an image

View File

@@ -0,0 +1,16 @@
#ifndef _USR_IMGARCHIVE_H
#define _USR_IMGARCHIVE_H
/** @file
*
* Archive image management
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/image.h>
extern int imgextract ( struct image *image, const char *name );
#endif /* _USR_IMGARCHIVE_H */