iPXE
image_set_cmd.c File Reference

Image setting commands. More...

#include <string.h>
#include <stdio.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/settings.h>
#include <usr/imgmgmt.h>

Go to the source code of this file.

Data Structures

struct  imgset_options
 "imgset" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int imgset_exec (int argc, char **argv)
 The "imgset" command.
 COMMAND (imgset, imgset_exec)

Variables

static struct option_descriptor imgset_opts []
 "imgset" option list
static struct command_descriptor imgset_cmd
 "imgset" command descriptor

Detailed Description

Image setting commands.

Definition in file image_set_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ imgset_exec()

int imgset_exec ( int argc,
char ** argv )
static

The "imgset" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 72 of file image_set_cmd.c.

72 {
73 struct imgset_options opts;
75 struct image *image;
76 int rc;
77
78 /* Parse options */
79 if ( ( rc = parse_options ( argc, argv, &imgset_cmd, &opts ) ) != 0 )
80 goto err_parse;
81
82 /* Parse setting name */
83 if ( ( rc = parse_autovivified_setting ( argv[optind++],
84 &setting ) ) != 0 )
85 goto err_setting;
86
87 /* Acquire image */
88 if ( ( rc = imgacquire ( argv[optind], opts.timeout, opts.quiet,
89 &image ) ) != 0 )
90 goto err_acquire;
91
92 /* Store setting value */
93 if ( ( rc = store_setting ( setting.settings, &setting.setting,
94 image->data, image->len ) ) != 0 ) {
95 printf ( "Could not store \"%s\": %s\n",
96 setting.setting.name, strerror ( rc ) );
97 goto err_store;
98 }
99
100 /* Success */
101 rc = 0;
102
103 err_store:
104 /* Discard image unless --keep was specified */
105 if ( ! opts.keep )
107 err_acquire:
108 err_setting:
109 err_parse:
110 return rc;
111}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
int optind
Current option index.
Definition getopt.c:52
void unregister_image(struct image *image)
Unregister executable image.
Definition image.c:390
static struct command_descriptor imgset_cmd
"imgset" command descriptor
int imgacquire(const char *name_uri, unsigned long timeout, int quiet, struct image **image)
Acquire an image.
Definition imgmgmt.c:148
int parse_autovivified_setting(char *text, struct named_setting *setting)
Parse and autovivify setting name.
Definition parseopt.c:337
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition parseopt.c:485
int store_setting(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of setting.
Definition settings.c:616
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
An executable image.
Definition image.h:24
const void * data
Read-only data.
Definition image.h:51
size_t len
Length of raw file image.
Definition image.h:63
"imgset" options
A parsed named setting.
Definition parseopt.h:123
A setting.
Definition settings.h:24
const char * name
Name.
Definition settings.h:29
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References image::data, imgacquire(), imgset_cmd, image::len, setting::name, optind, opts, parse_autovivified_setting(), parse_options(), printf(), rc, store_setting(), strerror(), and unregister_image().

Referenced by COMMAND().

◆ COMMAND()

COMMAND ( imgset ,
imgset_exec  )

References imgset_exec().

Variable Documentation

◆ imgset_opts

struct option_descriptor imgset_opts[]
static
Initial value:
= {
OPTION_DESC ( "keep", 'k', no_argument,
struct imgset_options, keep, parse_flag ),
OPTION_DESC ( "timeout", 't', required_argument,
OPTION_DESC ( "quiet", 'q', no_argument,
struct imgset_options, quiet, parse_flag ),
}
void timeout(int)
@ required_argument
Option requires an argument.
Definition getopt.h:19
@ no_argument
Option does not take an argument.
Definition getopt.h:17
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition parseopt.c:227
int parse_timeout(char *text, unsigned long *value)
Parse timeout value (in ms).
Definition parseopt.c:115
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68

"imgset" option list

Definition at line 52 of file image_set_cmd.c.

52 {
53 OPTION_DESC ( "keep", 'k', no_argument,
54 struct imgset_options, keep, parse_flag ),
55 OPTION_DESC ( "timeout", 't', required_argument,
57 OPTION_DESC ( "quiet", 'q', no_argument,
58 struct imgset_options, quiet, parse_flag ),
59};

◆ imgset_cmd

struct command_descriptor imgset_cmd
static
Initial value:
=
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
static struct option_descriptor imgset_opts[]
"imgset" option list
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109

"imgset" command descriptor

Definition at line 62 of file image_set_cmd.c.

Referenced by imgset_exec().