iPXE
image.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <stddef.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <ctype.h>
31 #include <errno.h>
32 #include <assert.h>
33 #include <libgen.h>
34 #include <syslog.h>
35 #include <ipxe/list.h>
36 #include <ipxe/uaccess.h>
37 #include <ipxe/umalloc.h>
38 #include <ipxe/uri.h>
39 #include <ipxe/image.h>
40 
41 /** @file
42  *
43  * Executable images
44  *
45  */
46 
47 /* Disambiguate the various error causes */
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" )
56 
57 /** List of registered images */
59 
60 /** Image selected for execution */
62  .name = "SELECTED",
63 };
64 
65 /** Currently-executing image */
67  .name = "CURRENT",
68 };
69 
70 /** Current image trust requirement */
71 static int require_trusted_images = 0;
72 
73 /** Prevent changes to image trust requirement */
75 
76 /**
77  * Free executable image
78  *
79  * @v refcnt Reference counter
80  *
81  * Image consumers must call image_put() rather than calling
82  * free_image() directly. This function is exposed for use only by
83  * static images.
84  */
85 void free_image ( struct refcnt *refcnt ) {
86  struct image *image = container_of ( refcnt, struct image, refcnt );
87  struct image_tag *tag;
88 
89  /* Sanity check: free_image() should not be called directly on
90  * dynamically allocated images.
91  */
92  assert ( refcnt->count < 0 );
93  DBGC ( image, "IMAGE %s freed\n", image->name );
94 
95  /* Clear any tag weak references */
97  if ( tag->image == image )
98  tag->image = NULL;
99  }
100 
101  /* Free dynamic allocations used by both static and dynamic images */
102  free ( image->cmdline );
103  uri_put ( image->uri );
105 
106  /* Free image name, if dynamically allocated */
107  if ( ! ( image->flags & IMAGE_STATIC_NAME ) )
108  free ( image->name );
109 
110  /* Free image data and image itself, if dynamically allocated */
111  if ( ! ( image->flags & IMAGE_STATIC ) ) {
112  ufree ( image->rwdata );
113  free ( image );
114  }
115 }
116 
117 /**
118  * Allocate executable image
119  *
120  * @v uri URI, or NULL
121  * @ret image Executable image
122  */
123 struct image * alloc_image ( struct uri *uri ) {
124  struct image *image;
125  int rc;
126 
127  /* Allocate image */
128  image = zalloc ( sizeof ( *image ) );
129  if ( ! image )
130  goto err_alloc;
131 
132  /* Initialise image */
134  if ( uri && ( ( rc = image_set_uri ( image, uri ) ) != 0 ) )
135  goto err_set_uri;
136 
137  return image;
138 
139  err_set_uri:
140  image_put ( image );
141  err_alloc:
142  return NULL;
143 }
144 
145 /**
146  * Set image URI
147  *
148  * @v image Image
149  * @v uri New image URI
150  * @ret rc Return status code
151  */
152 int image_set_uri ( struct image *image, struct uri *uri ) {
153  const char *name;
154  int rc;
155 
156  /* Set name, if image does not already have one */
157  if ( ! ( image->name && image->name[0] ) ) {
158  name = ( uri->path ? uri->path : uri->opaque );
159  if ( name ) {
160  name = basename ( ( char * ) name );
161  if ( ( rc = image_set_name ( image, name ) ) != 0 )
162  return rc;
163  }
164  }
165 
166  /* Update image URI */
167  uri_put ( image->uri );
168  image->uri = uri_get ( uri );
169 
170  return 0;
171 }
172 
173 /**
174  * Set image name
175  *
176  * @v image Image
177  * @v name New image name
178  * @ret rc Return status code
179  */
180 int image_set_name ( struct image *image, const char *name ) {
181  char *name_copy;
182 
183  /* Duplicate name */
184  name_copy = strdup ( name );
185  if ( ! name_copy )
186  return -ENOMEM;
187 
188  /* Free existing name, if not statically allocated */
189  if ( ! ( image->flags & IMAGE_STATIC_NAME ) )
190  free ( image->name );
191 
192  /* Replace existing name */
193  image->name = name_copy;
195 
196  return 0;
197 }
198 
199 /**
200  * Strip dot suffix from image name, if present
201  *
202  * @v image Image
203  * @ret sep Position of old dot separator, or NULL
204  */
205 char * image_strip_suffix ( struct image *image ) {
206  char *dot;
207 
208  /* Locate and strip suffix, if present */
209  if ( image->name &&
210  ( ( dot = strrchr ( image->name, '.' ) ) != NULL ) ) {
211  *dot = '\0';
212  return dot;
213  }
214 
215  return NULL;
216 }
217 
218 /**
219  * Set image command line
220  *
221  * @v image Image
222  * @v cmdline New image command line, or NULL
223  * @ret rc Return status code
224  */
225 int image_set_cmdline ( struct image *image, const char *cmdline ) {
226 
227  free ( image->cmdline );
228  image->cmdline = NULL;
229  if ( cmdline ) {
230  image->cmdline = strdup ( cmdline );
231  if ( ! image->cmdline )
232  return -ENOMEM;
233  }
234  return 0;
235 }
236 
237 /**
238  * Set image length
239  *
240  * @v image Image
241  * @v len Length of image data
242  * @ret rc Return status code
243  */
244 int image_set_len ( struct image *image, size_t len ) {
245  void *new;
246 
247  /* Refuse to reallocate static images */
248  if ( image->flags & IMAGE_STATIC )
249  return -ENOTTY;
250 
251  /* (Re)allocate image data */
252  new = urealloc ( image->rwdata, len );
253  if ( ! new )
254  return -ENOMEM;
255  image->rwdata = new;
256  image->len = len;
257 
258  return 0;
259 }
260 
261 /**
262  * Set image data
263  *
264  * @v image Image
265  * @v data Image data
266  * @v len Length of image data
267  * @ret rc Return status code
268  */
269 int image_set_data ( struct image *image, const void *data, size_t len ) {
270  int rc;
271 
272  /* Set image length */
273  if ( ( rc = image_set_len ( image, len ) ) != 0 )
274  return rc;
275 
276  /* Copy in new image data */
277  memcpy ( image->rwdata, data, len );
278 
279  return 0;
280 }
281 
282 /**
283  * Determine image type
284  *
285  * @v image Executable image
286  * @ret rc Return status code
287  */
288 static int image_probe ( struct image *image ) {
289  struct image_type *type;
290  int rc;
291 
292  /* Try each type in turn */
294  if ( ( rc = type->probe ( image ) ) == 0 ) {
295  image->type = type;
296  DBGC ( image, "IMAGE %s is %s\n",
297  image->name, type->name );
298  return 0;
299  }
300  DBGC ( image, "IMAGE %s is not %s: %s\n", image->name,
301  type->name, strerror ( rc ) );
302  }
303 
304  DBGC ( image, "IMAGE %s format not recognised\n", image->name );
305  return -ENOTSUP;
306 }
307 
308 /**
309  * Register executable image
310  *
311  * @v image Executable image
312  * @ret rc Return status code
313  */
314 int register_image ( struct image *image ) {
315  static unsigned int imgindex = 0;
316  char name[8]; /* "imgXXXX" */
317  int rc;
318 
319  /* Sanity checks */
320  if ( image->flags & IMAGE_STATIC ) {
321  assert ( ( image->name == NULL ) ||
322  ( image->flags & IMAGE_STATIC_NAME ) );
323  assert ( image->cmdline == NULL );
324  }
325 
326  /* Create image name if it doesn't already have one */
327  if ( ! image->name ) {
328  snprintf ( name, sizeof ( name ), "img%d", imgindex++ );
329  if ( ( rc = image_set_name ( image, name ) ) != 0 )
330  return rc;
331  }
332 
333  /* Add to image list */
334  image_get ( image );
336  list_add_tail ( &image->list, &images );
337  DBGC ( image, "IMAGE %s at [%lx,%lx) registered\n",
338  image->name, virt_to_phys ( image->data ),
339  ( virt_to_phys ( image->data ) + image->len ) );
340 
341  /* Try to detect image type, if applicable. Ignore failures,
342  * since we expect to handle some unrecognised images
343  * (e.g. kernel initrds, multiboot modules, random files
344  * provided via our EFI virtual filesystem, etc).
345  */
346  if ( ! image->type )
347  image_probe ( image );
348 
349  return 0;
350 }
351 
352 /**
353  * Unregister executable image
354  *
355  * @v image Executable image
356  */
357 void unregister_image ( struct image *image ) {
358 
359  /* Do nothing unless image is registered */
360  if ( ! ( image->flags & IMAGE_REGISTERED ) )
361  return;
362 
363  DBGC ( image, "IMAGE %s unregistered\n", image->name );
364  list_del ( &image->list );
366  image_put ( image );
367 }
368 
369 /**
370  * Find image by name
371  *
372  * @v name Image name
373  * @ret image Executable image, or NULL
374  */
375 struct image * find_image ( const char *name ) {
376  struct image *image;
377 
378  for_each_image ( image ) {
379  if ( strcmp ( image->name, name ) == 0 )
380  return image;
381  }
382 
383  return NULL;
384 }
385 
386 /**
387  * Find image by tag
388  *
389  * @v tag Image tag
390  * @ret image Executable image, or NULL
391  */
392 struct image * find_image_tag ( struct image_tag *tag ) {
393  struct image *image;
394 
395  for_each_image ( image ) {
396  if ( tag->image == image )
397  return image;
398  }
399 
400  return NULL;
401 }
402 
403 /**
404  * Execute image
405  *
406  * @v image Executable image
407  * @ret rc Return status code
408  *
409  * The image must already be registered. Note that executing an image
410  * may cause it to unregister itself. The caller must therefore
411  * assume that the image pointer becomes invalid.
412  */
413 int image_exec ( struct image *image ) {
414  struct image *saved_current_image;
415  struct image *replacement = NULL;
416  struct uri *old_cwuri;
417  int rc;
418 
419  /* Sanity check */
421 
422  /* Switch current working directory to be that of the image
423  * itself, if applicable
424  */
425  old_cwuri = uri_get ( cwuri );
426  if ( image->uri )
427  churi ( image->uri );
428 
429  /* Set as currently running image */
430  saved_current_image = image_tag ( image, &current_image );
431 
432  /* Take out a temporary reference to the image, so that it
433  * does not get freed when temporarily unregistered.
434  */
435  image_get ( image );
436 
437  /* Check that this image can be executed */
438  if ( ! ( image->type && image->type->exec ) ) {
439  rc = -ENOEXEC;
440  goto err;
441  }
442 
443  /* Check that image is trusted (if applicable) */
444  if ( require_trusted_images && ! ( image->flags & IMAGE_TRUSTED ) ) {
445  DBGC ( image, "IMAGE %s is not trusted\n", image->name );
446  rc = -EACCES_UNTRUSTED;
447  goto err;
448  }
449 
450  /* Record boot attempt */
451  syslog ( LOG_NOTICE, "Executing \"%s\"\n", image->name );
452 
453  /* Temporarily unregister the image during its execution */
455 
456  /* Try executing the image */
457  if ( ( rc = image->type->exec ( image ) ) != 0 ) {
458  DBGC ( image, "IMAGE %s could not execute: %s\n",
459  image->name, strerror ( rc ) );
460  /* Do not return yet; we still have clean-up to do */
461  }
462 
463  /* Record result of boot attempt */
464  if ( rc == 0 ) {
465  syslog ( LOG_NOTICE, "Execution of \"%s\" completed\n",
466  image->name );
467  } else {
468  syslog ( LOG_ERR, "Execution of \"%s\" failed: %s\n",
469  image->name, strerror ( rc ) );
470  }
471 
472  /* Re-register image (unless due to be replaced) */
473  if ( ! image->replacement )
474  register_image ( image );
475 
476  /* Pick up replacement image before we drop the original
477  * image's temporary reference. The replacement image must
478  * already be registered, so we don't need to hold a temporary
479  * reference (which would complicate the tail-recursion).
480  */
482  if ( replacement )
483  assert ( replacement->flags & IMAGE_REGISTERED );
484 
485  /* Clear any recorded replacement image */
488 
489  err:
490  /* Unregister image if applicable */
493 
494  /* Debug message for tail-recursion. Placed here because the
495  * image_put() may end up freeing the image.
496  */
497  if ( replacement ) {
498  DBGC ( image, "IMAGE %s replacing self with IMAGE %s\n",
499  image->name, replacement->name );
500  }
501 
502  /* Drop temporary reference to the original image */
503  image_put ( image );
504 
505  /* Restore previous currently-running image */
506  image_tag ( saved_current_image, &current_image );
507 
508  /* Reset current working directory */
509  churi ( old_cwuri );
510  uri_put ( old_cwuri );
511 
512  /* Tail-recurse into replacement image, if one exists */
513  if ( replacement )
514  return image_exec ( replacement );
515 
516  return rc;
517 }
518 
519 /**
520  * Set replacement image
521  *
522  * @v replacement Replacement image
523  * @ret rc Return status code
524  *
525  * The replacement image must already be registered, and must remain
526  * registered until the currently-executing image returns.
527  */
528 int image_replace ( struct image *replacement ) {
529  struct image *image = current_image.image;
530  int rc;
531 
532  /* Sanity check */
533  assert ( replacement->flags & IMAGE_REGISTERED );
534 
535  /* Fail unless there is a currently-executing image */
536  if ( ! image ) {
537  rc = -ENOTTY;
538  DBGC ( replacement, "IMAGE %s cannot replace non-existent "
539  "image: %s\n", replacement->name, strerror ( rc ) );
540  return rc;
541  }
542 
543  /* Check that the replacement image can be executed */
544  if ( ! ( replacement->type && replacement->type->exec ) )
545  return -ENOEXEC;
546 
547  /* Clear any existing replacement */
549 
550  /* Set replacement */
552  DBGC ( image, "IMAGE %s will replace self with IMAGE %s\n",
553  image->name, replacement->name );
554 
555  return 0;
556 }
557 
558 /**
559  * Select image for execution
560  *
561  * @v image Executable image
562  * @ret rc Return status code
563  */
564 int image_select ( struct image *image ) {
565 
566  /* Check that this image can be executed */
567  if ( ! ( image->type && image->type->exec ) )
568  return -ENOEXEC;
569 
570  /* Mark image as selected */
572 
573  return 0;
574 }
575 
576 /**
577  * Change image trust requirement
578  *
579  * @v require_trusted Require trusted images
580  * @v permanent Make trust requirement permanent
581  * @ret rc Return status code
582  */
583 int image_set_trust ( int require_trusted, int permanent ) {
584 
585  /* Update trust requirement, if permitted to do so */
587  require_trusted_images = require_trusted;
589  }
590 
591  /* Fail if we attempted to change the trust requirement but
592  * were not permitted to do so.
593  */
594  if ( require_trusted_images != require_trusted )
595  return -EACCES_PERMANENT;
596 
597  return 0;
598 }
599 
600 /**
601  * Create registered image from block of memory
602  *
603  * @v name Name
604  * @v data Image data
605  * @v len Length
606  * @ret image Image, or NULL on error
607  */
608 struct image * image_memory ( const char *name, const void *data,
609  size_t len ) {
610  struct image *image;
611  int rc;
612 
613  /* Allocate image */
614  image = alloc_image ( NULL );
615  if ( ! image ) {
616  rc = -ENOMEM;
617  goto err_alloc_image;
618  }
619 
620  /* Set name */
621  if ( ( rc = image_set_name ( image, name ) ) != 0 )
622  goto err_set_name;
623 
624  /* Set data */
625  if ( ( rc = image_set_data ( image, data, len ) ) != 0 )
626  goto err_set_data;
627 
628  /* Register image */
629  if ( ( rc = register_image ( image ) ) != 0 )
630  goto err_register;
631 
632  /* Drop local reference to image */
633  image_put ( image );
634 
635  return image;
636 
637  err_register:
638  err_set_data:
639  err_set_name:
640  image_put ( image );
641  err_alloc_image:
642  return NULL;
643 }
644 
645 /**
646  * Find argument within image command line
647  *
648  * @v image Image
649  * @v key Argument search key (including trailing delimiter)
650  * @ret value Argument value, or NULL if not found
651  */
652 const char * image_argument ( struct image *image, const char *key ) {
653  const char *cmdline = image->cmdline;
654  const char *search;
655  const char *match;
656  const char *next;
657 
658  /* Find argument */
659  for ( search = cmdline ; search ; search = next ) {
660 
661  /* Find next occurrence, if any */
662  match = strstr ( search, key );
663  if ( ! match )
664  break;
665  next = ( match + strlen ( key ) );
666 
667  /* Check preceding delimiter, if any */
668  if ( ( match == cmdline ) || isspace ( match[-1] ) )
669  return next;
670  }
671 
672  return NULL;
673 }
#define IMAGE_TYPES
Executable image type table.
Definition: image.h:166
int image_set_trust(int require_trusted, int permanent)
Change image trust requirement.
Definition: image.c:583
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:67
unsigned int flags
Flags.
Definition: image.h:39
struct image_tag selected_image
static int require_trusted_images_permanent
Prevent changes to image trust requirement.
Definition: image.c:74
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
int image_select(struct image *image)
Select image for execution.
Definition: image.c:564
int image_set_uri(struct image *image, struct uri *uri)
Set image URI.
Definition: image.c:152
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
An image tag.
Definition: image.h:172
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:194
char * strrchr(const char *src, int character)
Find rightmost character within a string.
Definition: string.c:289
struct image * find_image(const char *name)
Find image by name.
Definition: image.c:375
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
Error codes.
const void * data
Read-only data.
Definition: image.h:50
#define EACCES_UNTRUSTED
Definition: image.c:48
char * image_strip_suffix(struct image *image)
Strip dot suffix from image name, if present.
Definition: image.c:205
#define ENOEXEC
Exec format error.
Definition: errno.h:519
struct image_type * type
Image type, if known.
Definition: image.h:58
uint32_t type
Operating system type.
Definition: ena.h:12
static struct image * image_get(struct image *image)
Increment reference count on an image.
Definition: image.h:239
#define DBGC(...)
Definition: compiler.h:505
An executable image type.
Definition: image.h:94
#define EACCES_PERMANENT
Definition: image.c:52
An executable image.
Definition: image.h:23
Character types.
struct image_tag selected_image __image_tag
Image selected for execution.
Definition: image.c:61
#define LOG_ERR
Error: error conditions.
Definition: syslog.h:35
Uniform Resource Identifiers.
struct image * image
Image (weak reference, nullified when image is freed)
Definition: image.h:176
#define IMAGE_AUTO_UNREGISTER
Image will be automatically unregistered after execution.
Definition: image.h:82
int(* exec)(struct image *image)
Execute image.
Definition: image.h:112
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
char * cmdline
Command line to pass to image.
Definition: image.h:42
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
int image_exec(struct image *image)
Execute image.
Definition: image.c:413
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
Definition: image.c:392
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static int image_probe(struct image *image)
Determine image type.
Definition: image.c:288
char * strstr(const char *haystack, const char *needle)
Find substring.
Definition: string.c:309
#define ENOMEM
Not enough space.
Definition: errno.h:534
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void free_image(struct refcnt *refcnt)
Free executable image.
Definition: image.c:85
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int count
Current reference count.
Definition: refcnt.h:32
struct image_tag current_image
#define IMAGE_STATIC
Image is statically allocated.
Definition: image.h:88
Assertions.
void churi(struct uri *uri)
Change working URI.
Definition: cwuri.c:45
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
Access to external ("user") memory.
Executable images.
const char * replacement
Definition: editstring.h:53
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
ring len
Length.
Definition: dwmac.h:231
const char * path
Path (after URI decoding)
Definition: uri.h:80
#define IMAGE_REGISTERED
Image is registered.
Definition: image.h:76
#define IMAGE_TAGS
Image tag table.
Definition: image.h:180
Linked lists.
int register_image(struct image *image)
Register executable image.
Definition: image.c:314
#define for_each_image(image)
Iterate over all registered images.
Definition: image.h:190
System logger.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
char * basename(char *path)
Return base name from path.
Definition: basename.c:42
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
size_t len
Length of raw file image.
Definition: image.h:55
int image_replace(struct image *replacement)
Set replacement image.
Definition: image.c:528
struct list_head images
List of registered images.
Definition: image.c:58
int image_set_name(struct image *image, const char *name)
Set image name.
Definition: image.c:180
#define IMAGE_TRUSTED
Image is trusted.
Definition: image.h:79
char * strdup(const char *src)
Duplicate string.
Definition: string.c:393
User memory allocation.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
struct uri * uri
URI of image.
Definition: image.h:31
int isspace(int character)
Check to see if character is a space.
Definition: ctype.c:41
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
static void image_put(struct image *image)
Decrement reference count on an image.
Definition: image.h:249
uint32_t next
Next descriptor address.
Definition: dwmac.h:22
struct image * image_memory(const char *name, const void *data, size_t len)
Create registered image from block of memory.
Definition: image.c:608
int image_set_data(struct image *image, const void *data, size_t len)
Set image data.
Definition: image.c:269
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:357
int image_set_len(struct image *image, size_t len)
Set image length.
Definition: image.c:244
const char * opaque
Opaque part.
Definition: uri.h:70
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
void * rwdata
Writable data.
Definition: image.h:52
#define IMAGE_STATIC_NAME
Image name is statically allocated.
Definition: image.h:91
const char * image_argument(struct image *image, const char *key)
Find argument within image command line.
Definition: image.c:652
#define syslog(priority, fmt,...)
Write message to system log.
Definition: syslog.h:93
uint8_t data[48]
Additional event data.
Definition: ena.h:22
struct image * replacement
Replacement image.
Definition: image.h:72
int image_set_cmdline(struct image *image, const char *cmdline)
Set image command line.
Definition: image.c:225
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
A Uniform Resource Identifier.
Definition: uri.h:64
void * urealloc(void *ptr, size_t new_size)
Reallocate external memory.
static int require_trusted_images
Current image trust requirement.
Definition: image.c:71
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
struct list_head list
List of registered images.
Definition: image.h:28
struct uri * cwuri
Current working URI.
Definition: cwuri.c:38
static struct image * image_tag(struct image *image, struct image_tag *tag)
Tag image.
Definition: image.h:296
uint32_t cmdline
Definition: multiboot.h:16
struct image * alloc_image(struct uri *uri)
Allocate executable image.
Definition: image.c:123
uint64_t tag
Identity tag.
Definition: edd.h:30
char * name
Name.
Definition: image.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
#define LOG_NOTICE
Notice: normal but significant conditions.
Definition: syslog.h:41
const char * name
Name.
Definition: image.h:174
union @391 key
Sense key.
Definition: scsi.h:17
struct refcnt refcnt
Reference count.
Definition: image.h:25