Make fs_update() handle large disks.

Use gint64 to handle large block sizes for huge multi terabyte disks.
This commit is contained in:
Bill Wilson 2015-07-15 18:20:10 -05:00
parent d4eb792468
commit 14c4cc4ba0
1 changed files with 12 additions and 5 deletions

View File

@ -724,7 +724,7 @@ fs_update(void)
GkrellmPanel *p; GkrellmPanel *p;
GkrellmKrell *k; GkrellmKrell *k;
GList *list; GList *list;
glong used, avail; gint64 used, avail;
gint full_scale, index, w_scroll, w; gint full_scale, index, w_scroll, w;
gboolean fs_check, nfs_check, force_check, force_draw, gboolean fs_check, nfs_check, force_check, force_draw,
mounting_enabled; mounting_enabled;
@ -807,13 +807,20 @@ fs_update(void)
gth = g_thread_new("get_fsusage", get_fsusage_thread, fs); gth = g_thread_new("get_fsusage", get_fsusage_thread, fs);
g_thread_unref(gth); g_thread_unref(gth);
} }
fs->krell_factor = fs->blocks > 2097152 ? 1024 : 1; if (fs->blocks > 2147483648LL)
fs->krell_factor = 1024 * 1024;
else if (fs->blocks > 2097152LL)
fs->krell_factor = 1024 * 1024;
else
fs->krell_factor = 1;
} }
avail = fs->bavail >= 0 ? fs->bavail : 0; avail = fs->bavail >= 0 ? fs->bavail : 0;
used = fs->blocks - fs->bfree; used = fs->blocks - fs->bfree;
full_scale = (gint) (used + avail) / fs->krell_factor;
used /= fs->krell_factor; full_scale = (gint) ((used + avail) / (gint64) fs->krell_factor);
used = used / (gint64) fs->krell_factor;
gkrellm_set_krell_full_scale(k, full_scale, 1); gkrellm_set_krell_full_scale(k, full_scale, 1);
if (!fs->busy) if (!fs->busy)
@ -823,7 +830,7 @@ fs_update(void)
) )
gkrellm_update_krell(p, k, 0); gkrellm_update_krell(p, k, 0);
else else
gkrellm_update_krell(p, k, used); gkrellm_update_krell(p, k, (gulong) used);
if (full_scale > 0) if (full_scale > 0)
gkrellm_check_alert(fs->alert, gkrellm_check_alert(fs->alert,
100.0 * (gfloat) used / (gfloat) full_scale); 100.0 * (gfloat) used / (gfloat) full_scale);