mirror of
https://github.com/pikami/slstatus.git
synced 2024-11-27 22:05:42 +00:00
fixed disk percent
This commit is contained in:
parent
faae8292fb
commit
6624985cf4
12
slstatus.c
12
slstatus.c
@ -210,14 +210,20 @@ get_datetime()
|
|||||||
char *
|
char *
|
||||||
get_diskusage()
|
get_diskusage()
|
||||||
{
|
{
|
||||||
|
int perc = 0;
|
||||||
struct statvfs fs;
|
struct statvfs fs;
|
||||||
float perc = 0;
|
|
||||||
|
/* try to open mountpoint */
|
||||||
if (statvfs(mountpath, &fs) < 0) {
|
if (statvfs(mountpath, &fs) < 0) {
|
||||||
fprintf(stderr, "Could not get filesystem info.\n");
|
fprintf(stderr, "Could not get filesystem info.\n");
|
||||||
return smprintf("n/a");
|
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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user