blob: 39dfc9e2ea6206b9e907fcb74d573d290f4d1a89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
bypass unimplemented _SC_PHYS_PAGES system configuration API in uclibc
Upstream-Status: Inappropriate [uclibc-specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Index: git/src/shared/util.c
===================================================================
--- git.orig/src/shared/util.c 2014-03-15 18:09:34.796358146 -0700
+++ git/src/shared/util.c 2014-03-15 20:16:33.836501084 -0700
@@ -6332,11 +6332,24 @@
/* We return this as uint64_t in case we are running as 32bit
* process on a 64bit kernel with huge amounts of memory */
-
+#ifdef __UCLIBC__
+ char line[128];
+ FILE *f = fopen("/proc/meminfo", "r");
+ if (f == NULL)
+ return 0;
+ while (!feof(f) && fgets(line, sizeof(line)-1, f)) {
+ if (sscanf(line, "MemTotal: %l kB", &mem) == 1) {
+ mem *= 1024;
+ break;
+ }
+ }
+ fclose(f);
+ return (uint64_t) mem;
+#else
mem = sysconf(_SC_PHYS_PAGES);
assert(mem > 0);
-
return (uint64_t) mem * (uint64_t) page_size();
+#endif
}
char* mount_test_option(const char *haystack, const char *needle) {
|