48 #define EACCES_UNTRUSTED \ 49 __einfo_error ( EINFO_EACCES_UNTRUSTED ) 50 #define EINFO_EACCES_UNTRUSTED \ 51 __einfo_uniqify ( EINFO_EACCES, 0x01, "Untrusted image" ) 52 #define EACCES_PERMANENT \ 53 __einfo_error ( EINFO_EACCES_PERMANENT ) 54 #define EINFO_EACCES_PERMANENT \ 55 __einfo_uniqify ( EINFO_EACCES, 0x02, "Trust requirement is permanent" ) 315 static unsigned int imgindex = 0;
337 DBGC (
image,
"IMAGE %s at [%lx,%lx) registered\n",
414 struct image *saved_current_image;
416 struct uri *old_cwuri;
458 DBGC (
image,
"IMAGE %s could not execute: %s\n",
498 DBGC (
image,
"IMAGE %s replacing self with IMAGE %s\n",
552 DBGC (
image,
"IMAGE %s will replace self with IMAGE %s\n",
617 goto err_alloc_image;
659 for ( search =
cmdline ; search ; search =
next ) {
#define IMAGE_TYPES
Executable image type table.
int image_set_trust(int require_trusted, int permanent)
Change image trust requirement.
static __always_inline void ufree(void *ptr)
Free external memory.
struct image_tag selected_image
static int require_trusted_images_permanent
Prevent changes to image trust requirement.
struct arbelprm_rc_send_wqe rc
int image_select(struct image *image)
Select image for execution.
int image_set_uri(struct image *image, struct uri *uri)
Set image URI.
static void uri_put(struct uri *uri)
Decrement URI reference count.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
char * strrchr(const char *src, int character)
Find rightmost character within a string.
struct image * find_image(const char *name)
Find image by name.
#define ref_init(refcnt, free)
Initialise a reference counter.
const void * data
Read-only data.
char * image_strip_suffix(struct image *image)
Strip dot suffix from image name, if present.
#define ENOEXEC
Exec format error.
struct image_type * type
Image type, if known.
uint32_t type
Operating system type.
static struct image * image_get(struct image *image)
Increment reference count on an image.
An executable image type.
struct image_tag selected_image __image_tag
Image selected for execution.
#define LOG_ERR
Error: error conditions.
Uniform Resource Identifiers.
struct image * image
Image (weak reference, nullified when image is freed)
#define IMAGE_AUTO_UNREGISTER
Image will be automatically unregistered after execution.
int(* exec)(struct image *image)
Execute image.
#define ENOTSUP
Operation not supported.
char * cmdline
Command line to pass to image.
A doubly-linked list entry (or list head)
int image_exec(struct image *image)
Execute image.
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
#define list_del(list)
Delete an entry from a list.
static int image_probe(struct image *image)
Determine image type.
char * strstr(const char *haystack, const char *needle)
Find substring.
#define ENOMEM
Not enough space.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void free_image(struct refcnt *refcnt)
Free executable image.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int count
Current reference count.
struct image_tag current_image
#define IMAGE_STATIC
Image is statically allocated.
void churi(struct uri *uri)
Change working URI.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Access to external ("user") memory.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
const char * path
Path (after URI decoding)
#define IMAGE_REGISTERED
Image is registered.
#define IMAGE_TAGS
Image tag table.
int register_image(struct image *image)
Register executable image.
#define for_each_image(image)
Iterate over all registered images.
char * strerror(int errno)
Retrieve string representation of error number.
char * basename(char *path)
Return base name from path.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
size_t len
Length of raw file image.
int image_replace(struct image *replacement)
Set replacement image.
struct list_head images
List of registered images.
int image_set_name(struct image *image, const char *name)
Set image name.
#define IMAGE_TRUSTED
Image is trusted.
char * strdup(const char *src)
Duplicate string.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
struct uri * uri
URI of image.
int isspace(int character)
Check to see if character is a space.
size_t strlen(const char *src)
Get length of string.
static void image_put(struct image *image)
Decrement reference count on an image.
uint32_t next
Next descriptor address.
struct image * image_memory(const char *name, const void *data, size_t len)
Create registered image from block of memory.
int image_set_data(struct image *image, const void *data, size_t len)
Set image data.
void unregister_image(struct image *image)
Unregister executable image.
int image_set_len(struct image *image, size_t len)
Set image length.
const char * opaque
Opaque part.
#define ENOTTY
Inappropriate I/O control operation.
int strcmp(const char *first, const char *second)
Compare strings.
void * rwdata
Writable data.
#define IMAGE_STATIC_NAME
Image name is statically allocated.
const char * image_argument(struct image *image, const char *key)
Find argument within image command line.
#define syslog(priority, fmt,...)
Write message to system log.
uint8_t data[48]
Additional event data.
struct image * replacement
Replacement image.
int image_set_cmdline(struct image *image, const char *cmdline)
Set image command line.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
A Uniform Resource Identifier.
void * urealloc(void *ptr, size_t new_size)
Reallocate external memory.
static int require_trusted_images
Current image trust requirement.
#define LIST_HEAD_INIT(list)
Initialise a static list head.
struct list_head list
List of registered images.
struct uri * cwuri
Current working URI.
static struct image * image_tag(struct image *image, struct image_tag *tag)
Tag image.
struct image * alloc_image(struct uri *uri)
Allocate executable image.
uint64_t tag
Identity tag.
#define NULL
NULL pointer (VOID *)
#define LOG_NOTICE
Notice: normal but significant conditions.
struct refcnt refcnt
Reference count.