Xinqi Bao's Git
projects
/
slstatus.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
faae829
)
fixed disk percent
author
Aaron Marcher <
[email protected]
>
Fri, 11 Mar 2016 12:11:15 +0000
(13:11 +0100)
committer
Aaron Marcher (drkhsh) <
[email protected]
>
Fri, 11 Mar 2016 12:11:15 +0000
(13:11 +0100)
slstatus.c
diff
|
blob
|
history
diff --git
a/slstatus.c
b/slstatus.c
index
8ec68a4
..
75413a1
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-210,14
+210,20
@@
get_datetime()
char *
get_diskusage()
{
char *
get_diskusage()
{
+ int perc = 0;
struct statvfs fs;
struct statvfs fs;
- float perc = 0;
+
+ /* try to open mountpoint */
if (statvfs(mountpath, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
return smprintf("n/a");
}
if (statvfs(mountpath, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
return smprintf("n/a");
}
- perc = 1.0f - ((float)fs.f_bavail/(float)fs.f_blocks);
- return smprintf("%2f%%", perc);
+
+ /* calculate percent */
+ perc = 100 * (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks));
+
+ /* return perc */
+ return smprintf("%d%%", perc);
}
/* ram percentage */
}
/* ram percentage */