X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fswap.c;h=8d8f7525d1d3ced55c6ff1b8539043ab29223f72;hb=924bfe28d5be1058ccf50931d77639212fb28346;hp=1621f7af677a2a83ee866ee752cece72fcea3c60;hpb=c1318b06b424523d3704fcdfd16d3adb25d17d18;p=collectd.git diff --git a/src/swap.c b/src/swap.c index 1621f7af..8d8f7525 100644 --- a/src/swap.c +++ b/src/swap.c @@ -160,6 +160,8 @@ static int swap_init (void) /* {{{ */ /* #endif defined(VM_SWAPUSAGE) */ #elif HAVE_LIBKVM_GETSWAPINFO + char errbuf[_POSIX2_LINE_MAX]; + 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_openfiles failed, %s", errbuf); return (-1); } /* #endif HAVE_LIBKVM_GETSWAPINFO */ @@ -535,10 +534,10 @@ static int swap_read (void) /* {{{ */ return (0); /* Allocate and initialize the swaptbl_t structure */ - s = (swaptbl_t *) smalloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable)); + s = malloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable)); if (s == NULL) { - ERROR ("swap plugin: smalloc failed."); + ERROR ("swap plugin: malloc failed."); return (-1); } @@ -548,7 +547,7 @@ static int swap_read (void) /* {{{ */ s_paths = calloc (swap_num, PATH_MAX); if (s_paths == NULL) { - ERROR ("swap plugin: malloc failed."); + ERROR ("swap plugin: calloc failed."); sfree (s); return (-1); }