summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-29 15:55:14 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-29 15:55:14 +0800
commita198a56d7b75a0c3525ab0feb8d0013ebeae898a (patch)
tree135d2ab7e561435c04c2c2fa83a7461de606e434
parentfbe2b31ad4c561c4c54b07cb32faffff5912669b (diff)
downloadpttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar.gz
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar.bz2
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar.lz
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar.xz
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.tar.zst
pttbbs-a198a56d7b75a0c3525ab0feb8d0013ebeae898a.zip
the /proc/meminfo interface in linux kernel 2.6 is diferrent
although this is a useless function... git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2172 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/osdep.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/mbbsd/osdep.c b/mbbsd/osdep.c
index fb5ce17c..7b3fac06 100644
--- a/mbbsd/osdep.c
+++ b/mbbsd/osdep.c
@@ -177,7 +177,7 @@ cpuload(char *str)
}
double
-swapused(int *total, long *used)
+swapused(int *total, int *used)
{
double percent = -1;
kvm_t *kd;
@@ -220,17 +220,20 @@ cpuload(char *str)
}
double
-swapused(int *total, long *used)
+swapused(int *total, int *used)
{
double percent = -1;
char buf[101];
FILE *fp;
if ((fp = fopen("/proc/meminfo", "r"))) {
- while (fgets(buf, 100, fp) && buf[0] != 'S');
- if (sscanf(buf + 6, "%d %ld", total, used) == 2)
- if (*total != 0)
- percent = (double)*used / (double)*total;
+ while (fgets(buf, 100, fp) && strstr(buf, "SwapTotal:") == NULL);
+ sscanf(buf, "%*s %d", total);
+ fgets(buf, 100, fp);
+ sscanf(buf, "%*s %d", used);
+ *used = *total - *used;
+ if (*total != 0)
+ percent = (double)*used / (double)*total;
fclose(fp);
}
return percent;