aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-03-18 21:49:38 +0100
committerErwan Velu <erwanaliasr1@gmail.com>2011-03-18 21:49:38 +0100
commit17202942967982adb3679bad68ea93538ba0d867 (patch)
treec4743824a79cfb5bd1af88536907c98ce2bc5f8c /com32/hdt
parent5b4b737c22587fb1879efab9d93630afcd835d62 (diff)
downloadsyslinux-17202942967982adb3679bad68ea93538ba0d867.tar.gz
syslinux-17202942967982adb3679bad68ea93538ba0d867.tar.xz
syslinux-17202942967982adb3679bad68ea93538ba0d867.zip
hdt: Adding preliminary dump support
This commit add the basics for doing a dump command.
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/Makefile4
-rw-r--r--com32/hdt/hdt-cli-hdt.c13
-rw-r--r--com32/hdt/hdt-cli.h1
-rw-r--r--com32/hdt/hdt-common.h6
-rw-r--r--com32/hdt/hdt-dump.c89
5 files changed, 110 insertions, 3 deletions
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index 40ea3ac4..66dd6ede 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -19,8 +19,8 @@ topdir = ../..
include ../MCONFIG
LIBS = ../cmenu/libmenu/libmenu.a ../libutil/libutil_com.a \
- ../lib/libcom32.a $(LIBGCC)
-CFLAGS += -I$(com32)/cmenu/libmenu
+ ../lib/libcom32.a ../libupload/libcom32upload.a $(LIBGCC)
+CFLAGS += -I$(com32)/cmenu/libmenu -I$(com32)
MODULES = hdt.c32
TESTFILES =
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 65068232..e9752612 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -250,6 +250,15 @@ static void do_reboot(int argc __unused, char **argv __unused,
syslinux_reboot(1);
}
+/**
+ * do_dump - dump info
+ **/
+static void do_dump(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ dump(hardware);
+}
+
/* Default hdt mode */
struct cli_callback_descr list_hdt_default_modules[] = {
{
@@ -277,6 +286,10 @@ struct cli_callback_descr list_hdt_default_modules[] = {
.exec = print_history,
},
{
+ .name = CLI_DUMP,
+ .exec = do_dump,
+ },
+ {
.name = NULL,
.exec = NULL},
};
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 13291092..68b33158 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -65,6 +65,7 @@
#define CLI_ACPI "acpi"
#define CLI_ENABLE "enable"
#define CLI_DISABLE "disable"
+#define CLI_DUMP "dump"
typedef enum {
INVALID_MODE,
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index df7d2c98..c9923bfe 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -48,10 +48,11 @@
#include "cpuid.h"
#include "dmi/dmi.h"
#include "hdt-ata.h"
-#include "../lib/sys/vesa/vesa.h"
+#include <lib/sys/vesa/vesa.h>
#include <vpd/vpd.h>
#include <libansi.h>
#include <acpi/acpi.h>
+#include <libupload/upload_backend.h>
/* Declare a variable or data structure as unused. */
#define __unused __attribute__ (( unused ))
@@ -80,6 +81,8 @@
#define MAX_CLI_LINES 20
#define MAX_VESA_CLI_LINES 24
+struct upload_backend *upload;
+
/* Defines if the cli is quiet*/
bool quiet;
@@ -236,4 +239,5 @@ int detect_vesa(struct s_hardware *hardware);
void detect_memory(struct s_hardware *hardware);
void init_console(struct s_hardware *hardware);
void detect_hardware(struct s_hardware *hardware);
+void dump(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
new file mode 100644
index 00000000..285fb3b9
--- /dev/null
+++ b/com32/hdt/hdt-dump.c
@@ -0,0 +1,89 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 20011 Erwan Velu - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "hdt-common.h"
+
+static void compute_filename(struct s_hardware *hardware, char *filename, int size) {
+
+ snprintf(filename,size,"%s/","hdt");
+
+ 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));
+ }
+
+ /* We replace the ":" in the filename by some "-"
+ * This will avoid Microsoft FS turning crazy */
+ chrreplace(filename,':','-');
+
+ /* Avoid space to make filename easier to manipulate */
+ chrreplace(filename,' ','_');
+
+}
+
+/**
+ * dump - dump info
+ **/
+void dump(struct s_hardware *hardware)
+{
+ detect_hardware(hardware);
+
+ /* By now, we only support TFTP reporting */
+ 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));
+
+ /* The filename */
+ arg[0] = filename;
+ /* More to come */
+ arg[1] = NULL;
+
+ /* We initiate the cpio to send */
+ cpio_init(upload,(const char **)arg);
+
+ cpio_writefile(upload,"test","test1",4);
+
+ /* We close & flush the file to send */
+ cpio_close(upload);
+ flush_data(upload);
+}