Data Structures | Functions | Variables
image_archive_cmd.c File Reference

Archive image commands. More...

#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <usr/imgmgmt.h>
#include <usr/imgarchive.h>

Go to the source code of this file.

Data Structures

struct  imgextract_options
 "imgextract" options More...


static int imgextract_exec (int argc, char **argv)
 The "imgextract" command. More...


static struct option_descriptor imgextract_opts []
 "imgextract" option list More...
static struct command_descriptor imgextract_cmd
 "imgextract" command descriptor More...
struct command image_archive_commands [] __command
 Archive image commands. More...

Detailed Description

Archive image commands.

Definition in file image_archive_cmd.c.

Function Documentation



◆ imgextract_exec()

static int imgextract_exec ( int  argc,
char **  argv 

The "imgextract" command.

argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 69 of file image_archive_cmd.c.

69  {
70  struct imgextract_options opts;
71  struct image *image;
72  int rc;
74  /* Parse options */
75  if ( ( rc = parse_options ( argc, argv, &imgextract_cmd,
76  &opts ) ) != 0 )
77  goto err_parse;
79  /* Acquire image */
80  if ( ( rc = imgacquire ( argv[optind], opts.timeout, &image ) ) != 0 )
81  goto err_acquire;
83  /* Extract archive image */
84  if ( ( rc = imgextract ( image, opts.name ) ) != 0 )
85  goto err_extract;
87  /* Success */
88  rc = 0;
90  err_extract:
91  /* Discard original image unless --keep was specified */
92  if ( ! opts.keep )
94  err_acquire:
95  err_parse:
96  return rc;
97 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
An executable image.
Definition: image.h:24
"imgextract" options
int imgextract(struct image *image, const char *name)
Extract archive image.
Definition: imgarchive.c:43
static struct command_descriptor imgextract_cmd
"imgextract" command descriptor
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:294
static union @432 opts
"cert<xxx>" option list
int imgacquire(const char *name_uri, unsigned long timeout, struct image **image)
Acquire an image.
Definition: imgmgmt.c:141

References imgacquire(), imgextract(), imgextract_cmd, optind, opts, parse_options(), rc, and unregister_image().

Variable Documentation

◆ imgextract_opts

struct option_descriptor imgextract_opts[]
Initial value:
= {
OPTION_DESC ( "keep", 'k', no_argument,
struct imgextract_options, keep, parse_flag ),
OPTION_DESC ( "timeout", 't', required_argument,
const char * name
Definition: ath9k_hw.c:1984
int parse_timeout(char *text, unsigned long *value)
Parse timeout value (in ms)
Definition: parseopt.c:111
"imgextract" options
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:70
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:200
Option does not take an argument.
Definition: getopt.h:16
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:66
Option requires an argument.
Definition: getopt.h:18
void timeout(int)

"imgextract" option list

Definition at line 49 of file image_archive_cmd.c.

◆ imgextract_cmd

struct command_descriptor imgextract_cmd
Initial value:
"imgextract" options
static struct option_descriptor imgextract_opts[]
"imgextract" option list
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

"imgextract" command descriptor

Definition at line 59 of file image_archive_cmd.c.

Referenced by imgextract_exec().

◆ __command

struct command image_archive_commands [] __command
Initial value:
= {
.name = "imgextract",
.exec = imgextract_exec,
static int imgextract_exec(int argc, char **argv)
The "imgextract" command.

Archive image commands.

Definition at line 100 of file image_archive_cmd.c.