Skip to content

Instantly share code, notes, and snippets.

@enukane
Created August 4, 2012 08:14
Show Gist options
  • Save enukane/3255835 to your computer and use it in GitHub Desktop.
Save enukane/3255835 to your computer and use it in GitHub Desktop.
netbsd ovs 1.4.2
diff --git vswitchd/system-stats.c vswitchd/system-stats.c
index a3b4db4..68391ea 100644
--- vswitchd/system-stats.c
+++ vswitchd/system-stats.c
@@ -29,6 +29,8 @@
#include <sys/statvfs.h>
#endif
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "daemon.h"
#include "dirs.h"
@@ -89,12 +91,24 @@ get_page_size(void)
return cached;
}
+static int
+has_proc_meminfo()
+{
+ struct stat st;
+
+ return stat("/proc/meminfo", &st) == 0 ? 1 : 0;
+}
+
static void
get_memory_stats(struct shash *stats)
{
- if (!LINUX) {
+ if (!LINUX && !has_proc_meminfo()) {
unsigned int pagesize = get_page_size();
+#ifdef _SC_PHYS_PAGES
long int phys_pages = sysconf(_SC_PHYS_PAGES);
+#else
+ long int phys_pages = 0;
+#endif
#ifdef _SC_AVPHYS_PAGES
long int avphys_pages = sysconf(_SC_AVPHYS_PAGES);
#else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment