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 [4]
 
   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 99 of file sanboot_cmd.c.

101  {
102  struct sanboot_options opts;
103  struct uri *uris[argc];
104  int count;
105  int flags;
106  int i;
107  int rc;
108 
109  /* Initialise options */
110  memset ( &opts, 0, sizeof ( opts ) );
111  opts.drive = san_default_drive();
112 
113  /* Parse options */
114  if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
115  goto err_parse_options;
116 
117  /* Parse root paths, if present */
118  count = ( argc - optind );
119  for ( i = 0 ; i < count ; i++ ) {
120  uris[i] = parse_uri ( argv[ optind + i ] );
121  if ( ! uris[i] ) {
122  rc = -ENOMEM;
123  goto err_parse_uri;
124  }
125  }
126 
127  /* Construct flags */
128  flags = default_flags;
129  if ( opts.no_describe )
131  if ( opts.keep )
133  if ( ! count )
134  flags |= no_root_path_flags;
135 
136  /* Boot from root path */
137  if ( ( rc = uriboot ( NULL, uris, count, opts.drive, opts.filename,
138  flags ) ) != 0 )
139  goto err_uriboot;
140 
141  err_uriboot:
142  i = count;
143  err_parse_uri:
144  for ( i-- ; i >= 0 ; i-- )
145  uri_put ( uris[i] );
146  err_parse_options:
147  return rc;
148 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:188
int optind
Current option index.
Definition: getopt.c:51
unsigned int san_default_drive(void)
Get default SAN drive number.
Definition: sanboot.c:956
int uriboot(struct uri *filename, struct uri **root_paths, unsigned int root_path_count, int drive, const char *san_filename, unsigned int flags)
Boot from filename and root-path URIs.
Definition: autoboot.c:125
#define ENOMEM
Not enough space.
Definition: errno.h:534
int reparse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Reparse command-line options.
Definition: parseopt.c:364
"sanboot" options
Definition: sanboot_cmd.c:43
uint16_t count
Number of entries.
Definition: ena.h:22
A Uniform Resource Identifier.
Definition: uri.h:50
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
static union @425 opts
"sanboot" option list
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:295
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t flags
Flags.
Definition: ena.h:18

References cmd, count, ENOMEM, flags, memset(), NULL, optind, opts, parse_uri(), rc, reparse_options(), san_default_drive(), uri_put(), uriboot(), URIBOOT_NO_SAN_DESCRIBE, and URIBOOT_NO_SAN_UNHOOK.

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

157  {
158  return sanboot_core_exec ( argc, argv, &sanhook_cmd,
160  URIBOOT_NO_SAN_UNHOOK ), 0 );
161 }
static struct command_descriptor sanhook_cmd
"sanhook" command descriptor
Definition: sanboot_cmd.c:77
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:99

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

170  {
171  return sanboot_core_exec ( argc, argv, &sanboot_cmd,
173 }
static struct command_descriptor sanboot_cmd
"sanboot" command descriptor
Definition: sanboot_cmd.c:82
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:99

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

182  {
183  return sanboot_core_exec ( argc, argv, &sanunhook_cmd,
185  URIBOOT_NO_SAN_BOOT ), 0 );
186 }
static struct command_descriptor sanunhook_cmd
"sanunhook" command descriptor
Definition: sanboot_cmd.c:87
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:99

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

Variable Documentation

◆ sanboot

struct option_descriptor sanboot[4]

Definition at line 57 of file sanboot_cmd.c.

◆ sanhook

struct option_descriptor sanhook[2]

Definition at line 59 of file sanboot_cmd.c.

◆ sanunhook

struct option_descriptor sanunhook[1]

Definition at line 61 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 ),
},
}
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:88
uint8_t drive
Drive number.
Definition: int13.h:16
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
"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:66
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>" )
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:96
"sanboot" options
Definition: sanboot_cmd.c:43
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
static union @425 opts
"sanboot" option list

"sanhook" command descriptor

Definition at line 77 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:96
"sanboot" options
Definition: sanboot_cmd.c:43
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
static union @425 opts
"sanboot" option list

"sanboot" command descriptor

Definition at line 82 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:43
#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:362
static union @425 opts
"sanboot" option list

"sanunhook" command descriptor

Definition at line 87 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:170
static int sanhook_exec(int argc, char **argv)
The "sanhook" command.
Definition: sanboot_cmd.c:157
static int sanunhook_exec(int argc, char **argv)
The "sanunhook" command.
Definition: sanboot_cmd.c:182

SAN commands.

Definition at line 189 of file sanboot_cmd.c.