diff options
author | 05356787 <05356787@localhost.localdomain> | 2008-10-31 13:10:02 -0200 |
---|---|---|
committer | 05356787 <05356787@localhost.localdomain> | 2008-10-31 13:10:02 -0200 |
commit | 7608bb025507f0beb235abb5e1ef7ad84148892c (patch) | |
tree | fe39c998415fe91f5d3cb1437fc781ed9cae1658 /hardinfo2/arch/linux/common | |
parent | 1d2c77e7e1b4c3fcbc6a36dd89fe3287c324e032 (diff) |
Add filesystem usage bars
Diffstat (limited to 'hardinfo2/arch/linux/common')
-rw-r--r-- | hardinfo2/arch/linux/common/filesystem.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h index b3008387..48dd2160 100644 --- a/hardinfo2/arch/linux/common/filesystem.h +++ b/hardinfo2/arch/linux/common/filesystem.h @@ -51,10 +51,18 @@ scan_filesystems(void) tmp = g_strsplit(buf, " ", 0); if (!statfs(tmp[1], &sfs)) { + gfloat use_ratio; + size = (float) sfs.f_bsize * (float) sfs.f_blocks; avail = (float) sfs.f_bsize * (float) sfs.f_bavail; used = size - avail; + if (avail == 0.0f) { + use_ratio = 0.0f; + } else { + use_ratio = 100.0f * (used / size); + } + gchar *strsize = size_human_readable(size), *stravail = size_human_readable(avail), *strused = size_human_readable(used); @@ -81,9 +89,9 @@ scan_filesystems(void) stravail); g_hash_table_insert(moreinfo, g_strdup_printf("FS%d", ++count), strhash); - fs_list = h_strdup_cprintf("$FS%d$%s=%s|%s\n", + fs_list = h_strdup_cprintf("$FS%d$%s=%.2f|%s|%s\n", fs_list, - count, tmp[0], stravail, strsize); + count, tmp[0], use_ratio, strsize, stravail); g_free(strsize); g_free(stravail); |