$OpenBSD: patch-lib_src_facts_openbsd_memory_resolver_cc,v 1.5 2016/06/02 20:15:59 jasper Exp $

- From 8ee968b997ab0cd55be4ae071f9d17d6ef0b33a6 Mon Sep 17 00:00:00 2001
  From: Jasper Lievisse Adriaanse <jasper@humppa.nl>
  Date: Mon, 30 May 2016 18:34:50 +0200
  Subject: [PATCH] (MAINT) Unbreak after leatherman split in cc1245ab
- From 27369d5db64f0926da0c4d916ac5c65ad750ed49 Mon Sep 17 00:00:00 2001
  From: Jasper Lievisse Adriaanse <jasper@humppa.nl>
  Date: Tue, 31 May 2016 16:01:53 +0200
  Subject: [PATCH] (FACT-1433) Properly scale swap results

--- lib/src/facts/openbsd/memory_resolver.cc.orig	Fri May 20 18:36:55 2016
+++ lib/src/facts/openbsd/memory_resolver.cc	Tue May 31 15:53:39 2016
@@ -1,5 +1,5 @@
 #include <internal/facts/openbsd/memory_resolver.hpp>
-#include <facter/execution/execution.hpp>
+#include <leatherman/execution/execution.hpp>
 #include <leatherman/logging/logging.hpp>
 #include <sys/types.h>
 #include <sys/param.h>
@@ -9,8 +9,7 @@
 #include <unistd.h>
 
 using namespace std;
-using namespace facter::execution;
-using namespace facter::util;
+using namespace leatherman::execution;
 
 namespace facter { namespace facts { namespace openbsd {
 
@@ -49,12 +48,16 @@ namespace facter { namespace facts { namespace openbsd
         uint64_t swap_used = 0;
         for (auto &&swap : swapdev) {
             if (swap.se_flags & SWF_ENABLE) {
-                result.swap_total += swap.se_nblks * DEV_BSIZE;
-                swap_used += swap.se_inuse * DEV_BSIZE;
+		    result.swap_total += swap.se_nblks / (1024 / DEV_BSIZE);
+		    swap_used += swap.se_inuse / (1024 / DEV_BSIZE);
             }
         }
 
         result.swap_free = result.swap_total - swap_used;
+
+	// Adjust for expected scale
+	result.swap_total *= 1024;
+	result.swap_free *= 1024;
 
         // 0 is for CTL_SWPENC_NAMES' "enable", see uvm_swap_encrypt.h
         int swap_encrypted_mib[] = { CTL_VM, VM_SWAPENCRYPT, 0 };
