From b3e7a798672b8de6f85cd6ee6f002c8453ea5eb7 Mon Sep 17 00:00:00 2001 From: Doug Gilbert Date: Wed, 21 Sep 2011 15:26:31 -0500 Subject: LINKER delete partially created files on error Change-Id: I6d2a7e22570ae1c10512844ee2ba7de5c3605006 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/356 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert --- src/build/linker/linker.C | 54 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/build/linker/linker.C b/src/build/linker/linker.C index de2694fdd..e635c8017 100644 --- a/src/build/linker/linker.C +++ b/src/build/linker/linker.C @@ -1,3 +1,25 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/build/linker/linker.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END /** * @file linker.C Linker to generate the host boot binary images */ @@ -180,6 +202,7 @@ class ModuleTable { private: FILE * iv_output; + string iv_path; string iv_vfs_mod_table_name; public: @@ -187,14 +210,24 @@ class ModuleTable /** * CTOR */ - ModuleTable(FILE * i_binfile, const string & i_mod_table_name) - : iv_output(i_binfile), iv_vfs_mod_table_name(i_mod_table_name) {} + ModuleTable(FILE * i_binfile, + const string & i_path, + const string & i_mod_table_name) + : + iv_output(i_binfile), + iv_path(i_path), + iv_vfs_mod_table_name(i_mod_table_name) {} /** * Write module table to file * @param[in] list of objects */ void write_table(vector & i_objects); + + /** + * Clean up after an error + */ + void handle_error(); }; /** @@ -283,7 +316,7 @@ int main(int argc, char** argv) page_align(112*VFS_EXTENDED_MODULE_MAX); fseek(output, table_size, SEEK_SET); } - ModuleTable module_table(output,table_symbol); + ModuleTable module_table(output,fname,table_symbol); module_tables.push_back(module_table); } else if (0 == fname.compare(0,11,"--extended=")) @@ -382,6 +415,12 @@ int main(int argc, char** argv) { cerr << "exception caught: " << e.what() << endl; rc = -1; + // remove any partial output file(s) + for(vector::iterator i = module_tables.begin(); + i != module_tables.end(); ++i) + { + i->handle_error(); + } } return rc; @@ -970,3 +1009,12 @@ void ModuleTable::write_table(vector & i_objects) } } +void ModuleTable::handle_error() +{ + if(iv_output) + { + fclose(iv_output); + cout << "Removing " << iv_path << endl; + remove(iv_path.c_str()); + } +} -- cgit v1.2.1