aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-12-17 22:27:07 +0100
committerErwan Velu <erwanaliasr1@gmail.com>2011-12-17 22:27:07 +0100
commitc0c25b4826950162517896c5039c6d62d07115be (patch)
tree8b01e89ed4cce1dbc1eb9f1c518117d51383ed41
parent6ce64e6166ecbdbd137513025d108e8ea904c2ec (diff)
downloadsyslinux-c0c25b4826950162517896c5039c6d62d07115be.tar.gz
syslinux-c0c25b4826950162517896c5039c6d62d07115be.tar.xz
syslinux-c0c25b4826950162517896c5039c6d62d07115be.zip
hdt: Adding postexec= option
When HDT is exiting, you might need executing something else. This could be used in the following scenario : You start HDT, do an automatic command like 'dump; exit', but then after you might need to launch something else from syslinux. The postexec option will allow you to define what label you'd love running one HDT got terminated. Syntaxt is like the following: postexec='menu_label_to_run_once_hdt_got_exited' Note the quotes (') after the equal sign (=) This could looks like : APPEND auto='dump; exit' postexec='memtest'
-rw-r--r--com32/hdt/hdt-common.c22
-rw-r--r--com32/hdt/hdt-common.h1
-rw-r--r--com32/hdt/hdt.c15
3 files changed, 34 insertions, 4 deletions
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 1857cc0b..8e9a9e64 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -115,6 +115,27 @@ void detect_parameters(const int argc, const char *argv[],
} else if (!strncmp(argv[i], "tftp_ip=", 8)) {
strlcpy(hardware->tftp_ip, argv[i] + 8,
sizeof(hardware->tftp_ip));
+ } else if (!strncmp(argv[i], "postexec=", 9)) {
+ /* The postexec= parameter is separated in several argv[]
+ * as it can contains spaces.
+ * We use the AUTO_DELIMITER char to define the limits
+ * of this parameter.
+ * i.e postexec='linux memtest.bin'
+ */
+
+ char *argument = (char*)argv[i]+10;
+ /* Extracting the first parameter */
+ strcpy(hardware->postexec, argument);
+
+ /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
+ while ((strchr(argument, AUTO_DELIMITER) == NULL) && (i+1<argc)) {
+ i++;
+ argument = (char *)argv[i];
+ strcat(hardware->postexec, " ");
+ strcat(hardware->postexec, argument);
+ }
+
+ hardware->postexec[strlen(hardware->postexec) - 1] = 0;
} else if (!strncmp(argv[i], "auto=", 5)) {
/* The auto= parameter is separated in several argv[]
* as it can contains spaces.
@@ -210,6 +231,7 @@ void init_hardware(struct s_hardware *hardware)
memset(hardware->dump_filename, 0, sizeof hardware->dump_filename);
memset(hardware->vesa_background, 0, sizeof hardware->vesa_background);
memset(hardware->tftp_ip, 0, sizeof hardware->tftp_ip);
+ memset(hardware->postexec, 0, sizeof hardware->postexec);
strcat(hardware->dump_path, "hdt");
strcat(hardware->dump_filename, "%{m}+%{p}+%{v}");
strcat(hardware->pciids_path, "pci.ids");
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index f007e72f..8c85260b 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -219,6 +219,7 @@ struct s_hardware {
char memtest_label[255];
char auto_label[AUTO_COMMAND_SIZE];
char vesa_background[255];
+ char postexec[255];
};
void reset_more_printf(void);
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index a1e3923c..851b0462 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -74,14 +74,21 @@ int main(const int argc, const char *argv[])
printf("%s\n", version_string);
+ int return_code = 0;
+
if (!menumode || automode)
start_cli_mode(&hardware);
else {
- int return_code = start_menu_mode(&hardware, version_string);
+ return_code = start_menu_mode(&hardware, version_string);
if (return_code == HDT_RETURN_TO_CLI)
start_cli_mode(&hardware);
- else
- return return_code;
}
- return 0;
+
+ /* Do we got request to do something at exit time ? */
+ if (strlen(hardware.postexec)>0) {
+ printf("Executing postexec instructions : %s\n",hardware.postexec);
+ runsyslinuxcmd(hardware.postexec);
+ }
+
+ return return_code;
}