mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
- infoviewerbb: determination of hdd-percentage in a seperate thread
This commit is contained in:
@@ -86,6 +86,8 @@ CInfoViewerBB::CInfoViewerBB()
|
|||||||
pthread_detach(scrambledT);
|
pthread_detach(scrambledT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
hddperT = 0;
|
||||||
|
hddperTflag = false;
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +119,10 @@ CInfoViewerBB::~CInfoViewerBB()
|
|||||||
pthread_cancel(scrambledT);
|
pthread_cancel(scrambledT);
|
||||||
scrambledT = 0;
|
scrambledT = 0;
|
||||||
}
|
}
|
||||||
|
if(hddperT) {
|
||||||
|
pthread_cancel(hddperT);
|
||||||
|
hddperT = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CInfoViewerBB* CInfoViewerBB::getInstance()
|
CInfoViewerBB* CInfoViewerBB::getInstance()
|
||||||
@@ -589,26 +595,45 @@ void CInfoViewerBB::showIcon_Tuner()
|
|||||||
|
|
||||||
void CInfoViewerBB::showSysfsHdd()
|
void CInfoViewerBB::showSysfsHdd()
|
||||||
{
|
{
|
||||||
if ((g_settings.infobar_show_sysfs_hdd) && (is_visible)) {
|
if (g_settings.infobar_show_sysfs_hdd) {
|
||||||
long blocks_used;
|
//sysFS info
|
||||||
struct statfs s;
|
int sysper = 0;
|
||||||
int per = 0;
|
sysper = get_fs_usage("/");
|
||||||
if (::statfs("/", &s) == 0 && s.f_blocks) {
|
showBarSys(sysper);
|
||||||
// per = (s.f_blocks - s.f_bfree) / (s.f_blocks/100);
|
|
||||||
blocks_used = s.f_blocks - s.f_bfree;
|
//HDD info in a seperate thread
|
||||||
per = (blocks_used * 100ULL) / s.f_blocks;
|
if(!hddperTflag) {
|
||||||
}
|
hddperTflag=true;
|
||||||
varscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth , 6, per, 100);
|
pthread_create(&hddperT, NULL, hddperThread, (void*) this);
|
||||||
per = 0;
|
pthread_detach(hddperT);
|
||||||
//HD info
|
|
||||||
if(!check_dir(g_settings.network_nfs_recordingdir)){
|
|
||||||
if (::statfs(g_settings.network_nfs_recordingdir, &s) == 0 && s.f_blocks) {
|
|
||||||
blocks_used = s.f_blocks - s.f_bfree;
|
|
||||||
per = (blocks_used * 100ULL) / s.f_blocks;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2, hddwidth, 6, per, 100);
|
}
|
||||||
}
|
|
||||||
|
void* CInfoViewerBB::hddperThread(void *arg)
|
||||||
|
{
|
||||||
|
CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg;
|
||||||
|
|
||||||
|
int hddper = 0;
|
||||||
|
hddper = get_fs_usage(g_settings.network_nfs_recordingdir);
|
||||||
|
infoViewerBB->showBarHdd(hddper);
|
||||||
|
|
||||||
|
infoViewerBB->hddperTflag=false;
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInfoViewerBB::showBarSys(int percent)
|
||||||
|
{
|
||||||
|
if (is_visible)
|
||||||
|
varscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6, percent, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInfoViewerBB::showBarHdd(int percent)
|
||||||
|
{
|
||||||
|
if (percent < 0)
|
||||||
|
percent = 0;
|
||||||
|
if (is_visible)
|
||||||
|
hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset)
|
void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset)
|
||||||
|
@@ -121,6 +121,13 @@ class CInfoViewerBB
|
|||||||
static void* scrambledThread(void *arg);
|
static void* scrambledThread(void *arg);
|
||||||
void scrambledCheck(bool force=false);
|
void scrambledCheck(bool force=false);
|
||||||
|
|
||||||
|
void showBarSys(int percent = 0);
|
||||||
|
void showBarHdd(int percent = 0);
|
||||||
|
|
||||||
|
pthread_t hddperT;
|
||||||
|
static void* hddperThread(void *arg);
|
||||||
|
bool hddperTflag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CInfoViewerBB();
|
CInfoViewerBB();
|
||||||
~CInfoViewerBB();
|
~CInfoViewerBB();
|
||||||
|
@@ -158,11 +158,11 @@ int safe_mkdir(char * path)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_dir(const char * newdir)
|
int check_dir(const char * dir)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
struct statfs s;
|
struct statfs s;
|
||||||
if (::statfs(newdir, &s) == 0) {
|
if (::statfs(dir, &s) == 0) {
|
||||||
switch (s.f_type) /* f_type is long */
|
switch (s.f_type) /* f_type is long */
|
||||||
{
|
{
|
||||||
case 0xEF53L: /*EXT2 & EXT3*/
|
case 0xEF53L: /*EXT2 & EXT3*/
|
||||||
@@ -174,12 +174,29 @@ int check_dir(const char * newdir)
|
|||||||
case 0x58465342L: /*xfs*/
|
case 0x58465342L: /*xfs*/
|
||||||
case 0x4d44L: /*msdos*/
|
case 0x4d44L: /*msdos*/
|
||||||
case 0x0187: /* AUTOFS_SUPER_MAGIC */
|
case 0x0187: /* AUTOFS_SUPER_MAGIC */
|
||||||
case 0x858458f6: /*ramfs*/
|
case 0x858458f6L: /*ramfs*/
|
||||||
return 0;//ok
|
case 0x72b6L: /*jffs2*/
|
||||||
|
break; //ok
|
||||||
default:
|
default:
|
||||||
fprintf( stderr,"%s Unknow File system type: %i\n",newdir ,s.f_type);
|
fprintf(stderr, "%s Unknow File system type: %i\n" ,dir ,s.f_type);
|
||||||
break;
|
ret = -1;
|
||||||
|
break; // error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1; // error
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_fs_usage(const char * dir)
|
||||||
|
{
|
||||||
|
int ret = check_dir(dir);
|
||||||
|
long blocks_used;
|
||||||
|
struct statfs s;
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
if (::statfs(dir, &s) == 0 && s.f_blocks) {
|
||||||
|
blocks_used = s.f_blocks - s.f_bfree;
|
||||||
|
ret = (blocks_used * 100ULL) / s.f_blocks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -28,8 +28,9 @@ int my_system(const char * cmd);
|
|||||||
|
|
||||||
FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type);
|
FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type);
|
||||||
int safe_mkdir(char * path);
|
int safe_mkdir(char * path);
|
||||||
int check_dir(const char * newdir);
|
|
||||||
bool file_exists(const char *filename);
|
bool file_exists(const char *filename);
|
||||||
void wakeup_hdd(const char *hdd_dir);
|
void wakeup_hdd(const char *hdd_dir);
|
||||||
|
int check_dir(const char * dir);
|
||||||
|
int get_fs_usage(const char * dir);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user