summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2008-03-04 18:59:26 +0100
committerMichael Brown2008-03-04 18:59:26 +0100
commitb08a6f530042cfc0f8be2209cde9fab3d0ab9143 (patch)
tree85441416f1ca65f97d4ba0ef57d3b8f7e955f5d7 /src
parent[DHCP] Fix RFC4390 client identifier constructions. (diff)
downloadipxe-b08a6f530042cfc0f8be2209cde9fab3d0ab9143.tar.gz
ipxe-b08a6f530042cfc0f8be2209cde9fab3d0ab9143.tar.xz
ipxe-b08a6f530042cfc0f8be2209cde9fab3d0ab9143.zip
[Command] Add "sanboot" command.
Diffstat (limited to 'src')
-rw-r--r--src/config.h1
-rw-r--r--src/core/config.c3
-rw-r--r--src/hci/commands/sanboot_cmd.c68
-rw-r--r--src/include/usr/autoboot.h1
-rw-r--r--src/usr/autoboot.c2
5 files changed, 74 insertions, 1 deletions
diff --git a/src/config.h b/src/config.h
index 9aa9e8fdf..e5d8b114d 100644
--- a/src/config.h
+++ b/src/config.h
@@ -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 */
diff --git a/src/core/config.c b/src/core/config.c
index d5accecfe..e7db221a6 100644
--- a/src/core/config.c
+++ b/src/core/config.c
@@ -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
diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c
new file mode 100644
index 000000000..d5bbfb859
--- /dev/null
+++ b/src/hci/commands/sanboot_cmd.c
@@ -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,
+};
diff --git a/src/include/usr/autoboot.h b/src/include/usr/autoboot.h
index 4ddeb5bcc..b451a8c1c 100644
--- a/src/include/usr/autoboot.h
+++ b/src/include/usr/autoboot.h
@@ -8,5 +8,6 @@
*/
extern void autoboot ( void );
+extern int boot_root_path ( const char *root_path );
#endif /* _USR_AUTOBOOT_H */
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index c3b07e9a6..b84bd7b17 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -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 ) {