diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-23 09:38:50 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-23 09:38:50 -0400 |
commit | c60acb22860c4ac69855f84bf77d9e0dd3f7c17a (patch) | |
tree | a73e9a1b9edfc0c3469cc00aa9adfa57ef90c725 /flash.c | |
parent | 8bc46aed19c0e984b241e18c61ea0a528db5348a (diff) |
implement flash suspend
Diffstat (limited to 'flash.c')
-rw-r--r-- | flash.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -284,24 +284,26 @@ int readUserBlock(FlashStruct *mem) void writeUserBlock(FlashStruct *mem, int addr, int numbytes) { - // *** There is a potential issue here.. if the mainfile is corrupt *** // *** and this gets called before readUserBlock then the *** // *** potentially workable backup will be lost .. we could check *** // *** that the main file is valid before backing it up I guess... *** // *** but I don't think this situation should arise. *** - // backup the main copy of the file - if (persistence_copyfile(MAINFILE, BACKUPFILE)) { - if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) { - if (errno != PERSIST_ERR_COULDNTWRITE) { - printf("Error while trying to write, %d. **Write did not happen!!!**\n", errno); - } else { - printf("Error while writing data to disk. **File is potentially corrupt!**\n"); + if (!globals.flash_writes_suspended) { + + // backup the main copy of the file + if (persistence_copyfile(MAINFILE, BACKUPFILE)) { + if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) { + if (errno != PERSIST_ERR_COULDNTWRITE) { + printf("Error while trying to write, %d. **Write did not happen!!!**\n", errno); + } else { + printf("Error while writing data to disk. **File is potentially corrupt!**\n"); + } } + } else { + printf("Could not backup current file. **Write did not happen!!!**\n"); } - } else { - printf("Could not backup current file. **Write did not happen!!!**\n"); } } |