mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-29 04:39:42 +00:00
[Command] Add "sanboot" command.
This commit is contained in:
parent
844828cb15
commit
b08a6f5300
@ -125,6 +125,7 @@
|
||||
#define ROUTE_CMD /* Routing table management commands */
|
||||
#define IMAGE_CMD /* Image management commands */
|
||||
#define DHCP_CMD /* DHCP management commands */
|
||||
#define SANBOOT_CMD /* SAN boot commands */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
|
@ -175,6 +175,9 @@ REQUIRE_OBJECT ( image_cmd );
|
||||
#ifdef DHCP_CMD
|
||||
REQUIRE_OBJECT ( dhcp_cmd );
|
||||
#endif
|
||||
#ifdef SANBOOT_CMD
|
||||
REQUIRE_OBJECT ( sanboot_cmd );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Drag in miscellaneous objects
|
||||
|
68
src/hci/commands/sanboot_cmd.c
Normal file
68
src/hci/commands/sanboot_cmd.c
Normal file
@ -0,0 +1,68 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <gpxe/command.h>
|
||||
#include <usr/autoboot.h>
|
||||
|
||||
/**
|
||||
* "sanboot" command syntax message
|
||||
*
|
||||
* @v argv Argument list
|
||||
*/
|
||||
static void sanboot_syntax ( char **argv ) {
|
||||
printf ( "Usage:\n"
|
||||
" %s <root-path>\n"
|
||||
"\n"
|
||||
"Boot from SAN target\n",
|
||||
argv[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* The "sanboot" command
|
||||
*
|
||||
* @v argc Argument count
|
||||
* @v argv Argument list
|
||||
* @ret rc Exit code
|
||||
*/
|
||||
static int sanboot_exec ( int argc, char **argv ) {
|
||||
static struct option longopts[] = {
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
const char *root_path = NULL;
|
||||
int c;
|
||||
int rc;
|
||||
|
||||
/* Parse options */
|
||||
while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
|
||||
switch ( c ) {
|
||||
case 'h':
|
||||
/* Display help text */
|
||||
default:
|
||||
/* Unrecognised/invalid option */
|
||||
sanboot_syntax ( argv );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Need exactly one image name remaining after the options */
|
||||
if ( optind != ( argc - 1 ) ) {
|
||||
sanboot_syntax ( argv );
|
||||
return 1;
|
||||
}
|
||||
root_path = argv[optind];
|
||||
|
||||
/* Boot from root path */
|
||||
if ( ( rc = boot_root_path ( root_path ) ) != 0 ) {
|
||||
printf ( "Could not boot from %s: %s\n",
|
||||
root_path, strerror ( rc ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct command sanboot_command __command = {
|
||||
.name = "sanboot",
|
||||
.exec = sanboot_exec,
|
||||
};
|
@ -8,5 +8,6 @@
|
||||
*/
|
||||
|
||||
extern void autoboot ( void );
|
||||
extern int boot_root_path ( const char *root_path );
|
||||
|
||||
#endif /* _USR_AUTOBOOT_H */
|
||||
|
@ -108,7 +108,7 @@ static int boot_filename ( const char *filename ) {
|
||||
* @v root_path Root path
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int boot_root_path ( const char *root_path ) {
|
||||
int boot_root_path ( const char *root_path ) {
|
||||
|
||||
/* Quick hack */
|
||||
if ( strncmp ( root_path, "iscsi:", 6 ) == 0 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user