From 1df9933af2c1d1711db2f938eb1ea3e9a2be023c Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Mon, 18 Apr 2011 23:08:21 +0200 Subject: [PATCH] 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 file changed, 22 insertions(+), 1 deletion(-) 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 #include #include +#include +#include #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); + } } -- 2.7.4