diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-10-08 14:07:52 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-10-08 14:07:52 +0000 |
commit | 135c6a1dcce75df70ff3266cf3d66dd68b39a258 (patch) | |
tree | 4101c6c4f3b6bf809e30ddc037a45b11e592ca43 /main/libvirt/uclibc-physmem.patch | |
parent | b04ab376e0a1393534f5d23dadf99a1fb8bb56ce (diff) | |
download | aports-135c6a1dcce75df70ff3266cf3d66dd68b39a258.tar.bz2 aports-135c6a1dcce75df70ff3266cf3d66dd68b39a258.tar.xz |
main/libvirt: fix available memory reporting
fixes #1401
Diffstat (limited to 'main/libvirt/uclibc-physmem.patch')
-rw-r--r-- | main/libvirt/uclibc-physmem.patch | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/libvirt/uclibc-physmem.patch b/main/libvirt/uclibc-physmem.patch new file mode 100644 index 0000000000..73de5ac4ec --- /dev/null +++ b/main/libvirt/uclibc-physmem.patch @@ -0,0 +1,33 @@ +--- ./gnulib/lib/physmem.c.orig ++++ ./gnulib/lib/physmem.c +@@ -23,6 +23,7 @@ + #include "physmem.h" + + #include <unistd.h> ++#include <stdio.h> + + #if HAVE_SYS_PSTAT_H + # include <sys/pstat.h> +@@ -81,6 +82,22 @@ + double + physmem_total (void) + { ++#if defined(__UCLIBC__) ++ char line[128]; ++ FILE *f = fopen("/proc/meminfo", "r"); ++ long double result = -1; ++ if (f == NULL) ++ return 0; ++ while (!feof(f) && fgets(line, sizeof(line)-1, f)) { ++ if (sscanf(line, "MemTotal: %Lf kB", &result) == 1) { ++ result *= 1024; ++ break; ++ } ++ } ++ fclose(f); ++ return result; ++#endif ++ + #if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE + { /* This works on linux-gnu, solaris2 and cygwin. */ + double pages = sysconf (_SC_PHYS_PAGES); |