Allow images to hold references to the originating URI.

Some shuffling around of the image management code; this needs tidying up.
This commit is contained in:
Michael Brown
2007-08-02 20:18:32 +01:00
parent 9fd6a0418f
commit d4947c05b2
9 changed files with 189 additions and 69 deletions

View File

@@ -13,25 +13,26 @@
#include <gpxe/uaccess.h>
#include <gpxe/refcnt.h>
struct uri;
struct image_type;
/** Maximum length of a command line */
#define CMDLINE_MAX 128
/** An executable or loadable image */
struct image {
/** Reference count */
struct refcnt refcnt;
/** Name */
char name[16];
/** List of registered images */
struct list_head list;
/** URI of image */
struct uri *uri;
/** Name */
char name[16];
/** Flags */
unsigned int flags;
/** Command line to pass to image */
char cmdline[CMDLINE_MAX];
char *cmdline;
/** Raw file image */
userptr_t data;
/** Length of raw file image */
@@ -114,6 +115,8 @@ extern struct list_head images;
list_for_each_entry ( (image), &images, list )
extern struct image * alloc_image ( void );
extern int image_set_uri ( struct image *image, struct uri *uri );
extern int image_set_cmdline ( struct image *image, const char *cmdline );
extern int register_image ( struct image *image );
extern void unregister_image ( struct image *image );
extern void promote_image ( struct image *image );
@@ -121,6 +124,8 @@ struct image * find_image ( const char *name );
extern int image_load ( struct image *image );
extern int image_autoload ( struct image *image );
extern int image_exec ( struct image *image );
extern int register_and_autoload_image ( struct image *image );
extern int register_and_autoexec_image ( struct image *image );
/**
* Increment reference count on an image
@@ -142,4 +147,16 @@ static inline void image_put ( struct image *image ) {
ref_put ( &image->refcnt );
}
/**
* Set image name
*
* @v image Image
* @v name New image name
* @ret rc Return status code
*/
static inline int image_set_name ( struct image *image, const char *name ) {
strncpy ( image->name, name, ( sizeof ( image->name ) - 1 ) );
return 0;
}
#endif /* _GPXE_IMAGE_H */

View File

@@ -94,7 +94,7 @@ static inline int uri_has_absolute_path ( struct uri *uri ) {
* @v uri URI
* @ret has_relative_path URI has a relative path
*
* An relative path begins with something other than a '/'. Note that
* A relative path begins with something other than a '/'. Note that
* this is a separate concept from a relative URI. Note also that a
* URI may not have a path at all.
*/
@@ -117,7 +117,7 @@ uri_get ( struct uri *uri ) {
/**
* Decrement URI reference count
*
* @v uri URI
* @v uri URI, or NULL
*/
static inline __attribute__ (( always_inline )) void
uri_put ( struct uri *uri ) {

View File

@@ -9,7 +9,8 @@
struct image;
extern int imgfetch ( struct image *image, const char *filename, int load );
extern int imgfetch ( struct image *image, const char *uri_string,
int ( * image_register ) ( struct image *image ) );
extern int imgload ( struct image *image );
extern int imgexec ( struct image *image );
extern struct image * imgautoselect ( void );