Skip to content

Commit

Permalink
hdt: Adding postexec= option
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
ErwanAliasr1 committed Dec 17, 2011
1 parent 6ce64e6 commit c0c25b4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
22 changes: 22 additions & 0 deletions com32/hdt/hdt-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions com32/hdt/hdt-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions com32/hdt/hdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit c0c25b4

Please sign in to comment.