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

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...
 
struct command sanboot_commands [] __command
 SAN commands. More...
 

Detailed Description

SAN commands.

Definition in file sanboot_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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 110 of file sanboot_cmd.c.

112  {
113  struct sanboot_options opts;
114  struct san_boot_config config;
115  struct uri *uris[argc];
116  int count;
117  int flags;
118  int i;
119  int rc;
120 
121  /* Initialise options */
122  memset ( &opts, 0, sizeof ( opts ) );
123  opts.drive = san_default_drive();
124 
125  /* Parse options */
126  if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
127  goto err_parse_options;
128 
129  /* Parse root paths, if present */
130  count = ( argc - optind );
131  for ( i = 0 ; i < count ; i++ ) {
132  uris[i] = parse_uri ( argv[ optind + i ] );
133  if ( ! uris[i] ) {
134  rc = -ENOMEM;
135  goto err_parse_uri;
136  }
137  }
138 
139  /* Construct configuration parameters */
140  config.filename = opts.filename;
141  config.extra = opts.extra;
142  config.label = opts.label;
143  config.uuid = opts.uuid.value;
144 
145  /* Construct flags */
146  flags = default_flags;
147  if ( opts.no_describe )
149  if ( opts.keep )
151  if ( ! count )
152  flags |= no_root_path_flags;
153 
154  /* Boot from root path */
155  if ( ( rc = uriboot ( NULL, uris, count, opts.drive, &config,
156  flags ) ) != 0 )
157  goto err_uriboot;
158 
159  err_uriboot:
160  i = count;
161  err_parse_uri:
162  for ( i-- ; i >= 0 ; i-- )
163  uri_put ( uris[i] );
164  err_parse_options:
165  return rc;
166 }
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:129
static union @441 opts
"sanboot" option list
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
int optind
Current option index.
Definition: getopt.c:51
unsigned int san_default_drive(void)
Get default SAN drive number.
Definition: sanboot.c:970
#define ENOMEM
Not enough space.
Definition: errno.h:534
SAN boot configuration parameters.
Definition: sanboot.h:110
uint16_t count
Number of entries.
Definition: ena.h:22
int reparse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Reparse command-line options.
Definition: parseopt.c:401
uint8_t flags
Flags.
Definition: ena.h:18
"sanboot" options
Definition: sanboot_cmd.c:43
A Uniform Resource Identifier.
Definition: uri.h:64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296
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 175 of file sanboot_cmd.c.

175  {
176  return sanboot_core_exec ( argc, argv, &sanhook_cmd,
178  URIBOOT_NO_SAN_UNHOOK ), 0 );
179 }
static struct command_descriptor sanhook_cmd
"sanhook" command descriptor
Definition: sanboot_cmd.c:88
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:110

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 188 of file sanboot_cmd.c.

188  {
189  return sanboot_core_exec ( argc, argv, &sanboot_cmd,
191 }
static struct command_descriptor sanboot_cmd
"sanboot" command descriptor
Definition: sanboot_cmd.c:93
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:110

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 200 of file sanboot_cmd.c.

200  {
201  return sanboot_core_exec ( argc, argv, &sanunhook_cmd,
203  URIBOOT_NO_SAN_BOOT ), 0 );
204 }
static struct command_descriptor sanunhook_cmd
"sanunhook" command descriptor
Definition: sanboot_cmd.c:98
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:110

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

Variable Documentation

◆ sanboot

struct option_descriptor sanboot[7]

Definition at line 63 of file sanboot_cmd.c.

◆ sanhook

struct option_descriptor sanhook[2]

Definition at line 65 of file sanboot_cmd.c.

◆ sanunhook

struct option_descriptor sanunhook[1]

Definition at line 67 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:91
A text label widget.
Definition: label.h:16
int parse_uuid(char *text, struct uuid_option *uuid)
Parse UUID.
Definition: parseopt.c:135
A universally unique ID.
Definition: uuid.h:15
uint8_t extra
Signature extra byte.
Definition: smbios.h:17
uint8_t drive
Drive number.
Definition: int13.h:16
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:73
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:226
"sanboot" options
Definition: sanboot_cmd.c:43
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:67
Option requires an argument.
Definition: getopt.h:18

"sanboot" option list

Referenced by sanboot_core_exec().

◆ sanhook_cmd

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

"sanhook" command descriptor

Definition at line 88 of file sanboot_cmd.c.

Referenced by sanhook_exec().

◆ sanboot_cmd

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

"sanboot" command descriptor

Definition at line 93 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 )
static union @441 opts
"sanboot" option list
"sanboot" options
Definition: sanboot_cmd.c:43
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

"sanunhook" command descriptor

Definition at line 98 of file sanboot_cmd.c.

Referenced by sanunhook_exec().

◆ __command

struct command sanboot_commands [] __command
Initial value:
= {
{
.name = "sanhook",
.exec = sanhook_exec,
},
{
.name = "sanboot",
.exec = sanboot_exec,
},
{
.name = "sanunhook",
.exec = sanunhook_exec,
},
}
static int sanboot_exec(int argc, char **argv)
The "sanboot" command.
Definition: sanboot_cmd.c:188
static int sanhook_exec(int argc, char **argv)
The "sanhook" command.
Definition: sanboot_cmd.c:175
static int sanunhook_exec(int argc, char **argv)
The "sanunhook" command.
Definition: sanboot_cmd.c:200

SAN commands.

Definition at line 207 of file sanboot_cmd.c.