iPXE
sanboot_cmd.c File Reference

SAN commands. More...

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/uri.h>
#include <ipxe/sanboot.h>
#include <usr/autoboot.h>

Go to the source code of this file.

Data Structures

struct  sanboot_options
 "sanboot" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int sanboot_core_exec (int argc, char **argv, struct command_descriptor *cmd, int default_flags, int no_root_path_flags)
 The "sanboot", "sanhook" and "sanunhook" commands.
static int sanhook_exec (int argc, char **argv)
 The "sanhook" command.
static int sanboot_exec (int argc, char **argv)
 The "sanboot" command.
static int sanunhook_exec (int argc, char **argv)
 The "sanunhook" command.
 COMMAND (sanhook, sanhook_exec)
 SAN commands.
 COMMAND (sanboot, sanboot_exec)
 COMMAND (sanunhook, sanunhook_exec)

Variables

union { 
   struct option_descriptor   sanboot [7] 
   struct option_descriptor   sanhook [2] 
   struct option_descriptor   sanunhook [1] 
opts
 "sanboot" option list
static struct command_descriptor sanhook_cmd
 "sanhook" command descriptor
static struct command_descriptor sanboot_cmd
 "sanboot" command descriptor
static struct command_descriptor sanunhook_cmd
 "sanunhook" command descriptor

Detailed Description

SAN commands.

Definition in file sanboot_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ sanboot_core_exec()

int sanboot_core_exec ( int argc,
char ** argv,
struct command_descriptor * cmd,
int default_flags,
int no_root_path_flags )
static

The "sanboot", "sanhook" and "sanunhook" commands.

Parameters
argcArgument count
argvArgument list
default_flagsDefault set of flags for uriboot()
no_root_path_flagsAdditional flags to apply if no root path is present
Return values
rcReturn status code

Definition at line 111 of file sanboot_cmd.c.

113 {
114 struct sanboot_options opts;
115 struct san_boot_config config;
116 struct uri *uris[argc];
117 int count;
118 int flags;
119 int i;
120 int rc;
121
122 /* Initialise options */
123 memset ( &opts, 0, sizeof ( opts ) );
124 opts.drive = san_default_drive();
125
126 /* Parse options */
127 if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
128 goto err_parse_options;
129
130 /* Parse root paths, if present */
131 count = ( argc - optind );
132 for ( i = 0 ; i < count ; i++ ) {
133 uris[i] = parse_uri ( argv[ optind + i ] );
134 if ( ! uris[i] ) {
135 rc = -ENOMEM;
136 goto err_parse_uri;
137 }
138 }
139
140 /* Construct configuration parameters */
141 config.filename = opts.filename;
142 config.extra = opts.extra;
143 config.label = opts.label;
144 config.uuid = opts.uuid.value;
145
146 /* Construct flags */
147 flags = default_flags;
148 if ( opts.no_describe )
150 if ( opts.keep )
152 if ( ! count )
153 flags |= no_root_path_flags;
154
155 /* Boot from root path */
156 if ( ( rc = uriboot ( NULL, uris, count, opts.drive, &config,
157 flags ) ) != 0 )
158 goto err_uriboot;
159
160 err_uriboot:
161 i = count;
162 err_parse_uri:
163 for ( i-- ; i >= 0 ; i-- )
164 uri_put ( uris[i] );
165 err_parse_options:
166 return rc;
167}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct golan_eqe_cmd cmd
Definition CIB_PRM.h:1
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
int uriboot(struct uri *filename, struct uri **root_paths, unsigned int root_path_count, int drive, struct san_boot_config *san_config, unsigned int flags)
Boot from filename and root-path URIs.
Definition autoboot.c:130
@ URIBOOT_NO_SAN_DESCRIBE
Definition autoboot.h:22
@ URIBOOT_NO_SAN_UNHOOK
Definition autoboot.h:24
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
uint8_t flags
Flags.
Definition ena.h:7
int optind
Current option index.
Definition getopt.c:52
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define ENOMEM
Not enough space.
Definition errno.h:535
void * memset(void *dest, int character, size_t len) __nonnull
int reparse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Reparse command-line options.
Definition parseopt.c:402
unsigned int san_default_drive(void)
Get default SAN drive number.
Definition sanboot.c:973
SAN boot configuration parameters.
Definition sanboot.h:111
"sanboot" options
Definition sanboot_cmd.c:44
A Uniform Resource Identifier.
Definition uri.h:65
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition uri.c:297
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition uri.h:206

References cmd, count, ENOMEM, san_boot_config::extra, san_boot_config::filename, flags, san_boot_config::label, memset(), NULL, optind, opts, parse_uri(), rc, reparse_options(), san_default_drive(), uri_put(), uriboot(), URIBOOT_NO_SAN_DESCRIBE, URIBOOT_NO_SAN_UNHOOK, and san_boot_config::uuid.

Referenced by sanboot_exec(), sanhook_exec(), and sanunhook_exec().

◆ sanhook_exec()

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

The "sanhook" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 176 of file sanboot_cmd.c.

176 {
177 return sanboot_core_exec ( argc, argv, &sanhook_cmd,
180}
@ URIBOOT_NO_SAN_BOOT
Definition autoboot.h:23
static struct command_descriptor sanhook_cmd
"sanhook" command descriptor
Definition sanboot_cmd.c:89
static int sanboot_core_exec(int argc, char **argv, struct command_descriptor *cmd, int default_flags, int no_root_path_flags)
The "sanboot", "sanhook" and "sanunhook" commands.

References sanboot_core_exec(), sanhook_cmd, URIBOOT_NO_SAN_BOOT, and URIBOOT_NO_SAN_UNHOOK.

Referenced by COMMAND().

◆ sanboot_exec()

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

The "sanboot" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 189 of file sanboot_cmd.c.

189 {
190 return sanboot_core_exec ( argc, argv, &sanboot_cmd,
192}
static struct command_descriptor sanboot_cmd
"sanboot" command descriptor
Definition sanboot_cmd.c:94

References sanboot_cmd, sanboot_core_exec(), and URIBOOT_NO_SAN_UNHOOK.

Referenced by COMMAND().

◆ sanunhook_exec()

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

The "sanunhook" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 201 of file sanboot_cmd.c.

201 {
202 return sanboot_core_exec ( argc, argv, &sanunhook_cmd,
204 URIBOOT_NO_SAN_BOOT ), 0 );
205}
static struct command_descriptor sanunhook_cmd
"sanunhook" command descriptor
Definition sanboot_cmd.c:99

References sanboot_core_exec(), sanunhook_cmd, URIBOOT_NO_SAN_BOOT, and URIBOOT_NO_SAN_DESCRIBE.

Referenced by COMMAND().

◆ COMMAND() [1/3]

COMMAND ( sanhook ,
sanhook_exec  )

SAN commands.

References sanhook, and sanhook_exec().

◆ COMMAND() [2/3]

COMMAND ( sanboot ,
sanboot_exec  )

References sanboot, and sanboot_exec().

◆ COMMAND() [3/3]

COMMAND ( sanunhook ,
sanunhook_exec  )

References sanunhook, and sanunhook_exec().

Variable Documentation

◆ sanboot

struct option_descriptor sanboot[7]

Definition at line 64 of file sanboot_cmd.c.

Referenced by COMMAND().

◆ sanhook

struct option_descriptor sanhook[2]

Definition at line 66 of file sanboot_cmd.c.

Referenced by COMMAND().

◆ sanunhook

struct option_descriptor sanunhook[1]

Definition at line 68 of file sanboot_cmd.c.

Referenced by COMMAND().

◆ [union]

union { ... } opts
Initial value:
= {
.sanboot = {
OPTION_DESC ( "drive", 'd', required_argument,
OPTION_DESC ( "no-describe", 'n', no_argument,
struct sanboot_options, no_describe, parse_flag ),
OPTION_DESC ( "keep", 'k', no_argument,
struct sanboot_options, keep, parse_flag ),
OPTION_DESC ( "filename", 'f', required_argument,
struct sanboot_options, filename, parse_string ),
OPTION_DESC ( "extra", 'e', required_argument,
OPTION_DESC ( "label", 'l', required_argument,
},
}
@ required_argument
Option requires an argument.
Definition getopt.h:19
@ no_argument
Option does not take an argument.
Definition getopt.h:17
uint8_t drive
Drive number.
Definition int13.h:5
uint8_t extra
Signature extra byte.
Definition smbios.h:6
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition parseopt.c:227
int parse_string(char *text, char **value)
Parse string value.
Definition parseopt.c:74
int parse_uuid(char *text, struct uuid_option *uuid)
Parse UUID.
Definition parseopt.c:136
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition parseopt.c:92
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68
A text label widget.
Definition label.h:16
A universally unique ID.
Definition uuid.h:16

"sanboot" option list

◆ sanhook_cmd

struct command_descriptor sanhook_cmd
static
Initial value:
=
"<root-path>" )
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition parseopt.h:98
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109

"sanhook" command descriptor

Definition at line 89 of file sanboot_cmd.c.

Referenced by sanhook_exec().

◆ sanboot_cmd

struct command_descriptor sanboot_cmd
static
Initial value:
=
"[<root-path>]" )

"sanboot" command descriptor

Definition at line 94 of file sanboot_cmd.c.

Referenced by PROVIDE_REQUIRING_SYMBOL(), and sanboot_exec().

◆ sanunhook_cmd

struct command_descriptor sanunhook_cmd
static
Initial value:
=
COMMAND_DESC ( struct sanboot_options, opts.sanunhook, 0, 0, NULL )

"sanunhook" command descriptor

Definition at line 99 of file sanboot_cmd.c.

Referenced by sanunhook_exec().