diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 2604bc194..305d57939 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -636,9 +636,9 @@ void CInfoViewerBB::showSysfsHdd() if (g_settings.infobar_show_sysfs_hdd) { //sysFS info int percent = 0; - long t, u; + uint64_t t, u; if (get_fs_usage("/", t, u)) - percent = (u * 100ULL) / t; + percent = (int)((u * 100ULL) / t); showBarSys(percent); if (check_dir(g_settings.network_nfs_recordingdir) == 0) @@ -651,9 +651,9 @@ void CInfoViewerBB::showSysfsHdd() void* CInfoViewerBB::hddperThread(void *arg) { CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; - long t, u; + uint64_t t, u; if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) - infoViewerBB->hddpercent = (u * 100ULL) / t; + infoViewerBB->hddpercent = (int)((u * 100ULL) / t); else infoViewerBB->hddpercent = 0; infoViewerBB->hddperTflag=false; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 6588ba1cc..4f32e7018 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -571,8 +571,9 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) return false; } - long btotal = 0, bused = 0, bsize = 0; - int backupRequiredSize = 0; + uint64_t btotal = 0, bused = 0; + long bsize = 0; + uint64_t backupRequiredSize = 0; #ifdef BOXMODEL_APOLLO if (mtd == -1) { // check disk space for image creation if (!get_fs_usage("/", btotal, bused, &bsize)) { @@ -580,11 +581,11 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } - backupRequiredSize = (int)((bused * bsize) / 1024) * 2; // twice disk space for summarized image + backupRequiredSize = ((bused * bsize) / 1024ULL) * 2ULL; // twice disk space for summarized image } else #endif - backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024; + backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024ULL; btotal = 0; bused = 0; bsize = 0; if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) { @@ -592,9 +593,11 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } - int backupMaxSize = (int)((btotal - bused) * bsize); - int res = 10; // Reserved 10% of available space - backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100)) / 1024; + uint64_t backupMaxSize = (btotal - bused) * (uint64_t)bsize; + uint64_t res = 10; // Reserved 10% of available space + backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100ULL)) / 1024ULL; + printf("##### [%s] backupMaxSize: %llu, btotal: %llu, bused: %llu, bsize: %ld\n", __FUNCTION__, backupMaxSize, btotal, bused, bsize); + if (backupMaxSize < backupRequiredSize) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), backupMaxSize, backupRequiredSize); ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index 5deeb5ea7..eafb2fa17 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -74,8 +74,9 @@ CExtUpdate::CExtUpdate() FileHelpers = NULL; MTDBuf = NULL; flashErrorFlag = false; - total = bsize = used = 0; - free1 = free2 = free3 = 0; + bsize = 0; + total = used = 0; + free1 = free2 = free3 = 0; copyList.clear(); blackList.clear(); @@ -704,12 +705,12 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) sync(); if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) { - long flashWarning = 1000; // 1MB - long flashError = 600; // 600KB + uint64_t flashWarning = 1000; // 1MB + uint64_t flashError = 600; // 600KB char buf1[1024]; total = (total * bsize) / 1024; free3 = total - (used * bsize) / 1024; - printf("##### [%s] %ld KB free org, %ld KB free after delete, %ld 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)); if (free3 <= flashError) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); diff --git a/src/gui/update_ext.h b/src/gui/update_ext.h index de3b07d65..2347e5d07 100644 --- a/src/gui/update_ext.h +++ b/src/gui/update_ext.h @@ -57,8 +57,9 @@ class CExtUpdate std::vector copyList, blackList, deleteList; bool flashErrorFlag; - long total, bsize, used; - long free1, free2, free3; + long bsize; + uint64_t total, used; + uint64_t free1, free2, free3; bool applySettings(void); bool readBackupList(const std::string & dstPath);