summaryrefslogtreecommitdiff
path: root/com32/hdt
diff options
context:
space:
mode:
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/.gitignore1
-rw-r--r--com32/hdt/Makefile8
-rw-r--r--com32/hdt/hdt-common.c27
-rw-r--r--com32/hdt/hdt-common.h2
-rw-r--r--com32/hdt/hdt-dump-disks.c12
-rw-r--r--com32/hdt/hdt-dump.c192
-rw-r--r--com32/hdt/hdt-menu-summary.c3
-rw-r--r--com32/hdt/hdt.c15
-rw-r--r--com32/hdt/hdt.h4
9 files changed, 187 insertions, 77 deletions
diff --git a/com32/hdt/.gitignore b/com32/hdt/.gitignore
index 98927943..82d5b472 100644
--- a/com32/hdt/.gitignore
+++ b/com32/hdt/.gitignore
@@ -5,3 +5,4 @@ floppy/syslinux.cfg
*.iso
iso/
*gz
+hdt*checksums
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index f1873465..17fa1ab6 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -110,10 +110,16 @@ hdt.iso: hdt.c32 $(topdir)/core/isolinux.bin $(FLOPPY_DIR)/hdt.cfg memtest
mv hdt.iso hdt-$(VERSION).iso
ln -sf hdt-$(VERSION).iso hdt.iso
-release: spotless hdt.c32 hdt.img hdt.img.gz hdt.iso
+hdt-hybrid.iso: hdt.iso ../../utils/isohybrid
+ cp hdt-$(VERSION).iso hdt-hybrid-$(VERSION).iso
+ ../../utils/isohybrid --partok hdt-hybrid-$(VERSION).iso
+ ln -sf hdt-hybrid-$(VERSION).iso hdt-hybrid.iso
+
+release: spotless hdt.c32 hdt.img hdt.img.gz hdt.iso hdt-hybrid.iso
mv hdt.c32 hdt_$(NODASH_VERSION).c32
md5sum hdt_$(NODASH_VERSION).c32 >$(SUM_FILE)
md5sum hdt-$(VERSION).iso >>$(SUM_FILE)
+ md5sum hdt-hybrid-$(VERSION).iso >>$(SUM_FILE)
md5sum hdt-$(VERSION).img >>$(SUM_FILE)
md5sum hdt-$(VERSION).img.gz >>$(SUM_FILE)
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index aac50eb9..8e9a9e64 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -106,12 +106,36 @@ void detect_parameters(const int argc, const char *argv[],
max_console_lines = MAX_CLI_LINES;
} else if (!strncmp(argv[i], "nomenu", 6)) {
menumode = false;
+ } else if (!strncmp(argv[i], "dump_filename=", 14)) {
+ strlcpy(hardware->dump_filename, argv[i] + 14,
+ sizeof(hardware->dump_filename));
} else if (!strncmp(argv[i], "dump_path=", 10)) {
strlcpy(hardware->dump_path, argv[i] + 10,
sizeof(hardware->dump_path));
} 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.
@@ -204,9 +228,12 @@ void init_hardware(struct s_hardware *hardware)
memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
memset(hardware->auto_label, 0, sizeof hardware->auto_label);
memset(hardware->dump_path, 0, sizeof hardware->dump_path);
+ 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");
strcat(hardware->modules_pcimap_path, "modules.pcimap");
strcat(hardware->modules_alias_path, "modules.alias");
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index d37fcc8a..8c85260b 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -214,10 +214,12 @@ struct s_hardware {
char modules_alias_path[255];
char pciids_path[255];
char dump_path[255]; /* Dump path on the tftp server */
+ char dump_filename[255]; /* Dump filename on the tftp server */
char tftp_ip[255]; /* IP address of tftp server (dump mode) */
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-dump-disks.c b/com32/hdt/hdt-dump-disks.c
index dcbcaa9e..ff744b30 100644
--- a/com32/hdt/hdt-dump-disks.c
+++ b/com32/hdt/hdt-dump-disks.c
@@ -42,6 +42,7 @@ static void show_partition_information(struct driveinfo *drive_info,
char ostype[64]={0};
char *parttype;
unsigned int start, end;
+ char bootable[6] = {0};
int i = nb_partitions_seen;
start = partition_offset;
@@ -52,6 +53,10 @@ static void show_partition_information(struct driveinfo *drive_info,
get_label(ptab->ostype, &parttype);
get_bootloader_string(drive_info, ptab, bootloader_name, 9);
+ if (ptab->active_flag == 0x80)
+ snprintf(bootable,sizeof(bootable),"%s","true");
+ else
+ snprintf(bootable,sizeof(bootable),"%s","false");
snprintf(ostype,sizeof(ostype),"%02X",ptab->ostype);
@@ -62,6 +67,7 @@ static void show_partition_information(struct driveinfo *drive_info,
add_as("partition->size",size)
add_as("partition->type",parttype)
add_as("partition->os_type",ostype)
+ add_as("partition->boot_flag",bootable)
END_OF_APPEND;
free(parttype);
}
@@ -117,7 +123,9 @@ void show_disk(struct s_hardware *hardware, ZZJSON_CONFIG *conf, ZZJSON **it, in
void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
bool found=false;
- for (int drive = 0x80; drive < 0xff; drive++) {
+
+ if (hardware->disks_count > 0)
+ for (int drive = 0x80; drive < 0xff; drive++) {
if (hardware->disk_info[drive - 0x80].cbios) {
if (found==false) {
CREATE_NEW_OBJECT;
@@ -131,7 +139,7 @@ void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **ite
if (found==false) {
CREATE_NEW_OBJECT;
add_b("disks->is_valid",false);
- FLUSH_OBJECT;
}
+ FLUSH_OBJECT;
to_cpio("disks");
}
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index 8c221405..b963e19b 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -37,56 +37,117 @@
struct print_buf p_buf;
-void compute_filename(struct s_hardware *hardware, char *filename, int size) {
-
- snprintf(filename,size,"%s/",hardware->dump_path);
-
- if (hardware->is_pxe_valid) {
- strncat(filename, hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr));
- strncat(filename, "+", 1);
- }
-
- if (hardware->is_dmi_valid) {
- strncat(filename, remove_spaces(hardware->dmi.system.product_name), sizeof(hardware->dmi.system.manufacturer));
- strncat(filename, "+", 1);
- strncat(filename, remove_spaces(hardware->dmi.system.manufacturer), sizeof(hardware->dmi.system.product_name));
+struct dump_option {
+ char *flag;
+ char *item;
+};
+
+char *get_value_from_option(struct s_hardware *hardware, char *option)
+{
+ struct dump_option dump_options[10];
+ dump_options[0].flag = "%{m}";
+ dump_options[0].item = hardware->pxe.mac_addr;
+
+ dump_options[1].flag = "%{v}";
+ dump_options[1].item = hardware->dmi.system.manufacturer;
+
+ dump_options[2].flag = "%{p}";
+ dump_options[2].item = hardware->dmi.system.product_name;
+
+ dump_options[3].flag = "%{ba}";
+ dump_options[3].item = hardware->dmi.base_board.asset_tag;
+
+ dump_options[4].flag = "%{bs}";
+ dump_options[4].item = hardware->dmi.base_board.serial;
+
+ dump_options[5].flag = "%{ca}";
+ dump_options[5].item = hardware->dmi.chassis.asset_tag;
+
+ dump_options[6].flag = "%{cs}";
+ dump_options[6].item = hardware->dmi.chassis.serial;
+
+ dump_options[7].flag = "%{sk}";
+ dump_options[7].item = hardware->dmi.system.sku_number;
+
+ dump_options[8].flag = "%{ss}";
+ dump_options[8].item = hardware->dmi.system.serial;
+
+ dump_options[9].flag = NULL;
+ dump_options[9].item = NULL;
+
+ for (int i = 0; i < 9; i++) {
+ if (strcmp(option, dump_options[i].flag) == 0) {
+ return remove_spaces(dump_options[i].item);
+ }
+ }
+
+ return NULL;
+}
+
+char *compute_filename(struct s_hardware *hardware)
+{
+
+ char *filename = malloc(512);
+ snprintf(filename, 512, "%s/%s", hardware->dump_path,
+ hardware->dump_filename);
+
+ /* Until we found some dump parameters */
+ char *buffer;
+ while ((buffer = strstr(filename, "%{"))) {
+ // Find the end of the parameter
+ char *buffer_end = strstr(buffer, "}");
+
+ // Extracting the parameter between %{ and }
+ char option[8] = { 0 };
+ strncpy(option, buffer, buffer_end - buffer + 1);
+
+ /* Replace this option by its value in the filename
+ * Filename is longer than the previous filename we had
+ * so let's restart from the beginning */
+ filename =
+ strreplace(filename, option,
+ get_value_from_option(hardware, option));
}
/* We replace the ":" in the filename by some "-"
* This will avoid Microsoft FS turning crazy */
- chrreplace(filename,':','-');
+ chrreplace(filename, ':', '-');
/* Avoid space to make filename easier to manipulate */
- chrreplace(filename,' ','_');
+ chrreplace(filename, ' ', '_');
+ return filename;
}
-int dumpprintf(FILE *p, const char *format, ...) {
- va_list ap;
- int rv;
-
- (void) p;
- va_start(ap, format);
- rv = vbufprintf(&p_buf,format, ap);
- va_end(ap);
- return rv;
+int dumpprintf(FILE * p, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ (void)p;
+ va_start(ap, format);
+ rv = vbufprintf(&p_buf, format, ap);
+ va_end(ap);
+ return rv;
}
-void to_cpio(char *filename) {
- cpio_writefile(upload,filename,p_buf.buf,p_buf.len);
- if ((p_buf.buf) && (p_buf.len > 0)){
- memset(p_buf.buf,0,p_buf.len);
- free(p_buf.buf);
- p_buf.buf=NULL;
- p_buf.size=0;
- p_buf.len=0;
- }
+void to_cpio(char *filename)
+{
+ cpio_writefile(upload, filename, p_buf.buf, p_buf.len);
+ if ((p_buf.buf) && (p_buf.len > 0)) {
+ memset(p_buf.buf, 0, p_buf.len);
+ free(p_buf.buf);
+ p_buf.buf = NULL;
+ p_buf.size = 0;
+ p_buf.len = 0;
+ }
}
-void flush (ZZJSON_CONFIG *config, ZZJSON ** item) {
- zzjson_print(config, *item);
- zzjson_free(config, *item);
- *item=NULL;
+void flush(ZZJSON_CONFIG * config, ZZJSON ** item)
+{
+ zzjson_print(config, *item);
+ zzjson_free(config, *item);
+ *item = NULL;
}
/**
@@ -94,53 +155,52 @@ void flush (ZZJSON_CONFIG *config, ZZJSON ** item) {
**/
void dump(struct s_hardware *hardware)
{
- if (hardware->is_pxe_valid==false) {
- printf("PXE stack was not detected, Dump feature is not available\n");
- return;
+ if (hardware->is_pxe_valid == false) {
+ printf("PXE stack was not detected, Dump feature is not available\n");
+ return;
}
const union syslinux_derivative_info *sdi = syslinux_derivative_info();
- int err=0;
+ int err = 0;
ZZJSON *json = NULL;
ZZJSON_CONFIG config = { ZZJSON_VERY_STRICT, NULL,
- (int(*)(void*)) fgetc,
- NULL,
- malloc, calloc, free, realloc,
- stderr, NULL, stdout,
- (int(*)(void *,const char*,...)) dumpprintf,
- (int(*)(int,void*)) fputc
+ (int (*)(void *))fgetc,
+ NULL,
+ malloc, calloc, free, realloc,
+ stderr, NULL, stdout,
+ (int (*)(void *, const char *,...))dumpprintf,
+ (int (*)(int, void *))fputc
};
- memset(&p_buf,0,sizeof(p_buf));
+ memset(&p_buf, 0, sizeof(p_buf));
/* By now, we only support TFTP reporting */
- upload=&upload_tftp;
- upload->name="tftp";
+ upload = &upload_tftp;
+ upload->name = "tftp";
/* The following defines the behavior of the reporting */
char *arg[64];
- char filename[512]={0};
- compute_filename(hardware, filename, sizeof(filename));
+ char *filename = compute_filename(hardware);
/* The filename */
arg[0] = filename;
/* The server to upload the file */
if (strlen(hardware->tftp_ip) != 0) {
- arg[1] = hardware->tftp_ip;
- arg[2] = NULL;
+ arg[1] = hardware->tftp_ip;
+ arg[2] = NULL;
} else {
- arg[1] = NULL;
- snprintf(hardware->tftp_ip, sizeof(hardware->tftp_ip),
- "%u.%u.%u.%u",
- ((uint8_t *)&sdi->pxe.ipinfo->serverip)[0],
- ((uint8_t *)&sdi->pxe.ipinfo->serverip)[1],
- ((uint8_t *)&sdi->pxe.ipinfo->serverip)[2],
- ((uint8_t *)&sdi->pxe.ipinfo->serverip)[3]);
+ arg[1] = NULL;
+ snprintf(hardware->tftp_ip, sizeof(hardware->tftp_ip),
+ "%u.%u.%u.%u",
+ ((uint8_t *) & sdi->pxe.ipinfo->serverip)[0],
+ ((uint8_t *) & sdi->pxe.ipinfo->serverip)[1],
+ ((uint8_t *) & sdi->pxe.ipinfo->serverip)[2],
+ ((uint8_t *) & sdi->pxe.ipinfo->serverip)[3]);
}
/* We initiate the cpio to send */
- cpio_init(upload,(const char **)arg);
+ cpio_init(upload, (const char **)arg);
dump_cpu(hardware, &config, &json);
dump_pxe(hardware, &config, &json);
@@ -158,12 +218,12 @@ void dump(struct s_hardware *hardware)
/* We close & flush the file to send */
cpio_close(upload);
- if ((err=flush_data(upload)) != TFTP_OK) {
+ if ((err = flush_data(upload)) != TFTP_OK) {
/* As we manage a tftp connection, let's display the associated error message */
more_printf("Dump failed !\n");
- more_printf("TFTP ERROR on : %s:/%s \n",hardware->tftp_ip, filename);
- more_printf("TFTP ERROR msg : %s \n",tftp_string_error_message[-err]);
+ more_printf("TFTP ERROR on : %s:/%s \n", hardware->tftp_ip, filename);
+ more_printf("TFTP ERROR msg : %s \n", tftp_string_error_message[-err]);
} else {
- more_printf("Dump file sent at %s:/%s\n",hardware->tftp_ip, filename);
+ more_printf("Dump file sent at %s:/%s\n", hardware->tftp_ip, filename);
}
}
diff --git a/com32/hdt/hdt-menu-summary.c b/com32/hdt/hdt-menu-summary.c
index ad87c299..cef7e69e 100644
--- a/com32/hdt/hdt-menu-summary.c
+++ b/com32/hdt/hdt-menu-summary.c
@@ -52,8 +52,7 @@ void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- char features[SUBMENULEN + 1];
- memset(features, 0, sizeof(features));
+ char features[255]={0};
if (hardware->dmi.processor.thread_count != 0)
sprintf(buffer, ", %d thread", hardware->dmi.processor.thread_count);
else
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;
}
diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h
index 7b35236e..9b9e8a10 100644
--- a/com32/hdt/hdt.h
+++ b/com32/hdt/hdt.h
@@ -33,8 +33,8 @@
#define AUTHOR "Erwan Velu"
#define CORE_DEVELOPER "Pierre-Alexandre Meyer"
#define CONTACT "hdt@zytor.com"
-#define VERSION "0.5.0"
-#define CODENAME "Van De Keizer"
+#define VERSION "0.5.2-pre1"
+#define CODENAME "Manon"
#define NB_CONTRIBUTORS 3
#define CONTRIBUTORS {"Sebastien Gonzalve (Patches)", "Gert Hulselmans (Tests)", "Alexander Andino (Design)"}
#define WEBSITE_URL "http://hdt-project.org"