sanboot_cmd.c
Go to the documentation of this file.00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <getopt.h>
00004 #include <gpxe/command.h>
00005 #include <usr/autoboot.h>
00006
00007 FILE_LICENCE ( GPL2_OR_LATER );
00008
00009
00010
00011
00012
00013
00014 static void sanboot_syntax ( char **argv ) {
00015 printf ( "Usage:\n"
00016 " %s <root-path>\n"
00017 "\n"
00018 "Boot from SAN target\n",
00019 argv[0] );
00020 }
00021
00022
00023
00024
00025
00026
00027
00028
00029 static int sanboot_exec ( int argc, char **argv ) {
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
00039 while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
00040 switch ( c ) {
00041 case 'h':
00042
00043 default:
00044
00045 sanboot_syntax ( argv );
00046 return 1;
00047 }
00048 }
00049
00050
00051 if ( optind != ( argc - 1 ) ) {
00052 sanboot_syntax ( argv );
00053 return 1;
00054 }
00055 root_path = argv[optind];
00056
00057
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 }
00066
00067 struct command sanboot_command __command = {
00068 .name = "sanboot",
00069 .exec = sanboot_exec,
00070 };