diff options
author | root <root@avtech.domain.avtechpulse.com> | 1970-01-01 09:01:03 +0900 |
---|---|---|
committer | root <root@avtech.domain.avtechpulse.com> | 1970-01-01 09:01:03 +0900 |
commit | 9e02a7ee2335ba91e5bd0cbb79ab8a5a58f57bde (patch) | |
tree | c41616f855d66609896236dfefb63defcff53f33 /flash.c | |
parent | 5d5d9873f31ae857e0cd713f529f12407a6936a1 (diff) |
file root normally read-only now, for safe power-off. Major OS changes too.INSTRUMENT_6_2_00
Diffstat (limited to 'flash.c')
-rw-r--r-- | flash.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -307,6 +307,19 @@ hdrlengthok: } + +void remount_root_as_writeable () +{ + system("/usr/bin/mount -o remount,rw /dev/mmcblk03 /"); +} + + +void remount_root_as_not_writeable () +{ + system("/usr/bin/mount -o remount,ro /dev/mmcblk03 /"); +} + + static int readUserBlock(FlashStruct *mem) { @@ -329,8 +342,12 @@ static int readUserBlock(FlashStruct *mem) // if the backup was good overwrite the main file if (!globals.Sys.shutdown_started) { globals.Sys.flash_write_in_progress = TRUE; + remount_root_as_writeable (); + persistence_copyfile(BACKUPFILE, MAINFILE); + globals.Sys.flash_write_in_progress = FALSE; + remount_root_as_not_writeable (); } return sizeof(*mem); } @@ -359,11 +376,17 @@ void writeUserBlockNow(FlashStruct *mem, int addr, int numbytes) if (!globals.Sys.shutdown_started) { globals.Sys.flash_write_in_progress = TRUE; + remount_root_as_writeable (); + bool backup_ok = persistence_copyfile(MAINFILE, BACKUPFILE); + globals.Sys.flash_write_in_progress = FALSE; + remount_root_as_not_writeable (); if (backup_ok && !globals.Sys.shutdown_started) { + globals.Sys.flash_write_in_progress = TRUE; + remount_root_as_writeable (); if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) { if (errno != PERSIST_ERR_COULDNTWRITE) { @@ -373,6 +396,7 @@ void writeUserBlockNow(FlashStruct *mem, int addr, int numbytes) } } globals.Sys.flash_write_in_progress = FALSE; + remount_root_as_not_writeable (); } else { printf("Could not backup current file. **Write did not happen!!!**\n"); } |