47 #define EACCES_UNTRUSTED \ 48 __einfo_error ( EINFO_EACCES_UNTRUSTED ) 49 #define EINFO_EACCES_UNTRUSTED \ 50 __einfo_uniqify ( EINFO_EACCES, 0x01, "Untrusted image" ) 51 #define EACCES_PERMANENT \ 52 __einfo_error ( EINFO_EACCES_PERMANENT ) 53 #define EINFO_EACCES_PERMANENT \ 54 __einfo_uniqify ( EINFO_EACCES, 0x02, "Trust requirement is permanent" ) 287 static unsigned int imgindex = 0;
302 DBGC (
image,
"IMAGE %s at [%lx,%lx) registered\n",
379 struct image *saved_current_image;
381 struct uri *old_cwuri;
423 DBGC (
image,
"IMAGE %s could not execute: %s\n",
459 DBGC (
image,
"IMAGE %s replacing self with IMAGE %s\n",
513 DBGC (
image,
"IMAGE %s will replace self with IMAGE %s\n",
577 goto err_alloc_image;
619 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.
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.
userptr_t data
Raw file image.
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.
uint32_t next
Next descriptor address.
struct image * find_image(const char *name)
Find image by name.
#define ref_init(refcnt, free)
Initialise a reference counter.
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.
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
An executable image type.
struct image * image_memory(const char *name, userptr_t data, size_t len)
Create registered image from block of memory.
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.
static void free_image(struct refcnt *refcnt)
Free executable image.
#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)
struct image_tag current_image
uint32_t userptr_t
A pointer to a user buffer.
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.
#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.
userptr_t urealloc(userptr_t userptr, size_t new_size)
Reallocate external memory.
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.
int image_set_data(struct image *image, userptr_t 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.
static __always_inline void ufree(userptr_t userptr)
Free external memory.
const char * opaque
Opaque part.
#define ENOTTY
Inappropriate I/O control operation.
int strcmp(const char *first, const char *second)
Compare strings.
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.
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.
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
struct refcnt refcnt
Reference count.