105 char *name_uri =
NULL;
112 goto err_parse_options;
121 goto err_parse_cmdline;
128 if ( (
rc =
desc->acquire ( name_uri,
opts.timeout,
134 printf (
"No image selected\n" );
140 if (
desc->preaction )
146 printf (
"Could not name image: %s\n",
155 printf (
"Could not set arguments: %s\n",
157 goto err_set_cmdline;
166 if (
desc->action ) {
168 printf (
"Could not %s: %s\n",
261 if (
opts->replace ) {
342 void ( * payload ) (
struct image *
image ) ) {
361 for ( i =
optind ; i < argc ; i++ ) {
364 printf (
"\"%s\": no such image\n", argv[i] );
static struct command_descriptor imgfetch_cmd
"imgfetch" command descriptor
struct imgsingle_descriptor imgargs_desc
"imgargs" family command descriptor
struct image_tag selected_image
struct arbelprm_rc_send_wqe rc
int image_select(struct image *image)
Select image for execution.
int printf(const char *fmt,...)
Write a formatted string to the console.
int optind
Current option index.
struct image * find_image(const char *name)
Find image by name.
An "img{single}" family command descriptor.
int parse_timeout(char *text, unsigned long *value)
Parse timeout value (in ms)
uint64_t desc
Microcode descriptor list physical address.
#define ENOENT
No such file or directory.
struct imgsingle_descriptor imgfetch_desc
"imgfetch" family command descriptor
int autofree
Free image after execution.
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
void shell_stop(int stop)
Set shell stop state.
struct imgsingle_descriptor imgselect_desc
"imgselect" family command descriptor
static int imgselect_exec(int argc, char **argv)
The "imgselect" command.
#define IMAGE_AUTO_UNREGISTER
Image will be automatically unregistered after execution.
int image_exec(struct image *image)
Execute image.
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
struct command image_commands [] __command
Image management commands.
#define ENOMEM
Not enough space.
static struct option_descriptor imgmulti_opts[]
"img{multi}" option list
static int imgmulti_exec(int argc, char **argv, void(*payload)(struct image *image))
The "img{multi}" family of commands.
Parse command-line options.
int parse_string(char *text, char **value)
Parse string value.
struct option_descriptor imgsingle[3]
#define __unused
Declare a variable or data structure as unused.
static int imgexec_exec(int argc, char **argv)
The "imgexec" command.
void imgstat(struct image *image)
Display status of an image.
#define MAX_ARGUMENTS
No maximum number of arguments.
struct option_descriptor imgexec[4]
char * concat_args(char **args)
Concatenate arguments.
static int imgsingle_exec(int argc, char **argv, struct imgsingle_descriptor *desc)
The "img{single}" family of commands.
int parse_flag(char *text __unused, int *flag)
Parse flag.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
static int imgargs_exec(int argc, char **argv)
The "imgargs" command body.
int image_replace(struct image *replacement)
Set replacement image.
#define for_each_image_safe(image, tmp)
Iterate over all registered images, safe against deletion.
int image_set_name(struct image *image, const char *name)
Set image name.
Command line option parsing.
static struct command_descriptor imgargs_cmd
"imgargs" command descriptor
struct command_descriptor * cmd
Command descriptor.
void(* preaction)(struct image *image)
Pre-action to take upon image, or NULL.
static struct command_descriptor imgexec_cmd
"imgexec" command descriptor
Option does not take an argument.
int(* action)(struct image *image, struct imgsingle_options *opts)
Action to take upon image, or NULL.
static int imgselect(struct image *image, struct imgsingle_options *opts __unused)
"imgselect" command action
const char * name
Name of the command.
static int imgstat_exec(int argc, char **argv)
The "imgstat" command.
void unregister_image(struct image *image)
Unregister executable image.
unsigned long timeout
Download timeout.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct command_descriptor imgmulti_cmd
"img{multi}" command descriptor
int imgdownload_string(const char *uri_string, unsigned long timeout, struct image **image)
Download a new image.
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Option requires an argument.
Stop processing commands.
A command-line option descriptor.
static void image_clear_cmdline(struct image *image)
Clear image command line.
struct imgsingle_descriptor imgexec_desc
"imgexec" family command descriptor
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
int image_set_cmdline(struct image *image, const char *cmdline)
Set image command line.
int replace
Replace image.
const char * verb
Verb to describe action.
int(* acquire)(const char *name, unsigned long timeout, struct image **image)
Function to use to acquire the image.
#define NULL
NULL pointer (VOID *)
static struct command_descriptor imgselect_cmd
"imgselect" command descriptor
static int imgfetch_exec(int argc, char **argv)
The "imgfetch" command.
int imgacquire(const char *name_uri, unsigned long timeout, struct image **image)
Acquire an image.
static union @439 opts
"img{single}" option list
static int imgfree_exec(int argc, char **argv)
The "imgfree" command.