This patch fixes our handling of firmware dump files we create. Previously, we just wouldn't recognize the file at all.
This also updates the generation code to write out a more recognizable file. -- Phil Dibowitz p...@ipom.com Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." - Dr. Seuss
commit 52592d886f6d4aebd182af84572218e2400bbb2b Author: Phil Dibowitz <p...@ipom.com> Date: Mon Mar 17 22:42:12 2014 -0700 Fix firmware file detection and creation libconcord/operationfile.cpp * Handle firmware files we created ourselves libconcord/libconcord.cpp * Write out more complete XML headers for FW dumps Signed-off-by: Phil Dibowitz <p...@ipom.com> diff --git a/libconcord/libconcord.cpp b/libconcord/libconcord.cpp index fc1ca7d..fe8b2f4 100644 --- a/libconcord/libconcord.cpp +++ b/libconcord/libconcord.cpp @@ -1510,6 +1510,7 @@ int write_firmware_to_file(uint8_t *in, uint32_t size, char *file_name, uint8_t *pf = in; const uint8_t *fwend = in + size; + of.write("<INFORMATION>\n"); do { of.write("\t\t\t<DATA>"); char hex[16]; @@ -1525,6 +1526,7 @@ int write_firmware_to_file(uint8_t *in, uint32_t size, char *file_name, } of.write("</DATA>\n"); } while (pf < fwend); + of.write("</INFORMATION>\n"); } if (of.close() != 0) { diff --git a/libconcord/operationfile.cpp b/libconcord/operationfile.cpp index f20ab72..c260208 100644 --- a/libconcord/operationfile.cpp +++ b/libconcord/operationfile.cpp @@ -269,12 +269,23 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) err = GetTag("INFORMATION", xml, xml_size, start_info_ptr); debug("err is %d", err); if (err == -1) { - return LC_ERROR; - } - - err = GetTag("/INFORMATION", xml, xml_size, end_info_ptr); - if (err == -1) { - return LC_ERROR; + /* + * In theory, we should always have an INFORMATION section + * so we used to return LC_ERROR here. However, for a long time + * when we generated firmware dump files, we didn't surround the + * data in INFORMATION tags. However, since that entire file is + * XML, we assume that's what we have and set the start/end + * of the XML section to the whole file. + */ + debug("Unable to find INFORMATION tag, using whole file"); + start_info_ptr = xml; + end_info_ptr = xml + xml_size; + } else { + err = GetTag("/INFORMATION", xml, xml_size, end_info_ptr); + if (err == -1) { + debug("Unable to find /INFORMATION tag"); + return LC_ERROR; + } } } debug("start/end pointers populated"); @@ -310,12 +321,22 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) while (1) { uint8_t *tag_ptr; string tag_s; + debug("Looking for TYPE tag...\n"); err = GetTag("TYPE", tmp_data, tmp_size, tag_ptr, &tag_s); if (err == -1) { + debug("Looking for PATH tag...\n"); err = GetTag("PATH", tmp_data, tmp_size, tag_ptr, &tag_s); if (err == -1) { - debug("not a firmware file"); - break; + debug("Looking for DATA tag...\n"); + err = GetTag("DATA", tmp_data, tmp_size, tag_ptr, &tag_s); + if (err == -1) { + debug("not a firmware file"); + break; + } else { + debug("Looks like a firmware file we made"); + found_firmware = true; + break; + } } } if (!stricmp(tag_s.c_str(), "Firmware_Main")) {
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech
_______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel