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

Variables

union {
   struct option_descriptor   sanboot [4]
   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
struct command sanboot_commands[] __command
 SAN commands.

Detailed Description

SAN commands.

Definition in file sanboot_cmd.c.


Function Documentation

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

References count, sanboot_options::drive, ENOMEM, sanboot_options::filename, flags, sanboot_options::keep, memset(), sanboot_options::no_describe, NULL, optind, 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().

                                                                           {
        struct sanboot_options opts;
        struct uri *uris[argc];
        int count;
        int flags;
        int i;
        int rc;

        /* Initialise options */
        memset ( &opts, 0, sizeof ( opts ) );
        opts.drive = san_default_drive();

        /* Parse options */
        if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
                goto err_parse_options;

        /* Parse root paths, if present */
        count = ( argc - optind );
        for ( i = 0 ; i < count ; i++ ) {
                uris[i] = parse_uri ( argv[ optind + i ] );
                if ( ! uris[i] ) {
                        rc = -ENOMEM;
                        goto err_parse_uri;
                }
        }

        /* Construct flags */
        flags = default_flags;
        if ( opts.no_describe )
                flags |= URIBOOT_NO_SAN_DESCRIBE;
        if ( opts.keep )
                flags |= URIBOOT_NO_SAN_UNHOOK;
        if ( ! count )
                flags |= no_root_path_flags;

        /* Boot from root path */
        if ( ( rc = uriboot ( NULL, uris, count, opts.drive, opts.filename,
                              flags ) ) != 0 )
                goto err_uriboot;

 err_uriboot:
        i = count;
 err_parse_uri:
        for ( i-- ; i >= 0 ; i-- )
                uri_put ( uris[i] );
 err_parse_options:
        return rc;
}
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.

References sanboot_core_exec(), URIBOOT_NO_SAN_BOOT, and URIBOOT_NO_SAN_UNHOOK.

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.

References sanboot_core_exec(), and URIBOOT_NO_SAN_UNHOOK.

                                                  {
        return sanboot_core_exec ( argc, argv, &sanboot_cmd,
                                   0, URIBOOT_NO_SAN_UNHOOK );
}
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.

References sanboot_core_exec(), URIBOOT_NO_SAN_BOOT, and URIBOOT_NO_SAN_DESCRIBE.


Variable Documentation

Definition at line 57 of file sanboot_cmd.c.

Definition at line 59 of file sanboot_cmd.c.

Definition at line 61 of file sanboot_cmd.c.

union { ... } opts [static]

"sanboot" option list

Initial value:
        COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, MAX_ARGUMENTS,
                       "<root-path>" )

"sanhook" command descriptor

Definition at line 77 of file sanboot_cmd.c.

Initial value:
        COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, MAX_ARGUMENTS,
                       "[<root-path>]" )

"sanboot" command descriptor

Definition at line 82 of file sanboot_cmd.c.

Initial value:
        COMMAND_DESC ( struct sanboot_options, opts.sanunhook, 0, 0, NULL )

"sanunhook" command descriptor

Definition at line 87 of file sanboot_cmd.c.

struct command sanboot_commands [] __command
Initial value:
 {
        {
                .name = "sanhook",
                .exec = sanhook_exec,
        },
        {
                .name = "sanboot",
                .exec = sanboot_exec,
        },
        {
                .name = "sanunhook",
                .exec = sanunhook_exec,
        },
}

SAN commands.

Definition at line 189 of file sanboot_cmd.c.