Software update: Copy flashimage to /tmp if it is not present in this directory

- unmount mounted network folders before flashing
- kill timerd before flashing
This commit is contained in:
Michael Liebmann
2013-06-12 12:12:32 +02:00
parent 50e953cf27
commit c780676ce5
4 changed files with 35 additions and 24 deletions

View File

@@ -15,14 +15,3 @@ if [ -e /var/etc/.djmount ]; then
echo "Kill djmount"
fusermount -u /media/00upnp
fi
## remount rootfs readonly #################
mount -no remount,ro /
RET=$?
echo -n "remount rootfs readonly "
if [ "$RET" = "0" ]; then
echo "successful."
else
echo "failed."
fi
############################################

View File

@@ -47,7 +47,6 @@
#include <gui/color.h>
#include <gui/filebrowser.h>
#include <system/fsmounter.h>
#include <gui/widget/messagebox.h>
#include <gui/widget/hintbox.h>
@@ -483,16 +482,9 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
//status anzeigen
showGlobalStatus(100);
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8
hide();
// Unmount all NFS & CIFS volumes
nfs_mounted_once = false; /* needed by update.cpp to prevent removal of modules after flashing a new cramfs, since rmmod (busybox) might no longer be available */
CFSMounter::umount();
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8
sleep(2);
//my_system("/etc/init.d/rcK");
ft.reboot();
}
else if(fileType == 'T') // display file contents

View File

@@ -3579,6 +3579,7 @@ void stop_daemons(bool stopall, bool for_flash)
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->ShowText("Stop daemons...");
my_system(NEUTRINO_ENTER_FLASH_SCRIPT);
}
dvbsub_close();
@@ -3596,7 +3597,7 @@ void stop_daemons(bool stopall, bool for_flash)
}
printf("httpd shutdown done\n");
CStreamManager::getInstance()->Stop();
if(stopall && !for_flash) {
if(stopall || for_flash) {
printf("timerd shutdown\n");
if (g_Timerd)
g_Timerd->shutdown();
@@ -3641,7 +3642,8 @@ void stop_daemons(bool stopall, bool for_flash)
if (for_flash) {
delete CRecordManager::getInstance();
delete videoDemux;
my_system(NEUTRINO_ENTER_FLASH_SCRIPT);
int ret = my_system(4, "mount", "-no", "remount,ro", "/");
printf("remount rootfs readonly %s.\n", (ret == 0)?"successful":"failed"); fflush(stdout);
}
}

View File

@@ -25,11 +25,14 @@
#include <libmd5sum.h>
#include <system/flashtool.h>
#include <system/fsmounter.h>
#include <system/helpers.h>
#include <eitd/sectionsd.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <libgen.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
@@ -165,7 +168,32 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
return false;
}
if( (fd1 = open( filename.c_str(), O_RDONLY )) < 0 ) {
char buf1[1024];
memset(buf1, 0, sizeof(buf1));
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
char* dn = dirname(buf1);
std::string flashfile;
if (strcmp(dn, "/tmp") != 0) {
memset(buf1, 0, sizeof(buf1));
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
flashfile = (std::string)"/tmp/" + basename(buf1);
CFileHelpers fh;
printf("##### [CFlashTool::program] copy flashfile to %s\n", flashfile.c_str());
if(statusViewer)
statusViewer->showStatusMessageUTF("Copy Image");
fh.copyFile(filename.c_str(), flashfile.c_str(), 0644);
sync();
if(statusViewer)
statusViewer->showGlobalStatus(statusViewer->getGlobalStatus()+5);
}
else
flashfile = filename;
// Unmount all NFS & CIFS volumes
nfs_mounted_once = false;
CFSMounter::umount();
if( (fd1 = open( flashfile.c_str(), O_RDONLY )) < 0 ) {
ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE);
return false;
}
@@ -211,7 +239,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
unsigned char buf[meminfo.writesize];
unsigned mtdoffset = 0;
unsigned fsize = filesize;
printf("CFlashTool::program: file %s write size %d, erase size %d\n", filename.c_str(), meminfo.writesize, meminfo.erasesize);
printf("CFlashTool::program: file %s write size %d, erase size %d\n", flashfile.c_str(), meminfo.writesize, meminfo.erasesize);
while(fsize > 0) {
unsigned block = meminfo.writesize;
if (block > fsize)
@@ -219,7 +247,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
unsigned res = read(fd1, buf, block);
if (res != block) {
printf("CFlashTool::program: read from %s failed: %d from %d\n", filename.c_str(), res, block);
printf("CFlashTool::program: read from %s failed: %d from %d\n", flashfile.c_str(), res, block);
}
if (isnand) {
if (block < (unsigned) meminfo.writesize) {