aboutsummaryrefslogtreecommitdiff
path: root/arch/linux/common/filesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/linux/common/filesystem.h')
-rw-r--r--arch/linux/common/filesystem.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/arch/linux/common/filesystem.h b/arch/linux/common/filesystem.h
index d8166fc3..1eff0818 100644
--- a/arch/linux/common/filesystem.h
+++ b/arch/linux/common/filesystem.h
@@ -1,6 +1,6 @@
/*
* HardInfo - Displays System Information
- * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br>
+ * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -51,10 +51,22 @@ 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 (size == 0.0f) {
+ continue;
+ }
+
+ if (avail == 0.0f) {
+ use_ratio = 100.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 +93,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 total, %s free\n",
+ fs_list = h_strdup_cprintf("$FS%d$%s=%.2f %% (%s of %s)|%s\n",
fs_list,
- count, tmp[0], strsize, stravail);
+ count, tmp[0], use_ratio, stravail, strsize, tmp[1]);
g_free(strsize);
g_free(stravail);