2010-11-21 20:55:51 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2008-03-04 18:59:26 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2011-01-27 19:48:47 +01:00
|
|
|
#include <errno.h>
|
2008-03-04 18:59:26 +01:00
|
|
|
#include <getopt.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/command.h>
|
2010-11-21 20:55:51 +01:00
|
|
|
#include <ipxe/parseopt.h>
|
2011-01-27 19:48:47 +01:00
|
|
|
#include <ipxe/uri.h>
|
2008-03-04 18:59:26 +01:00
|
|
|
#include <usr/autoboot.h>
|
|
|
|
|
2009-05-01 16:41:06 +02:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
|
|
|
2010-11-21 20:55:51 +01:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* SAN commands
|
2008-03-04 18:59:26 +01:00
|
|
|
*
|
|
|
|
*/
|
2010-11-21 20:55:51 +01:00
|
|
|
|
|
|
|
/** "sanboot" options */
|
|
|
|
struct sanboot_options {};
|
|
|
|
|
|
|
|
/** "sanboot" option list */
|
|
|
|
static struct option_descriptor sanboot_opts[] = {};
|
|
|
|
|
|
|
|
/** "sanboot" command descriptor */
|
|
|
|
static struct command_descriptor sanboot_cmd =
|
|
|
|
COMMAND_DESC ( struct sanboot_options, sanboot_opts, 1, 1,
|
2011-03-04 13:14:51 +01:00
|
|
|
"<root-path>" );
|
2008-03-04 18:59:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The "sanboot" command
|
|
|
|
*
|
|
|
|
* @v argc Argument count
|
|
|
|
* @v argv Argument list
|
2010-11-21 20:55:51 +01:00
|
|
|
* @ret rc Return status code
|
2008-03-04 18:59:26 +01:00
|
|
|
*/
|
|
|
|
static int sanboot_exec ( int argc, char **argv ) {
|
2010-11-21 20:55:51 +01:00
|
|
|
struct sanboot_options opts;
|
|
|
|
const char *root_path;
|
2011-01-27 19:48:47 +01:00
|
|
|
struct uri *uri;
|
2008-03-04 18:59:26 +01:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Parse options */
|
2010-11-21 20:55:51 +01:00
|
|
|
if ( ( rc = parse_options ( argc, argv, &sanboot_cmd, &opts ) ) != 0 )
|
2011-01-27 19:48:47 +01:00
|
|
|
goto err_parse_options;
|
2008-03-04 18:59:26 +01:00
|
|
|
|
2010-11-21 20:55:51 +01:00
|
|
|
/* Parse root path */
|
2008-03-04 18:59:26 +01:00
|
|
|
root_path = argv[optind];
|
2011-01-27 19:48:47 +01:00
|
|
|
uri = parse_uri ( root_path );
|
|
|
|
if ( ! uri ) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_parse_uri;
|
|
|
|
}
|
2008-03-04 18:59:26 +01:00
|
|
|
|
|
|
|
/* Boot from root path */
|
2011-01-27 19:48:47 +01:00
|
|
|
if ( ( rc = uriboot ( NULL, uri ) ) != 0 ) {
|
2008-03-04 18:59:26 +01:00
|
|
|
printf ( "Could not boot from %s: %s\n",
|
|
|
|
root_path, strerror ( rc ) );
|
2011-01-27 19:48:47 +01:00
|
|
|
goto err_uriboot;
|
2008-03-04 18:59:26 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 19:48:47 +01:00
|
|
|
err_uriboot:
|
|
|
|
uri_put ( uri );
|
|
|
|
err_parse_uri:
|
|
|
|
err_parse_options:
|
|
|
|
return rc;
|
2008-03-04 18:59:26 +01:00
|
|
|
}
|
|
|
|
|
2010-11-21 20:55:51 +01:00
|
|
|
/** SAN commands */
|
2008-03-04 18:59:26 +01:00
|
|
|
struct command sanboot_command __command = {
|
|
|
|
.name = "sanboot",
|
|
|
|
.exec = sanboot_exec,
|
|
|
|
};
|