sanboot_cmd.c File Reference

#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <gpxe/command.h>
#include <usr/autoboot.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void sanboot_syntax (char **argv)
 "sanboot" command syntax message
static int sanboot_exec (int argc, char **argv)
 The "sanboot" command.

Variables

struct command sanboot_command __command


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void sanboot_syntax ( char **  argv  )  [static]

"sanboot" command syntax message

Parameters:
argv Argument list

Definition at line 14 of file sanboot_cmd.c.

References printf().

Referenced by sanboot_exec().

00014                                            {
00015         printf ( "Usage:\n"
00016                  "  %s <root-path>\n"
00017                  "\n"
00018                  "Boot from SAN target\n",
00019                  argv[0] );
00020 }

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

The "sanboot" command.

Parameters:
argc Argument count
argv Argument list
Return values:
rc Exit code

Definition at line 29 of file sanboot_cmd.c.

References boot_root_path(), getopt_long(), NULL, optind, printf(), sanboot_syntax(), and strerror().

00029                                                   {
00030         static struct option longopts[] = {
00031                 { "help", 0, NULL, 'h' },
00032                 { NULL, 0, NULL, 0 },
00033         };
00034         const char *root_path = NULL;
00035         int c;
00036         int rc;
00037 
00038         /* Parse options */
00039         while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
00040                 switch ( c ) {
00041                 case 'h':
00042                         /* Display help text */
00043                 default:
00044                         /* Unrecognised/invalid option */
00045                         sanboot_syntax ( argv );
00046                         return 1;
00047                 }
00048         }
00049 
00050         /* Need exactly one image name remaining after the options */
00051         if ( optind != ( argc - 1 ) ) {
00052                 sanboot_syntax ( argv );
00053                 return 1;
00054         }
00055         root_path = argv[optind];
00056 
00057         /* Boot from root path */
00058         if ( ( rc = boot_root_path ( root_path ) ) != 0 ) {
00059                 printf ( "Could not boot from %s: %s\n",
00060                          root_path, strerror ( rc ) );
00061                 return 1;
00062         }
00063 
00064         return 0;
00065 }


Variable Documentation

struct command sanboot_command __command

Initial value:

 {
        .name = "sanboot",
        .exec = sanboot_exec,
}

Definition at line 67 of file sanboot_cmd.c.


Generated on Tue Apr 6 20:01:46 2010 for gPXE by  doxygen 1.5.7.1