[syslinux:master] hdt: Reporting TFTP errors in dump mode

syslinux-bot for Erwan Velu erwanaliasr1 at gmail.com
Mon Apr 25 15:29:16 PDT 2011


Commit-ID:  1df9933af2c1d1711db2f938eb1ea3e9a2be023c
Gitweb:     http://syslinux.zytor.com/commit/1df9933af2c1d1711db2f938eb1ea3e9a2be023c
Author:     Erwan Velu <erwanaliasr1 at gmail.com>
AuthorDate: Mon, 18 Apr 2011 23:08:21 +0200
Committer:  Erwan Velu <erwanaliasr1 at gmail.com>
CommitDate: Mon, 18 Apr 2011 23:08:21 +0200

hdt: Reporting TFTP errors in dump mode

If we get some errors from the tftp, let's report it to the user.
This will make user's life easier to understand why the dumping mode
isn't working.


---
 com32/hdt/hdt-dump.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index 88f402b..c1e1e01 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <getkey.h>
+#include <syslinux/config.h>
 #include "hdt-common.h"
 #include "hdt-dump.h"
 
@@ -92,6 +94,8 @@ void flush (ZZJSON_CONFIG *config, ZZJSON ** item) {
  **/
 void dump(struct s_hardware *hardware)
 {
+    const union syslinux_derivative_info *sdi = syslinux_derivative_info();
+    int err=0;
     ZZJSON *json = NULL;
     ZZJSON_CONFIG config = { ZZJSON_VERY_STRICT, NULL,
 		(int(*)(void*)) fgetc,
@@ -104,6 +108,8 @@ void dump(struct s_hardware *hardware)
 
     memset(&p_buf,0,sizeof(p_buf));
 
+    more_printf("Preparing dump file\n");
+
     /* By now, we only support TFTP reporting */
     upload=&upload_tftp;
     upload->name="tftp";
@@ -121,6 +127,13 @@ void dump(struct s_hardware *hardware)
 	    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]);
+
     }
 
     /* We initiate the cpio to send */
@@ -141,5 +154,13 @@ void dump(struct s_hardware *hardware)
 
     /* We close & flush the file to send */
     cpio_close(upload);
-    flush_data(upload);
+
+    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]);
+    } else {
+	more_printf("Dump file sent at %s:/%s\n",hardware->tftp_ip, filename);
+    }
 }



More information about the Syslinux-commits mailing list