aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerwan <erwan@laptopR1.(none)>2009-03-08 11:26:03 +0100
committererwan <erwan@laptopR1.(none)>2009-03-08 11:26:03 +0100
commit235a1968999eacf333005910136c6c62e85bd22e (patch)
treec0d5526b65ceb01de269c507d673d711679b6168
parentdb688a5c86074a5dcc842a71cc417ae6a6c26915 (diff)
downloadsyslinux-elf-235a1968999eacf333005910136c6c62e85bd22e.tar.gz
syslinux-elf-235a1968999eacf333005910136c6c62e85bd22e.tar.xz
syslinux-elf-235a1968999eacf333005910136c6c62e85bd22e.zip
hdt: preventing pxe mode being reach w/o pxelinux
If the current bootloader isn't pxelinux, the pxe mode mustn't be available in the cli mode The syslinux detection have been refactorised too
-rw-r--r--com32/hdt/hdt-cli-pxe.c5
-rw-r--r--com32/hdt/hdt-cli.c12
-rw-r--r--com32/hdt/hdt-common.c17
-rw-r--r--com32/hdt/hdt-common.h4
-rw-r--r--com32/hdt/hdt-menu-syslinux.c37
-rw-r--r--com32/hdt/hdt-menu.c2
-rw-r--r--com32/hdt/hdt-menu.h2
-rw-r--r--com32/hdt/hdt.c3
8 files changed, 49 insertions, 33 deletions
diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index ea190934..c88d4449 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -33,10 +33,15 @@
#include <stdlib.h>
#include <errno.h>
#include <syslinux/pxe.h>
+#include <syslinux/config.h>
void main_show_pxe(struct s_hardware *hardware,struct s_cli_mode *cli_mode) {
char buffer[81];
memset(buffer,0,sizeof(81));
+ if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX) {
+ more_printf("You are not currently using PXELINUX\n");
+ return;
+ }
detect_pxe(hardware);
more_printf("PXE\n");
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 5847d7ff..a92d5f5c 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -30,6 +30,7 @@
#include "hdt-common.h"
#include <stdlib.h>
#include <string.h>
+#include <syslinux/config.h>
void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *hardware) {
switch (mode) {
@@ -44,6 +45,10 @@ void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *h
break;
case PXE_MODE:
+ if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX) {
+ more_printf("You are not currently using PXELINUX\n");
+ break;
+ }
cli_mode->mode=mode;
snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ", CLI_PXE);
break;
@@ -213,14 +218,15 @@ void main_show_summary(struct s_hardware *hardware, struct s_cli_mode *cli_mode)
main_show_kernel(hardware,cli_mode);
}
-void show_main_help() {
+void show_main_help(struct s_hardware *hardware) {
more_printf("Show supports the following commands : \n");
more_printf(" %s\n",CLI_SUMMARY);
more_printf(" %s\n",CLI_PCI);
more_printf(" %s\n",CLI_DMI);
more_printf(" %s\n",CLI_CPU);
- more_printf(" %s\n",CLI_PXE);
more_printf(" %s\n",CLI_KERNEL);
+ if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX)
+ more_printf(" %s\n",CLI_PXE);
}
void main_show(char *item, struct s_hardware *hardware, struct s_cli_mode *cli_mode) {
@@ -230,5 +236,5 @@ void main_show(char *item, struct s_hardware *hardware, struct s_cli_mode *cli_m
if (!strncmp(item,CLI_CPU, sizeof (CLI_CPU))) { main_show_cpu(hardware,cli_mode); return; }
if (!strncmp(item,CLI_PXE, sizeof (CLI_PXE))) { main_show_pxe(hardware,cli_mode); return; }
if (!strncmp(item,CLI_KERNEL, sizeof (CLI_KERNEL))) { main_show_kernel(hardware,cli_mode); return; }
- show_main_help();
+ show_main_help(hardware);
}
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 231c35fc..39af9483 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -32,6 +32,18 @@
#include <stdio.h>
#include "syslinux/config.h"
+void detect_syslinux(struct s_hardware *hardware) {
+ hardware->sv = syslinux_version();
+ switch(hardware->sv->filesystem) {
+ case SYSLINUX_FS_SYSLINUX: strlcpy(hardware->syslinux_fs,"SYSlinux",9); break;
+ case SYSLINUX_FS_PXELINUX: strlcpy(hardware->syslinux_fs,"PXElinux",9); break;
+ case SYSLINUX_FS_ISOLINUX: strlcpy(hardware->syslinux_fs,"ISOlinux",9); break;
+ case SYSLINUX_FS_EXTLINUX: strlcpy(hardware->syslinux_fs,"EXTlinux",9); break;
+ case SYSLINUX_FS_UNKNOWN:
+ default: strlcpy(hardware->syslinux_fs,"Unknown Bootloader",sizeof hardware->syslinux_fs); break;
+ }
+}
+
void init_hardware(struct s_hardware *hardware) {
hardware->pci_ids_return_code=0;
hardware->modules_pcimap_return_code=0;
@@ -50,6 +62,7 @@ void init_hardware(struct s_hardware *hardware) {
memset(&hardware->dmi,0,sizeof(s_dmi));
memset(&hardware->cpu,0,sizeof(s_cpu));
memset(&hardware->pxe,0,sizeof(struct s_pxe));
+ memset(hardware->syslinux_fs,0,sizeof hardware->syslinux_fs);
}
/* Detecting if a DMI table exist
@@ -82,7 +95,6 @@ int detect_pxe(struct s_hardware *hardware) {
void *dhcpdata;
size_t dhcplen;
- const struct syslinux_version *sv;
t_PXENV_UNDI_GET_NIC_TYPE gnt;
if (hardware->pxe_detection == true) return -1;
@@ -91,9 +103,8 @@ int detect_pxe(struct s_hardware *hardware) {
memset(&gnt,0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
memset(&hardware->pxe,0, sizeof(struct s_pxe));
- sv = syslinux_version();
/* This code can only work if pxelinux is loaded*/
- if (sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
return -1;
}
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 04a46e42..5cf80603 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -93,6 +93,9 @@ struct s_hardware {
bool cpu_detection; /* Does the cpu stuff have been already detected */
bool disk_detection; /* Does the disk stuff have been already detected */
bool pxe_detection; /* Does the pxe stuff have been already detected*/
+
+ char syslinux_fs[22];
+ struct syslinux_version *sv;
};
char *find_argument(const char **argv, const char *argument);
@@ -103,4 +106,5 @@ void cpu_detect(struct s_hardware *hardware);
int detect_pxe(struct s_hardware *hardware);
void init_hardware(struct s_hardware *hardware);
void clear_screen(void);
+void detect_syslinux(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-menu-syslinux.c b/com32/hdt/hdt-menu-syslinux.c
index 4ee6d1dd..d17070f8 100644
--- a/com32/hdt/hdt-menu-syslinux.c
+++ b/com32/hdt/hdt-menu-syslinux.c
@@ -30,55 +30,42 @@
#include "hdt-menu.h"
/* Computing Syslinux menu*/
-void compute_syslinuxmenu(struct s_my_menu *menu) {
- char syslinux_fs[22];
+void compute_syslinuxmenu(struct s_my_menu *menu, struct s_hardware *hardware) {
char syslinux_fs_menu[24];
char buffer[SUBMENULEN+1];
char statbuffer[STATLEN+1];
- const struct syslinux_version *sv;
-
- memset(syslinux_fs,0,sizeof syslinux_fs);
memset(syslinux_fs_menu,0,sizeof syslinux_fs_menu);
- sv = syslinux_version();
- switch(sv->filesystem) {
- case SYSLINUX_FS_SYSLINUX: strlcpy(syslinux_fs,"SYSlinux",9); break;
- case SYSLINUX_FS_PXELINUX: strlcpy(syslinux_fs,"PXElinux",9); break;
- case SYSLINUX_FS_ISOLINUX: strlcpy(syslinux_fs,"ISOlinux",9); break;
- case SYSLINUX_FS_EXTLINUX: strlcpy(syslinux_fs,"EXTlinux",9); break;
- case SYSLINUX_FS_UNKNOWN:
- default: strlcpy(syslinux_fs,"Unknown Bootloader",sizeof syslinux_fs); break;
- }
- snprintf(syslinux_fs_menu,sizeof syslinux_fs_menu," %s ",syslinux_fs);
+ snprintf(syslinux_fs_menu,sizeof syslinux_fs_menu," %s ",hardware->syslinux_fs);
menu->menu = add_menu(syslinux_fs_menu,-1);
menu->items_count=0;
set_menu_pos(SUBMENU_Y,SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Bootloader : %s", syslinux_fs);
- snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", syslinux_fs);
+ snprintf(buffer, sizeof buffer, "Bootloader : %s", hardware->syslinux_fs);
+ snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", hardware->syslinux_fs);
add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %s", sv->version_string+2);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s", sv->version_string+2);
+ snprintf(buffer, sizeof buffer, "Version : %s", hardware->sv->version_string+2);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s", hardware->sv->version_string+2);
add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %u",sv->version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %u",sv->version);
+ snprintf(buffer, sizeof buffer, "Version : %u",hardware->sv->version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %u",hardware->sv->version);
add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Max API : %u",sv->max_api);
- snprintf(statbuffer, sizeof statbuffer, "Max API: %u",sv->max_api);
+ snprintf(buffer, sizeof buffer, "Max API : %u",hardware->sv->max_api);
+ snprintf(statbuffer, sizeof statbuffer, "Max API: %u",hardware->sv->max_api);
add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
menu->items_count++;
add_item("","",OPT_SEP,"",0);
- snprintf(buffer, sizeof buffer, "%s", sv->copyright_string+1);
- snprintf(statbuffer, sizeof statbuffer, "%s", sv->copyright_string+1);
+ snprintf(buffer, sizeof buffer, "%s", hardware->sv->copyright_string+1);
+ snprintf(statbuffer, sizeof statbuffer, "%s", hardware->sv->copyright_string+1);
add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
menu->items_count++;
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 7380a079..0853f09e 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -144,7 +144,7 @@ void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
compute_kernel(&(hdt_menu->kernel_menu),hardware);
#endif
compute_summarymenu(&(hdt_menu->summary_menu),hardware);
- compute_syslinuxmenu(&(hdt_menu->syslinux_menu));
+ compute_syslinuxmenu(&(hdt_menu->syslinux_menu),hardware);
compute_aboutmenu(&(hdt_menu->about_menu));
}
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index 19986ccf..db94057a 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -102,7 +102,7 @@ void compute_memory_module(struct s_my_menu *menu, s_dmi *dmi, int slot_number);
void compute_processor(struct s_my_menu *menu,struct s_hardware *hardware);
// Syslinux stuff
-void compute_syslinuxmenu(struct s_my_menu *menu);
+void compute_syslinuxmenu(struct s_my_menu *menu,struct s_hardware *hardware);
// About menu
void compute_aboutmenu(struct s_my_menu *menu);
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index c96d0b97..ec667c3c 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -52,6 +52,9 @@ int main(int argc, char *argv[])
/* Cleaning structures */
init_hardware(&hardware);
+ /* Detecting Syslinux Version*/
+ detect_syslinux(&hardware);
+
/* Opening the syslinux console */
openconsole(&dev_stdcon_r, &dev_ansicon_w);