iPXE
Data Structures | Functions | Variables
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. More...
 
static int sanhook_exec (int argc, char **argv)
 The "sanhook" command. More...
 
static int sanboot_exec (int argc, char **argv)
 The "sanboot" command. More...
 
static int sanunhook_exec (int argc, char **argv)
 The "sanunhook" command. More...
 
 COMMAND (sanhook, sanhook_exec)
 SAN commands. More...
 
 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 More...
 
static struct command_descriptor sanhook_cmd
 "sanhook" command descriptor More...
 
static struct command_descriptor sanboot_cmd
 "sanboot" command descriptor More...
 
static struct command_descriptor sanunhook_cmd
 "sanunhook" command descriptor More...
 

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()

static 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 }
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
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:206
int optind
Current option index.
Definition: getopt.c:52
unsigned int san_default_drive(void)
Get default SAN drive number.
Definition: sanboot.c:973
#define ENOMEM
Not enough space.
Definition: errno.h:535
SAN boot configuration parameters.
Definition: sanboot.h:111
static unsigned int count
Number of entries.
Definition: dwmac.h:225
int reparse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Reparse command-line options.
Definition: parseopt.c:402
uint8_t flags
Flags.
Definition: ena.h:18
"sanboot" options
Definition: sanboot_cmd.c:44
A Uniform Resource Identifier.
Definition: uri.h:65
static union @450 opts
"sanboot" option list
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:297
void * memset(void *dest, int character, size_t len) __nonnull

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()

static 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,
179  URIBOOT_NO_SAN_UNHOOK ), 0 );
180 }
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.
Definition: sanboot_cmd.c:111

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

◆ sanboot_exec()

static 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
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.
Definition: sanboot_cmd.c:111

References sanboot_cmd, sanboot_core_exec(), and URIBOOT_NO_SAN_UNHOOK.

◆ sanunhook_exec()

static 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
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.
Definition: sanboot_cmd.c:111

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

◆ COMMAND() [1/3]

COMMAND ( sanhook  ,
sanhook_exec   
)

SAN commands.

◆ COMMAND() [2/3]

COMMAND ( sanboot  ,
sanboot_exec   
)

◆ COMMAND() [3/3]

COMMAND ( sanunhook  ,
sanunhook_exec   
)

Variable Documentation

◆ sanboot

struct option_descriptor sanboot[7]

Definition at line 64 of file sanboot_cmd.c.

◆ sanhook

struct option_descriptor sanhook[2]

Definition at line 66 of file sanboot_cmd.c.

◆ sanunhook

struct option_descriptor sanunhook[1]

Definition at line 68 of file sanboot_cmd.c.

◆ opts

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,
},
}
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:92
A text label widget.
Definition: label.h:16
int parse_uuid(char *text, struct uuid_option *uuid)
Parse UUID.
Definition: parseopt.c:136
A universally unique ID.
Definition: uuid.h:16
uint8_t extra
Signature extra byte.
Definition: smbios.h:18
uint8_t drive
Drive number.
Definition: int13.h:16
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:74
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:227
"sanboot" options
Definition: sanboot_cmd.c:44
Option does not take an argument.
Definition: getopt.h:17
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:68
Option requires an argument.
Definition: getopt.h:19

"sanboot" option list

Referenced by sanboot_core_exec().

◆ sanhook_cmd

struct command_descriptor sanhook_cmd
static
Initial value:
=
"<root-path>" )
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:98
"sanboot" options
Definition: sanboot_cmd.c:44
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
static union @450 opts
"sanboot" option list

"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>]" )
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:98
"sanboot" options
Definition: sanboot_cmd.c:44
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
static union @450 opts
"sanboot" option list

"sanboot" command descriptor

Definition at line 94 of file sanboot_cmd.c.

Referenced by sanboot_exec().

◆ sanunhook_cmd

struct command_descriptor sanunhook_cmd
static
Initial value:
=
COMMAND_DESC ( struct sanboot_options, opts.sanunhook, 0, 0, NULL )
"sanboot" options
Definition: sanboot_cmd.c:44
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
static union @450 opts
"sanboot" option list
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

"sanunhook" command descriptor

Definition at line 99 of file sanboot_cmd.c.

Referenced by sanunhook_exec().