fixes swap plugin on FreeBSD Jail
authorale@biancalanas.net <ale@biancalanas.net>
Fri, 1 May 2015 16:48:30 +0000 (16:48 +0000)
committerMarc Fournier <marc.fournier@camptocamp.com>
Tue, 5 May 2015 15:41:41 +0000 (17:41 +0200)
src/swap.c

index 1621f7a..b3aa4f7 100644 (file)
@@ -160,6 +160,8 @@ static int swap_init (void) /* {{{ */
 /* #endif defined(VM_SWAPUSAGE) */
 
 #elif HAVE_LIBKVM_GETSWAPINFO
+       char errbuf[1024];
+
        if (kvm_obj != NULL)
        {
                kvm_close (kvm_obj);
@@ -168,14 +170,11 @@ static int swap_init (void) /* {{{ */
 
        kvm_pagesize = getpagesize ();
 
-       if ((kvm_obj = kvm_open (NULL, /* execfile */
-                                       NULL, /* corefile */
-                                       NULL, /* swapfile */
-                                       O_RDONLY, /* flags */
-                                       NULL)) /* errstr */
-                       == NULL)
+       kvm_obj = kvm_openfiles (NULL, "/dev/null", NULL, O_RDONLY, errbuf);
+
+       if (kvm_obj == NULL)
        {
-               ERROR ("swap plugin: kvm_open failed.");
+               ERROR ("swap plugin: kvm_open failed, %s", errbuf);
                return (-1);
        }
 /* #endif HAVE_LIBKVM_GETSWAPINFO */