mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-10 23:28:34 +02:00
- update-ext: formatting code using astyle; some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
CHintBox * hintBox = 0;
|
CHintBox *hintBox = 0;
|
||||||
|
|
||||||
CExtUpdate::CExtUpdate()
|
CExtUpdate::CExtUpdate()
|
||||||
{
|
{
|
||||||
@@ -85,30 +85,31 @@ CExtUpdate::CExtUpdate()
|
|||||||
|
|
||||||
CExtUpdate::~CExtUpdate()
|
CExtUpdate::~CExtUpdate()
|
||||||
{
|
{
|
||||||
if(FileHelpers)
|
if (FileHelpers)
|
||||||
delete[] FileHelpers;
|
delete[] FileHelpers;
|
||||||
if(MTDBuf)
|
if (MTDBuf)
|
||||||
delete[] MTDBuf;
|
delete[] MTDBuf;
|
||||||
copyList.clear();
|
copyList.clear();
|
||||||
blackList.clear();
|
blackList.clear();
|
||||||
deleteList.clear();
|
deleteList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CExtUpdate* CExtUpdate::getInstance()
|
CExtUpdate *CExtUpdate::getInstance()
|
||||||
{
|
{
|
||||||
static CExtUpdate* ExtUpdate = NULL;
|
static CExtUpdate *ExtUpdate = NULL;
|
||||||
if(!ExtUpdate)
|
if (!ExtUpdate)
|
||||||
ExtUpdate = new CExtUpdate();
|
ExtUpdate = new CExtUpdate();
|
||||||
return ExtUpdate;
|
return ExtUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::string & msg2)
|
bool CExtUpdate::ErrorReset(bool modus, const std::string &msg1, const std::string &msg2)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
if (modus & RESET_UNLOAD) {
|
if (modus & RESET_UNLOAD)
|
||||||
|
{
|
||||||
umount(mountPkt.c_str());
|
umount(mountPkt.c_str());
|
||||||
// my_system(2,"rmmod", mtdramDriver.c_str());
|
//my_system(2,"rmmod", mtdramDriver.c_str());
|
||||||
}
|
}
|
||||||
if (modus & CLOSE_FD1)
|
if (modus & CLOSE_FD1)
|
||||||
close(fd1);
|
close(fd1);
|
||||||
@@ -116,7 +117,8 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
|
|||||||
close(fd2);
|
close(fd2);
|
||||||
if (modus & CLOSE_F1)
|
if (modus & CLOSE_F1)
|
||||||
fclose(f1);
|
fclose(f1);
|
||||||
if (modus & DELETE_MTDBUF) {
|
if (modus & DELETE_MTDBUF)
|
||||||
|
{
|
||||||
if (MTDBuf != NULL)
|
if (MTDBuf != NULL)
|
||||||
delete[] MTDBuf;
|
delete[] MTDBuf;
|
||||||
MTDBuf = NULL;
|
MTDBuf = NULL;
|
||||||
@@ -127,20 +129,21 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
|
|||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "%s %s\n", msg1.c_str(), msg2.c_str());
|
snprintf(buf, sizeof(buf), "%s %s\n", msg1.c_str(), msg2.c_str());
|
||||||
|
|
||||||
if ((!msg1.empty()) || (!msg2.empty())) {
|
if ((!msg1.empty()) || (!msg2.empty()))
|
||||||
|
{
|
||||||
mtdRamError = buf;
|
mtdRamError = buf;
|
||||||
WRITE_UPDATE_LOG("ERROR: %s", buf);
|
WRITE_UPDATE_LOG("ERROR: %s", buf);
|
||||||
printf(mtdRamError.c_str());
|
printf(mtdRamError.c_str());
|
||||||
}
|
}
|
||||||
if(hintBox)
|
if (hintBox)
|
||||||
hintBox->hide();
|
hintBox->hide();
|
||||||
sync();
|
sync();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::applySettings(std::string & filename, int mode)
|
bool CExtUpdate::applySettings(std::string &filename, int mode)
|
||||||
{
|
{
|
||||||
if(!FileHelpers)
|
if (!FileHelpers)
|
||||||
FileHelpers = new CFileHelpers();
|
FileHelpers = new CFileHelpers();
|
||||||
|
|
||||||
if (mode == MODE_EXPERT)
|
if (mode == MODE_EXPERT)
|
||||||
@@ -151,7 +154,7 @@ bool CExtUpdate::applySettings(std::string & filename, int mode)
|
|||||||
DBG_TIMER_START()
|
DBG_TIMER_START()
|
||||||
|
|
||||||
std::string oldFilename = imgFilename;
|
std::string oldFilename = imgFilename;
|
||||||
std::string hostName ="";
|
std::string hostName = "";
|
||||||
netGetHostname(hostName);
|
netGetHostname(hostName);
|
||||||
std::string orgPath = getPathName(imgFilename);
|
std::string orgPath = getPathName(imgFilename);
|
||||||
std::string orgName = getBaseName(imgFilename);
|
std::string orgName = getBaseName(imgFilename);
|
||||||
@@ -160,7 +163,8 @@ bool CExtUpdate::applySettings(std::string & filename, int mode)
|
|||||||
std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M");
|
std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M");
|
||||||
std::string settingsStr = "+settings";
|
std::string settingsStr = "+settings";
|
||||||
|
|
||||||
if (orgPath != "/tmp") {
|
if (orgPath != "/tmp")
|
||||||
|
{
|
||||||
if (g_settings.softupdate_name_mode_apply == CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME)
|
if (g_settings.softupdate_name_mode_apply == CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME)
|
||||||
imgFilename = orgPath + "/" + hostName + timeStr + settingsStr + orgExt;
|
imgFilename = orgPath + "/" + hostName + timeStr + settingsStr + orgExt;
|
||||||
else if (g_settings.softupdate_name_mode_apply == CExtUpdate::SOFTUPDATE_NAME_ORGNAME_TIME)
|
else if (g_settings.softupdate_name_mode_apply == CExtUpdate::SOFTUPDATE_NAME_ORGNAME_TIME)
|
||||||
@@ -175,16 +179,20 @@ bool CExtUpdate::applySettings(std::string & filename, int mode)
|
|||||||
|
|
||||||
bool ret = applySettings();
|
bool ret = applySettings();
|
||||||
DBG_TIMER_STOP("Image editing")
|
DBG_TIMER_STOP("Image editing")
|
||||||
if (!ret) {
|
if (!ret)
|
||||||
|
{
|
||||||
if ((!mtdRamError.empty()) && (!flashErrorFlag))
|
if ((!mtdRamError.empty()) && (!flashErrorFlag))
|
||||||
DisplayErrorMessage(mtdRamError.c_str());
|
DisplayErrorMessage(mtdRamError.c_str());
|
||||||
|
|
||||||
// error, delete image file
|
// error, delete image file
|
||||||
unlink(imgFilename.c_str());
|
unlink(imgFilename.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (mode == MODE_EXPERT) {
|
{
|
||||||
if ((mtdNumber < 3) || (mtdNumber > 4)) {
|
if (mode == MODE_EXPERT)
|
||||||
|
{
|
||||||
|
if ((mtdNumber < 3) || (mtdNumber > 4))
|
||||||
|
{
|
||||||
const char *err = "invalid mtdNumber\n";
|
const char *err = "invalid mtdNumber\n";
|
||||||
printf(err);
|
printf(err);
|
||||||
DisplayErrorMessage(err);
|
DisplayErrorMessage(err);
|
||||||
@@ -203,11 +211,14 @@ bool CExtUpdate::applySettings(std::string & filename, int mode)
|
|||||||
bool CExtUpdate::isMtdramLoad()
|
bool CExtUpdate::isMtdramLoad()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
FILE* f = fopen("/proc/modules", "r");
|
FILE *f = fopen("/proc/modules", "r");
|
||||||
if (f) {
|
if (f)
|
||||||
|
{
|
||||||
char buf[256] = "";
|
char buf[256] = "";
|
||||||
while(fgets(buf, sizeof(buf), f) != NULL) {
|
while (fgets(buf, sizeof(buf), f) != NULL)
|
||||||
if (strstr(buf, "mtdram") != NULL) {
|
{
|
||||||
|
if (strstr(buf, "mtdram") != NULL)
|
||||||
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -219,7 +230,7 @@ bool CExtUpdate::isMtdramLoad()
|
|||||||
|
|
||||||
bool CExtUpdate::applySettings()
|
bool CExtUpdate::applySettings()
|
||||||
{
|
{
|
||||||
if(!hintBox)
|
if (!hintBox)
|
||||||
hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED));
|
hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED));
|
||||||
hintBox->paint();
|
hintBox->paint();
|
||||||
mtdRamError = "";
|
mtdRamError = "";
|
||||||
@@ -228,13 +239,13 @@ bool CExtUpdate::applySettings()
|
|||||||
char buf1[256] = "";
|
char buf1[256] = "";
|
||||||
char buf2[256] = "";
|
char buf2[256] = "";
|
||||||
|
|
||||||
CMTDInfo * mtdInfo = CMTDInfo::getInstance();
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
std::string mtdFilename = mtdInfo->findMTDsystem(); // /dev/mtdX
|
std::string mtdFilename = mtdInfo->findMTDsystem(); // /dev/mtdX
|
||||||
if (mtdFilename.empty())
|
if (mtdFilename.empty())
|
||||||
return ErrorReset(0, "error system mtd not found");
|
return ErrorReset(0, "error system mtd not found");
|
||||||
|
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
uint64_t mtdSize = 65536*1024; // FIXME hack, mtd size more than free RAM
|
uint64_t mtdSize = 65536 * 1024; // FIXME hack, mtd size more than free RAM
|
||||||
#else
|
#else
|
||||||
uint64_t mtdSize = mtdInfo->getMTDSize(mtdFilename);
|
uint64_t mtdSize = mtdInfo->getMTDSize(mtdFilename);
|
||||||
#endif
|
#endif
|
||||||
@@ -243,7 +254,8 @@ bool CExtUpdate::applySettings()
|
|||||||
|
|
||||||
// get osrelease
|
// get osrelease
|
||||||
struct utsname uts_info;
|
struct utsname uts_info;
|
||||||
if( uname(&uts_info) == 0 ) {
|
if (uname(&uts_info) == 0)
|
||||||
|
{
|
||||||
osrelease = uts_info.release;
|
osrelease = uts_info.release;
|
||||||
size_t pos = osrelease.find_first_of(" ");
|
size_t pos = osrelease.find_first_of(" ");
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
@@ -253,21 +265,23 @@ bool CExtUpdate::applySettings()
|
|||||||
return ErrorReset(0, "error no kernel info");
|
return ErrorReset(0, "error no kernel info");
|
||||||
|
|
||||||
// check if mtdram driver is already loaded
|
// check if mtdram driver is already loaded
|
||||||
if (!isMtdramLoad()) {
|
if (!isMtdramLoad())
|
||||||
|
{
|
||||||
// check if exist mtdram driver
|
// check if exist mtdram driver
|
||||||
snprintf(buf1, sizeof(buf1), "/lib/modules/%s/mtdram.ko", osrelease.c_str());
|
snprintf(buf1, sizeof(buf1), "/lib/modules/%s/mtdram.ko", osrelease.c_str());
|
||||||
mtdramDriver = buf1;
|
mtdramDriver = buf1;
|
||||||
if ( !file_exists(mtdramDriver.c_str()) )
|
if (!file_exists(mtdramDriver.c_str()))
|
||||||
return ErrorReset(0, "no mtdram driver available");
|
return ErrorReset(0, "no mtdram driver available");
|
||||||
// load mtdram driver
|
// load mtdram driver
|
||||||
snprintf(buf1, sizeof(buf1), "total_size=%llu", mtdSize/1024);
|
snprintf(buf1, sizeof(buf1), "total_size=%llu", mtdSize / 1024);
|
||||||
snprintf(buf2, sizeof(buf2), "erase_size=%llu", mtdEraseSize/1024);
|
snprintf(buf2, sizeof(buf2), "erase_size=%llu", mtdEraseSize / 1024);
|
||||||
my_system(4, "insmod", mtdramDriver.c_str(), buf1, buf2);
|
my_system(4, "insmod", mtdramDriver.c_str(), buf1, buf2);
|
||||||
// check if mtdram driver is now loaded
|
// check if mtdram driver is now loaded
|
||||||
if (!isMtdramLoad())
|
if (!isMtdramLoad())
|
||||||
return ErrorReset(0, "error load mtdram driver");
|
return ErrorReset(0, "error load mtdram driver");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
DBG_MSG("mtdram driver is already loaded");
|
DBG_MSG("mtdram driver is already loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,17 +290,20 @@ bool CExtUpdate::applySettings()
|
|||||||
uint64_t mtdRamSize = 0, mtdRamEraseSize = 0;
|
uint64_t mtdRamSize = 0, mtdRamEraseSize = 0;
|
||||||
int mtdRamNr = 0;
|
int mtdRamNr = 0;
|
||||||
f1 = fopen("/proc/mtd", "r");
|
f1 = fopen("/proc/mtd", "r");
|
||||||
if(!f1)
|
if (!f1)
|
||||||
return ErrorReset(RESET_UNLOAD, "cannot read /proc/mtd");
|
return ErrorReset(RESET_UNLOAD, "cannot read /proc/mtd");
|
||||||
fgets(buf1, sizeof(buf1), f1);
|
fgets(buf1, sizeof(buf1), f1);
|
||||||
while(!feof(f1)) {
|
while (!feof(f1))
|
||||||
if(fgets(buf1, sizeof(buf1), f1)!=NULL) {
|
{
|
||||||
|
if (fgets(buf1, sizeof(buf1), f1) != NULL)
|
||||||
|
{
|
||||||
char dummy[50] = "";
|
char dummy[50] = "";
|
||||||
uint32_t tmp1, tmp2;
|
uint32_t tmp1, tmp2;
|
||||||
sscanf(buf1, "mtd%1d: %8x %8x \"%48s\"\n", &mtdRamNr, &tmp1, &tmp2, dummy);
|
sscanf(buf1, "mtd%1d: %8x %8x \"%48s\"\n", &mtdRamNr, &tmp1, &tmp2, dummy);
|
||||||
mtdRamSize = (uint64_t)tmp1;
|
mtdRamSize = (uint64_t)tmp1;
|
||||||
mtdRamEraseSize = (uint64_t)tmp2;
|
mtdRamEraseSize = (uint64_t)tmp2;
|
||||||
if (strstr(buf1, "mtdram test device") != NULL) {
|
if (strstr(buf1, "mtdram test device") != NULL)
|
||||||
|
{
|
||||||
sprintf(buf1, "/dev/mtd%d", mtdRamNr);
|
sprintf(buf1, "/dev/mtd%d", mtdRamNr);
|
||||||
mtdRamFilename = buf1;
|
mtdRamFilename = buf1;
|
||||||
sprintf(buf1, "/dev/mtdblock%d", mtdRamNr);
|
sprintf(buf1, "/dev/mtdblock%d", mtdRamNr);
|
||||||
@@ -299,9 +316,11 @@ bool CExtUpdate::applySettings()
|
|||||||
|
|
||||||
if (mtdRamFilename.empty())
|
if (mtdRamFilename.empty())
|
||||||
return ErrorReset(RESET_UNLOAD, "no mtdram test device found");
|
return ErrorReset(RESET_UNLOAD, "no mtdram test device found");
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// check mtdRamSize / mtdRamEraseSize
|
// check mtdRamSize / mtdRamEraseSize
|
||||||
if ((mtdRamSize != mtdSize) || (mtdRamEraseSize != mtdEraseSize)) {
|
if ((mtdRamSize != mtdSize) || (mtdRamEraseSize != mtdEraseSize))
|
||||||
|
{
|
||||||
snprintf(buf2, sizeof(buf2), "error MTDSize(%08llx/%08llx) or MTDEraseSize(%08llx/%08llx)\n", mtdSize, mtdRamSize, mtdEraseSize, mtdRamEraseSize);
|
snprintf(buf2, sizeof(buf2), "error MTDSize(%08llx/%08llx) or MTDEraseSize(%08llx/%08llx)\n", mtdSize, mtdRamSize, mtdEraseSize, mtdRamEraseSize);
|
||||||
return ErrorReset(RESET_UNLOAD, buf2);
|
return ErrorReset(RESET_UNLOAD, buf2);
|
||||||
}
|
}
|
||||||
@@ -317,13 +336,14 @@ bool CExtUpdate::applySettings()
|
|||||||
return ErrorReset(RESET_UNLOAD | DELETE_MTDBUF, "cannot read image file: " + imgFilename);
|
return ErrorReset(RESET_UNLOAD | DELETE_MTDBUF, "cannot read image file: " + imgFilename);
|
||||||
uint64_t filesize = (uint64_t)lseek(fd1, 0, SEEK_END);
|
uint64_t filesize = (uint64_t)lseek(fd1, 0, SEEK_END);
|
||||||
lseek(fd1, 0, SEEK_SET);
|
lseek(fd1, 0, SEEK_SET);
|
||||||
if(filesize == 0)
|
if (filesize == 0)
|
||||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "image filesize is 0");
|
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "image filesize is 0");
|
||||||
if(filesize > mtdSize)
|
if (filesize > mtdSize)
|
||||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "image filesize too large");
|
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "image filesize too large");
|
||||||
fd2 = -1;
|
fd2 = -1;
|
||||||
int tmpCount = 0;
|
int tmpCount = 0;
|
||||||
while (fd2 < 0) {
|
while (fd2 < 0)
|
||||||
|
{
|
||||||
fd2 = open(mtdBlockFileName.c_str(), O_WRONLY, 00644);
|
fd2 = open(mtdBlockFileName.c_str(), O_WRONLY, 00644);
|
||||||
tmpCount++;
|
tmpCount++;
|
||||||
if (tmpCount > 3)
|
if (tmpCount > 3)
|
||||||
@@ -334,9 +354,10 @@ bool CExtUpdate::applySettings()
|
|||||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open mtdBlock");
|
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open mtdBlock");
|
||||||
uint64_t fsize = filesize;
|
uint64_t fsize = filesize;
|
||||||
uint32_t block;
|
uint32_t block;
|
||||||
while(fsize > 0) {
|
while (fsize > 0)
|
||||||
|
{
|
||||||
block = (uint32_t)fsize;
|
block = (uint32_t)fsize;
|
||||||
if(block > (uint32_t)MTDBufSize)
|
if (block > (uint32_t)MTDBufSize)
|
||||||
block = MTDBufSize;
|
block = MTDBufSize;
|
||||||
read(fd1, MTDBuf, block);
|
read(fd1, MTDBuf, block);
|
||||||
write(fd2, MTDBuf, block);
|
write(fd2, MTDBuf, block);
|
||||||
@@ -353,7 +374,8 @@ bool CExtUpdate::applySettings()
|
|||||||
if (get_fs_usage(mountPkt.c_str(), total, used, &bsize))
|
if (get_fs_usage(mountPkt.c_str(), total, used, &bsize))
|
||||||
free1 = (total * bsize) / 1024 - (used * bsize) / 1024;
|
free1 = (total * bsize) / 1024 - (used * bsize) / 1024;
|
||||||
|
|
||||||
if (!readBackupList(mountPkt)) {
|
if (!readBackupList(mountPkt))
|
||||||
|
{
|
||||||
if (MTDBuf != NULL)
|
if (MTDBuf != NULL)
|
||||||
delete[] MTDBuf;
|
delete[] MTDBuf;
|
||||||
MTDBuf = NULL;
|
MTDBuf = NULL;
|
||||||
@@ -378,9 +400,10 @@ bool CExtUpdate::applySettings()
|
|||||||
fd2 = open(imgFilename.c_str(), O_WRONLY | O_CREAT, 00644);
|
fd2 = open(imgFilename.c_str(), O_WRONLY | O_CREAT, 00644);
|
||||||
if (fd2 < 0)
|
if (fd2 < 0)
|
||||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open image file: ", imgFilename);
|
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open image file: ", imgFilename);
|
||||||
while(fsize > 0) {
|
while (fsize > 0)
|
||||||
|
{
|
||||||
block = (uint32_t)fsize;
|
block = (uint32_t)fsize;
|
||||||
if(block > (uint32_t)MTDBufSize)
|
if (block > (uint32_t)MTDBufSize)
|
||||||
block = MTDBufSize;
|
block = MTDBufSize;
|
||||||
read(fd1, MTDBuf, block);
|
read(fd1, MTDBuf, block);
|
||||||
write(fd2, MTDBuf, block);
|
write(fd2, MTDBuf, block);
|
||||||
@@ -391,7 +414,8 @@ bool CExtUpdate::applySettings()
|
|||||||
close(fd1);
|
close(fd1);
|
||||||
close(fd2);
|
close(fd2);
|
||||||
// check image file size
|
// check image file size
|
||||||
if (mtdRamSize != fsizeDst) {
|
if (mtdRamSize != fsizeDst)
|
||||||
|
{
|
||||||
unlink(imgFilename.c_str());
|
unlink(imgFilename.c_str());
|
||||||
return ErrorReset(DELETE_MTDBUF, "error file size: ", imgFilename);
|
return ErrorReset(DELETE_MTDBUF, "error file size: ", imgFilename);
|
||||||
}
|
}
|
||||||
@@ -399,7 +423,7 @@ bool CExtUpdate::applySettings()
|
|||||||
// unload mtdramDriver only
|
// unload mtdramDriver only
|
||||||
ErrorReset(RESET_UNLOAD);
|
ErrorReset(RESET_UNLOAD);
|
||||||
|
|
||||||
if(hintBox)
|
if (hintBox)
|
||||||
hintBox->hide();
|
hintBox->hide();
|
||||||
|
|
||||||
if (MTDBuf != NULL)
|
if (MTDBuf != NULL)
|
||||||
@@ -416,14 +440,16 @@ int fileSelect(const struct dirent *entry)
|
|||||||
if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0))
|
if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if ((!Wildcard.empty()) && (fnmatch(Wildcard.c_str(), entry->d_name, FNM_FILE_NAME)))
|
if ((!Wildcard.empty()) && (fnmatch(Wildcard.c_str(), entry->d_name, FNM_FILE_NAME)))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::copyFileList(const std::string & fileList, const std::string & dstPath)
|
bool CExtUpdate::copyFileList(const std::string &fileList, const std::string &dstPath)
|
||||||
{
|
{
|
||||||
Wildcard = "";
|
Wildcard = "";
|
||||||
struct dirent **namelist;
|
struct dirent **namelist;
|
||||||
@@ -432,29 +458,34 @@ bool CExtUpdate::copyFileList(const std::string & fileList, const std::string &
|
|||||||
|
|
||||||
size_t pos = fileList.find_last_of("/");
|
size_t pos = fileList.find_last_of("/");
|
||||||
fList = fileList.substr(0, pos);
|
fList = fileList.substr(0, pos);
|
||||||
Wildcard = fileList.substr(pos+1);
|
Wildcard = fileList.substr(pos + 1);
|
||||||
|
|
||||||
int n = scandir(fList.c_str(), &namelist, fileSelect, 0);
|
int n = scandir(fList.c_str(), &namelist, fileSelect, 0);
|
||||||
if (n > 0) {
|
if (n > 0)
|
||||||
|
{
|
||||||
dst = dstPath + fList;
|
dst = dstPath + fList;
|
||||||
FileHelpers->createDir(dst.c_str(), 0755);
|
FileHelpers->createDir(dst.c_str(), 0755);
|
||||||
while (n--) {
|
while (n--)
|
||||||
|
{
|
||||||
std::string dName = namelist[n]->d_name;
|
std::string dName = namelist[n]->d_name;
|
||||||
if (lstat((fList+"/"+dName).c_str(), &FileInfo) != -1) {
|
if (lstat((fList + "/" + dName).c_str(), &FileInfo) != -1)
|
||||||
if (S_ISLNK(FileInfo.st_mode)) {
|
{
|
||||||
|
if (S_ISLNK(FileInfo.st_mode))
|
||||||
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
int len = readlink((fList+"/"+dName).c_str(), buf, sizeof(buf)-1);
|
int len = readlink((fList + "/" + dName).c_str(), buf, sizeof(buf) - 1);
|
||||||
if (len != -1) {
|
if (len != -1)
|
||||||
|
{
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
WRITE_UPDATE_LOG("symlink: %s => %s\n", (dst+"/"+dName).c_str(), buf);
|
WRITE_UPDATE_LOG("symlink: %s => %s\n", (dst + "/" + dName).c_str(), buf);
|
||||||
symlink(buf, (dst+"/"+dName).c_str());
|
symlink(buf, (dst + "/" + dName).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (S_ISREG(FileInfo.st_mode))
|
||||||
if (S_ISREG(FileInfo.st_mode)) {
|
{
|
||||||
WRITE_UPDATE_LOG("copy %s => %s\n", (fList+"/"+dName).c_str(), (dst+"/"+dName).c_str());
|
WRITE_UPDATE_LOG("copy %s => %s\n", (fList + "/" + dName).c_str(), (dst + "/" + dName).c_str());
|
||||||
std::string save = (isBlacklistEntry(fList+"/"+dName)) ? ".save" : "";
|
std::string save = (isBlacklistEntry(fList + "/" + dName)) ? ".save" : "";
|
||||||
if (!FileHelpers->copyFile((fList+"/"+dName).c_str(), (dst + "/" + dName + save).c_str(), FileInfo.st_mode & 0x0FFF))
|
if (!FileHelpers->copyFile((fList + "/" + dName).c_str(), (dst + "/" + dName + save).c_str(), FileInfo.st_mode & 0x0FFF))
|
||||||
return ErrorReset(0, "copyFile error");
|
return ErrorReset(0, "copyFile error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,7 +497,7 @@ bool CExtUpdate::copyFileList(const std::string & fileList, const std::string &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::deleteFileList(const std::string & fileList)
|
bool CExtUpdate::deleteFileList(const std::string &fileList)
|
||||||
{
|
{
|
||||||
Wildcard = "";
|
Wildcard = "";
|
||||||
struct dirent **namelist;
|
struct dirent **namelist;
|
||||||
@@ -475,22 +506,27 @@ bool CExtUpdate::deleteFileList(const std::string & fileList)
|
|||||||
|
|
||||||
size_t pos = fileList.find_last_of("/");
|
size_t pos = fileList.find_last_of("/");
|
||||||
fList = fileList.substr(0, pos);
|
fList = fileList.substr(0, pos);
|
||||||
Wildcard = fileList.substr(pos+1);
|
Wildcard = fileList.substr(pos + 1);
|
||||||
|
|
||||||
int n = scandir(fList.c_str(), &namelist, fileSelect, 0);
|
int n = scandir(fList.c_str(), &namelist, fileSelect, 0);
|
||||||
if (n > 0) {
|
if (n > 0)
|
||||||
while (n--) {
|
{
|
||||||
|
while (n--)
|
||||||
|
{
|
||||||
std::string dName = namelist[n]->d_name;
|
std::string dName = namelist[n]->d_name;
|
||||||
if (lstat((fList+"/"+dName).c_str(), &FileInfo) != -1) {
|
if (lstat((fList + "/" + dName).c_str(), &FileInfo) != -1)
|
||||||
if (S_ISDIR(FileInfo.st_mode)) {
|
{
|
||||||
|
if (S_ISDIR(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// Directory
|
// Directory
|
||||||
WRITE_UPDATE_LOG("delete directory: %s\n", (fList+"/"+dName).c_str());
|
WRITE_UPDATE_LOG("delete directory: %s\n", (fList + "/" + dName).c_str());
|
||||||
FileHelpers->removeDir((fList+"/"+dName).c_str());
|
FileHelpers->removeDir((fList + "/" + dName).c_str());
|
||||||
}
|
}
|
||||||
else if (S_ISREG(FileInfo.st_mode)) {
|
else if (S_ISREG(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// File
|
// File
|
||||||
WRITE_UPDATE_LOG("delete file: %s\n", (fList+"/"+dName).c_str());
|
WRITE_UPDATE_LOG("delete file: %s\n", (fList + "/" + dName).c_str());
|
||||||
unlink((fList+"/"+dName).c_str());
|
unlink((fList + "/" + dName).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(namelist[n]);
|
free(namelist[n]);
|
||||||
@@ -500,27 +536,30 @@ bool CExtUpdate::deleteFileList(const std::string & fileList)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::findConfigEntry(std::string & line, std::string find)
|
bool CExtUpdate::findConfigEntry(std::string &line, std::string find)
|
||||||
{
|
{
|
||||||
if (line.find("#:" + find + "=") == 0) {
|
if (line.find("#:" + find + "=") == 0)
|
||||||
|
{
|
||||||
size_t pos = line.find_first_of('=');
|
size_t pos = line.find_first_of('=');
|
||||||
line = line.substr(pos+1);
|
line = line.substr(pos + 1);
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::readConfig(const std::string & line)
|
bool CExtUpdate::readConfig(const std::string &line)
|
||||||
{
|
{
|
||||||
std::string tmp1 = line;
|
std::string tmp1 = line;
|
||||||
if (findConfigEntry(tmp1, "Log")) {
|
if (findConfigEntry(tmp1, "Log"))
|
||||||
|
{
|
||||||
if (!tmp1.empty())
|
if (!tmp1.empty())
|
||||||
fLogEnabled = atoi(tmp1.c_str());
|
fLogEnabled = atoi(tmp1.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tmp1 = line;
|
tmp1 = line;
|
||||||
if (findConfigEntry(tmp1, "LogFile")) {
|
if (findConfigEntry(tmp1, "LogFile"))
|
||||||
|
{
|
||||||
if (!tmp1.empty())
|
if (!tmp1.empty())
|
||||||
fLogfile = tmp1;
|
fLogfile = tmp1;
|
||||||
return true;
|
return true;
|
||||||
@@ -529,10 +568,12 @@ bool CExtUpdate::readConfig(const std::string & line)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::isBlacklistEntry(const std::string & file)
|
bool CExtUpdate::isBlacklistEntry(const std::string &file)
|
||||||
{
|
{
|
||||||
for(std::vector<std::string>::iterator it = blackList.begin(); it != blackList.end(); ++it) {
|
for (std::vector<std::string>::iterator it = blackList.begin(); it != blackList.end(); ++it)
|
||||||
if (*it == file) {
|
{
|
||||||
|
if (*it == file)
|
||||||
|
{
|
||||||
DBG_MSG("BlacklistEntry %s\n", (*it).c_str());
|
DBG_MSG("BlacklistEntry %s\n", (*it).c_str());
|
||||||
WRITE_UPDATE_LOG("BlacklistEntry: %s\n", (*it).c_str());
|
WRITE_UPDATE_LOG("BlacklistEntry: %s\n", (*it).c_str());
|
||||||
return true;
|
return true;
|
||||||
@@ -544,7 +585,8 @@ bool CExtUpdate::isBlacklistEntry(const std::string & file)
|
|||||||
bool CExtUpdate::checkSpecialFolders(std::string line, bool copy)
|
bool CExtUpdate::checkSpecialFolders(std::string line, bool copy)
|
||||||
{
|
{
|
||||||
if ((line == "/") || (line == "/*") || (line == "/*.*") || (line.find("/dev") == 0) || (line.find("/proc") == 0) ||
|
if ((line == "/") || (line == "/*") || (line == "/*.*") || (line.find("/dev") == 0) || (line.find("/proc") == 0) ||
|
||||||
(line.find("/sys") == 0) || (line.find("/mnt") == 0) || (line.find("/tmp") == 0)) {
|
(line.find("/sys") == 0) || (line.find("/mnt") == 0) || (line.find("/tmp") == 0))
|
||||||
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED;
|
neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED;
|
||||||
snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str());
|
snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str());
|
||||||
@@ -555,16 +597,18 @@ bool CExtUpdate::checkSpecialFolders(std::string line, bool copy)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExtUpdate::readBackupList(const std::string & dstPath)
|
bool CExtUpdate::readBackupList(const std::string &dstPath)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
static struct stat FileInfo;
|
static struct stat FileInfo;
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it;
|
||||||
|
|
||||||
f1 = fopen(backupList.c_str(), "r");
|
f1 = fopen(backupList.c_str(), "r");
|
||||||
if (f1 == NULL) {
|
if (f1 == NULL)
|
||||||
|
{
|
||||||
f1 = fopen(backupList.c_str(), "w");
|
f1 = fopen(backupList.c_str(), "w");
|
||||||
if (f1 != NULL) {
|
if (f1 != NULL)
|
||||||
|
{
|
||||||
char tmp1[1024];
|
char tmp1[1024];
|
||||||
snprintf(tmp1, sizeof(tmp1), "Log=%d\nLogFile=%s\n\n%s\n\n", fLogEnabled, fLogfile.c_str(), defaultBackup.c_str());
|
snprintf(tmp1, sizeof(tmp1), "Log=%d\nLogFile=%s\n\n%s\n\n", fLogEnabled, fLogfile.c_str(), defaultBackup.c_str());
|
||||||
fwrite(tmp1, 1, strlen(tmp1), f1);
|
fwrite(tmp1, 1, strlen(tmp1), f1);
|
||||||
@@ -590,34 +634,41 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
copyList.clear();
|
copyList.clear();
|
||||||
blackList.clear();
|
blackList.clear();
|
||||||
deleteList.clear();
|
deleteList.clear();
|
||||||
while(fgets(buf, sizeof(buf), f1) != NULL) {
|
while (fgets(buf, sizeof(buf), f1) != NULL)
|
||||||
|
{
|
||||||
std::string tmpLine;
|
std::string tmpLine;
|
||||||
line = buf;
|
line = buf;
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
// ignore comments
|
// ignore comments
|
||||||
if (line.find_first_of("#") == 0) {
|
if (line.find_first_of("#") == 0)
|
||||||
|
{
|
||||||
// config vars
|
// config vars
|
||||||
if (line.find_first_of(":") == 1) {
|
if (line.find_first_of(":") == 1)
|
||||||
|
{
|
||||||
if (line.length() > 1)
|
if (line.length() > 1)
|
||||||
readConfig(line);
|
readConfig(line);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pos = line.find_first_of("#");
|
pos = line.find_first_of("#");
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
line = line.substr(0, pos);
|
line = line.substr(0, pos);
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
}
|
}
|
||||||
// find blackList entry
|
// find blackList entry
|
||||||
if (line.find_first_of("-") == 0) {
|
if (line.find_first_of("-") == 0)
|
||||||
|
{
|
||||||
tmpLine = line.substr(1);
|
tmpLine = line.substr(1);
|
||||||
if ((tmpLine.length() > 1) && (lstat(tmpLine.c_str(), &FileInfo) != -1)) {
|
if ((tmpLine.length() > 1) && (lstat(tmpLine.c_str(), &FileInfo) != -1))
|
||||||
|
{
|
||||||
if (S_ISREG(FileInfo.st_mode))
|
if (S_ISREG(FileInfo.st_mode))
|
||||||
blackList.push_back(tmpLine);
|
blackList.push_back(tmpLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find deleteList entry
|
// find deleteList entry
|
||||||
else if (line.find_first_of("~") == 0) {
|
else if (line.find_first_of("~") == 0)
|
||||||
|
{
|
||||||
tmpLine = line.substr(1);
|
tmpLine = line.substr(1);
|
||||||
if (checkSpecialFolders(tmpLine, false))
|
if (checkSpecialFolders(tmpLine, false))
|
||||||
continue;
|
continue;
|
||||||
@@ -626,7 +677,8 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
deleteList.push_back(tmpLine);
|
deleteList.push_back(tmpLine);
|
||||||
}
|
}
|
||||||
// find copyList entry
|
// find copyList entry
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
tmpLine = (line.find_first_of("+") == 0) ? line.substr(1) : line; // '+' add entry = default
|
tmpLine = (line.find_first_of("+") == 0) ? line.substr(1) : line; // '+' add entry = default
|
||||||
if (checkSpecialFolders(tmpLine, true))
|
if (checkSpecialFolders(tmpLine, true))
|
||||||
continue;
|
continue;
|
||||||
@@ -637,20 +689,25 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
fclose(f1);
|
fclose(f1);
|
||||||
|
|
||||||
// read DeleteList
|
// read DeleteList
|
||||||
for(it = deleteList.begin(); it != deleteList.end(); ++it) {
|
for (it = deleteList.begin(); it != deleteList.end(); ++it)
|
||||||
|
{
|
||||||
line = *it;
|
line = *it;
|
||||||
if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) {
|
if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos))
|
||||||
|
{
|
||||||
// Wildcards
|
// Wildcards
|
||||||
WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str());
|
WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str());
|
||||||
deleteFileList(line.c_str());
|
deleteFileList(line.c_str());
|
||||||
}
|
}
|
||||||
else if (lstat(line.c_str(), &FileInfo) != -1) {
|
else if (lstat(line.c_str(), &FileInfo) != -1)
|
||||||
if (S_ISREG(FileInfo.st_mode)) {
|
{
|
||||||
|
if (S_ISREG(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// File
|
// File
|
||||||
WRITE_UPDATE_LOG("delete file: %s\n", line.c_str());
|
WRITE_UPDATE_LOG("delete file: %s\n", line.c_str());
|
||||||
unlink(line.c_str());
|
unlink(line.c_str());
|
||||||
}
|
}
|
||||||
else if (S_ISDIR(FileInfo.st_mode)){
|
else if (S_ISDIR(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// Directory
|
// Directory
|
||||||
WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str());
|
WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str());
|
||||||
FileHelpers->removeDir(line.c_str());
|
FileHelpers->removeDir(line.c_str());
|
||||||
@@ -663,16 +720,18 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
free2 = (total * bsize) / 1024 - (used * bsize) / 1024;
|
free2 = (total * bsize) / 1024 - (used * bsize) / 1024;
|
||||||
|
|
||||||
// read copyList
|
// read copyList
|
||||||
for(it = copyList.begin(); it != copyList.end(); ++it) {
|
for (it = copyList.begin(); it != copyList.end(); ++it)
|
||||||
|
{
|
||||||
line = *it;
|
line = *it;
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
// remove '/' from line end
|
// remove '/' from line end
|
||||||
size_t len = line.length();
|
size_t len = line.length();
|
||||||
pos = line.find_last_of("/");
|
pos = line.find_last_of("/");
|
||||||
if (len == pos+1)
|
if (len == pos + 1)
|
||||||
line = line.substr(0, pos);
|
line = line.substr(0, pos);
|
||||||
std::string dst = dstPath + line;
|
std::string dst = dstPath + line;
|
||||||
if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) {
|
if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos))
|
||||||
|
{
|
||||||
// Wildcards
|
// Wildcards
|
||||||
DBG_MSG("Wildcards: %s\n", dst.c_str());
|
DBG_MSG("Wildcards: %s\n", dst.c_str());
|
||||||
WRITE_UPDATE_LOG("\n");
|
WRITE_UPDATE_LOG("\n");
|
||||||
@@ -680,9 +739,12 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
WRITE_UPDATE_LOG("Wildcards: %s\n", dst.c_str());
|
WRITE_UPDATE_LOG("Wildcards: %s\n", dst.c_str());
|
||||||
copyFileList(line, dstPath);
|
copyFileList(line, dstPath);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (lstat(line.c_str(), &FileInfo) != -1) {
|
{
|
||||||
if (S_ISREG(FileInfo.st_mode)) {
|
if (lstat(line.c_str(), &FileInfo) != -1)
|
||||||
|
{
|
||||||
|
if (S_ISREG(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// one file only
|
// one file only
|
||||||
pos = dst.find_last_of("/");
|
pos = dst.find_last_of("/");
|
||||||
std::string dir = dst.substr(0, pos);
|
std::string dir = dst.substr(0, pos);
|
||||||
@@ -695,7 +757,8 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
if (!FileHelpers->copyFile(line.c_str(), (dst + save).c_str(), FileInfo.st_mode & 0x0FFF))
|
if (!FileHelpers->copyFile(line.c_str(), (dst + save).c_str(), FileInfo.st_mode & 0x0FFF))
|
||||||
return ErrorReset(0, "copyFile error");
|
return ErrorReset(0, "copyFile error");
|
||||||
}
|
}
|
||||||
else if (S_ISDIR(FileInfo.st_mode)) {
|
else if (S_ISDIR(FileInfo.st_mode))
|
||||||
|
{
|
||||||
// directory
|
// directory
|
||||||
DBG_MSG("directory: %s => %s\n", line.c_str(), dst.c_str());
|
DBG_MSG("directory: %s => %s\n", line.c_str(), dst.c_str());
|
||||||
WRITE_UPDATE_LOG("\n");
|
WRITE_UPDATE_LOG("\n");
|
||||||
@@ -709,7 +772,8 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
}
|
}
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) {
|
if (get_fs_usage(mountPkt.c_str(), total, used, &bsize))
|
||||||
|
{
|
||||||
uint64_t flashWarning = 1000; // 1MB
|
uint64_t flashWarning = 1000; // 1MB
|
||||||
uint64_t flashError = 600; // 600KB
|
uint64_t flashError = 600; // 600KB
|
||||||
char buf1[1024];
|
char buf1[1024];
|
||||||
@@ -717,15 +781,18 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
free3 = total - (used * bsize) / 1024;
|
free3 = total - (used * bsize) / 1024;
|
||||||
printf("##### [%s] %llu KB free org, %llu KB free after delete, %llu KB free now\n", __FUNCTION__, free1, free2, free3);
|
printf("##### [%s] %llu KB free org, %llu KB free after delete, %llu KB free now\n", __FUNCTION__, free1, free2, free3);
|
||||||
memset(buf1, '\0', sizeof(buf1));
|
memset(buf1, '\0', sizeof(buf1));
|
||||||
if (free3 <= flashError) {
|
if (free3 <= flashError)
|
||||||
snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total);
|
{
|
||||||
|
snprintf(buf1, sizeof(buf1) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total);
|
||||||
ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_ERROR);
|
ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_ERROR);
|
||||||
flashErrorFlag = true;
|
flashErrorFlag = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (free3 <= flashWarning) {
|
else if (free3 <= flashWarning)
|
||||||
snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total);
|
{
|
||||||
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO) != CMsgBox::mbrYes) {
|
snprintf(buf1, sizeof(buf1) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total);
|
||||||
|
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO) != CMsgBox::mbrYes)
|
||||||
|
{
|
||||||
flashErrorFlag = true;
|
flashErrorFlag = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -738,7 +805,8 @@ void CExtUpdate::updateLog(const char *buf)
|
|||||||
{
|
{
|
||||||
if ((!fUpdate) && (fLogEnabled))
|
if ((!fUpdate) && (fLogEnabled))
|
||||||
fUpdate = fopen(fLogfile.c_str(), "a");
|
fUpdate = fopen(fLogfile.c_str(), "a");
|
||||||
if (fUpdate) {
|
if (fUpdate)
|
||||||
|
{
|
||||||
fwrite(buf, 1, strlen(buf), fUpdate);
|
fwrite(buf, 1, strlen(buf), fUpdate);
|
||||||
fclose(fUpdate);
|
fclose(fUpdate);
|
||||||
fUpdate = NULL;
|
fUpdate = NULL;
|
||||||
|
@@ -54,7 +54,7 @@ class CExtUpdate
|
|||||||
std::string mtdramDriver;
|
std::string mtdramDriver;
|
||||||
std::string backupList, defaultBackup;
|
std::string backupList, defaultBackup;
|
||||||
std::string mountPkt;
|
std::string mountPkt;
|
||||||
CFileHelpers* FileHelpers;
|
CFileHelpers *FileHelpers;
|
||||||
std::vector<std::string> copyList, blackList, deleteList;
|
std::vector<std::string> copyList, blackList, deleteList;
|
||||||
|
|
||||||
bool flashErrorFlag;
|
bool flashErrorFlag;
|
||||||
@@ -63,15 +63,15 @@ class CExtUpdate
|
|||||||
uint64_t free1, free2, free3;
|
uint64_t free1, free2, free3;
|
||||||
|
|
||||||
bool applySettings(void);
|
bool applySettings(void);
|
||||||
bool readBackupList(const std::string & dstPath);
|
bool readBackupList(const std::string &dstPath);
|
||||||
bool copyFileList(const std::string & fileList, const std::string & dstPath);
|
bool copyFileList(const std::string &fileList, const std::string &dstPath);
|
||||||
bool deleteFileList(const std::string & fileList);
|
bool deleteFileList(const std::string &fileList);
|
||||||
bool readConfig(const std::string & Config);
|
bool readConfig(const std::string &Config);
|
||||||
bool findConfigEntry(std::string & line, std::string find);
|
bool findConfigEntry(std::string &line, std::string find);
|
||||||
bool isMtdramLoad();
|
bool isMtdramLoad();
|
||||||
bool checkSpecialFolders(std::string line, bool copy);
|
bool checkSpecialFolders(std::string line, bool copy);
|
||||||
|
|
||||||
FILE * fUpdate;
|
FILE *fUpdate;
|
||||||
char updateLogBuf[1024];
|
char updateLogBuf[1024];
|
||||||
std::string fLogfile;
|
std::string fLogfile;
|
||||||
int fLogEnabled;
|
int fLogEnabled;
|
||||||
@@ -83,18 +83,19 @@ class CExtUpdate
|
|||||||
MODE_EXPERT = 0,
|
MODE_EXPERT = 0,
|
||||||
MODE_SOFTUPDATE = 1
|
MODE_SOFTUPDATE = 1
|
||||||
};
|
};
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SOFTUPDATE_NAME_DEFAULT,
|
SOFTUPDATE_NAME_DEFAULT,
|
||||||
SOFTUPDATE_NAME_HOSTNAME_TIME,
|
SOFTUPDATE_NAME_HOSTNAME_TIME,
|
||||||
SOFTUPDATE_NAME_ORGNAME_TIME
|
SOFTUPDATE_NAME_ORGNAME_TIME
|
||||||
};
|
};
|
||||||
CExtUpdate();
|
CExtUpdate();
|
||||||
~CExtUpdate();
|
~CExtUpdate();
|
||||||
static CExtUpdate* getInstance();
|
static CExtUpdate *getInstance();
|
||||||
|
|
||||||
bool applySettings(std::string & filename, int mode);
|
bool applySettings(std::string &filename, int mode);
|
||||||
bool ErrorReset(bool modus, const std::string & msg1="", const std::string & msg2="");
|
bool ErrorReset(bool modus, const std::string &msg1 = "", const std::string &msg2 = "");
|
||||||
bool isBlacklistEntry(const std::string & file);
|
bool isBlacklistEntry(const std::string &file);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user