diff options
author | Pietro Cerutti <gahr@FreeBSD.org> | 2013-05-14 16:19:38 +0000 |
---|---|---|
committer | Pietro Cerutti <gahr@FreeBSD.org> | 2013-05-14 16:19:38 +0000 |
commit | 6ea90da5fdcddd160199ee00f1be57bc63895baf (patch) | |
tree | 9252dbc5a1aec5ae0f480d96c1a614cd22871303 /x11-wm | |
parent | - Fix conflict/build failure with png by using libgfx from the ports tree (diff) |
- Fix swap usage values in E-MemWatch.epplet
Notes
Notes:
svn path=/head/; revision=318169
Diffstat (limited to 'x11-wm')
-rw-r--r-- | x11-wm/epplets/files/patch-epplets_E-MemWatch.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/x11-wm/epplets/files/patch-epplets_E-MemWatch.c b/x11-wm/epplets/files/patch-epplets_E-MemWatch.c index 8ae3951f438b..624b73e394cb 100644 --- a/x11-wm/epplets/files/patch-epplets_E-MemWatch.c +++ b/x11-wm/epplets/files/patch-epplets_E-MemWatch.c @@ -1,5 +1,5 @@ ---- epplets/E-MemWatch.c.orig 2006-04-16 00:32:42.000000000 +0200 -+++ epplets/E-MemWatch.c 2008-01-25 23:37:25.000000000 +0100 +--- epplets/E-MemWatch.c.orig 2012-09-30 11:38:35.000000000 +0200 ++++ epplets/E-MemWatch.c 2013-05-14 18:17:45.000000000 +0200 @@ -1,5 +1,6 @@ /* * Copyright (C) 1999-2000, Michael Jennings @@ -19,7 +19,7 @@ +#endif + #if 0 - # define D(x) do {printf("%10s | %7d: [debug] ", __FILE__, __LINE__); printf x; fflush(stdout);} while (0) + #define D(x) do {printf("%10s | %7d: [debug] ", __FILE__, __LINE__); printf x; fflush(stdout);} while (0) #else @@ -74,7 +82,7 @@ used = (unsigned long)mem.used; @@ -29,7 +29,7 @@ +#elif defined(linux) FILE *fp; - if ((fp = fopen("/proc/meminfo", "r")) == NULL) + if (!(fp = fopen("/proc/meminfo", "r"))) @@ -109,8 +117,20 @@ sscanf(buff, "%*s %lu %lu %*u %*u %lu %lu", &total, &used, &buffers, &cached); @@ -40,7 +40,7 @@ + sysctlbyname("hw.physmem", &total, &len, NULL, 0); + sysctlbyname("vm.stats.vm.v_free_count", &free, &len, NULL, 0); + sysctlbyname("vfs.bufspace", &buffers, &len, NULL, 0); -+ sysctlbyname("vfs.stats.vm.v_cache_count", &cached, &len, NULL, 0); ++ sysctlbyname("vm.stats.vm.v_cache_count", &cached, &len, NULL, 0); + + cached *= pagesize; + free *= pagesize; @@ -80,11 +80,12 @@ if (kernel_2_6) { -@@ -174,7 +194,21 @@ +@@ -174,8 +194,23 @@ } fclose(fp); -#endif /* HAVE_LIBGTOP */ +- swap_val = (int)((((float)used) / total) * 100.0); +#elif defined(__FreeBSD__) + kvm_t *k; + struct kvm_swap swp; @@ -93,17 +94,19 @@ + used = 0; + total = 1; + } else { -+ if(kvm_getswapinfo(k, &swp, 1, 0) != -1) { -+ used = swp.ksw_used; -+ total = swp.ksw_total; ++ if(kvm_getswapinfo(k, &swp, 1, 0) != 1) { ++ used = (unsigned long)swp.ksw_used * pagesize; ++ total = (unsigned long)swp.ksw_total * pagesize; + } -+ kvm_close(k); ++ kvm_close(k); + } +#endif - swap_val = (int)((((float)used) / total) * 100.0); ++ swap_val = 100. * used / total; ++ printf ("swap_val: %d\n", swap_val); /*printf ("Swap: %lu %lu %d%%\n", total, used, swap_val); */ -@@ -273,6 +307,7 @@ + +@@ -273,6 +308,7 @@ { int prio; @@ -111,7 +114,7 @@ /* check for Kernel 2.6 */ FILE *fp; -@@ -295,6 +330,7 @@ +@@ -295,6 +331,7 @@ fclose(fp); /* end check for Kernel 2.6 */ |