neutrino: Fit various functions to the changed at get_fs_usage()

This commit is contained in:
Michael Liebmann
2013-10-08 07:28:37 +02:00
parent 36f3579df6
commit 4ee8fded80
4 changed files with 23 additions and 18 deletions

View File

@@ -636,9 +636,9 @@ void CInfoViewerBB::showSysfsHdd()
if (g_settings.infobar_show_sysfs_hdd) { if (g_settings.infobar_show_sysfs_hdd) {
//sysFS info //sysFS info
int percent = 0; int percent = 0;
long t, u; uint64_t t, u;
if (get_fs_usage("/", t, u)) if (get_fs_usage("/", t, u))
percent = (u * 100ULL) / t; percent = (int)((u * 100ULL) / t);
showBarSys(percent); showBarSys(percent);
if (check_dir(g_settings.network_nfs_recordingdir) == 0) if (check_dir(g_settings.network_nfs_recordingdir) == 0)
@@ -651,9 +651,9 @@ void CInfoViewerBB::showSysfsHdd()
void* CInfoViewerBB::hddperThread(void *arg) void* CInfoViewerBB::hddperThread(void *arg)
{ {
CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg;
long t, u; uint64_t t, u;
if (get_fs_usage(g_settings.network_nfs_recordingdir, 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 else
infoViewerBB->hddpercent = 0; infoViewerBB->hddpercent = 0;
infoViewerBB->hddperTflag=false; infoViewerBB->hddperTflag=false;

View File

@@ -571,8 +571,9 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
return false; return false;
} }
long btotal = 0, bused = 0, bsize = 0; uint64_t btotal = 0, bused = 0;
int backupRequiredSize = 0; long bsize = 0;
uint64_t backupRequiredSize = 0;
#ifdef BOXMODEL_APOLLO #ifdef BOXMODEL_APOLLO
if (mtd == -1) { // check disk space for image creation if (mtd == -1) { // check disk space for image creation
if (!get_fs_usage("/", btotal, bused, &bsize)) { if (!get_fs_usage("/", btotal, bused, &bsize)) {
@@ -580,11 +581,11 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);
return false; 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 else
#endif #endif
backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024; backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024ULL;
btotal = 0; bused = 0; bsize = 0; btotal = 0; bused = 0; bsize = 0;
if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) { 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); ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);
return false; return false;
} }
int backupMaxSize = (int)((btotal - bused) * bsize); uint64_t backupMaxSize = (btotal - bused) * (uint64_t)bsize;
int res = 10; // Reserved 10% of available space uint64_t res = 10; // Reserved 10% of available space
backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100)) / 1024; 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) { if (backupMaxSize < backupRequiredSize) {
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), 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); ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);

View File

@@ -74,8 +74,9 @@ CExtUpdate::CExtUpdate()
FileHelpers = NULL; FileHelpers = NULL;
MTDBuf = NULL; MTDBuf = NULL;
flashErrorFlag = false; flashErrorFlag = false;
total = bsize = used = 0; bsize = 0;
free1 = free2 = free3 = 0; total = used = 0;
free1 = free2 = free3 = 0;
copyList.clear(); copyList.clear();
blackList.clear(); blackList.clear();
@@ -704,12 +705,12 @@ 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)) {
long flashWarning = 1000; // 1MB uint64_t flashWarning = 1000; // 1MB
long flashError = 600; // 600KB uint64_t flashError = 600; // 600KB
char buf1[1024]; char buf1[1024];
total = (total * bsize) / 1024; total = (total * bsize) / 1024;
free3 = total - (used * 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)); 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);

View File

@@ -57,8 +57,9 @@ class CExtUpdate
std::vector<std::string> copyList, blackList, deleteList; std::vector<std::string> copyList, blackList, deleteList;
bool flashErrorFlag; bool flashErrorFlag;
long total, bsize, used; long bsize;
long free1, free2, free3; uint64_t total, used;
uint64_t free1, free2, free3;
bool applySettings(void); bool applySettings(void);
bool readBackupList(const std::string & dstPath); bool readBackupList(const std::string & dstPath);