MFH: r490904 r490905

Fix libstatgrab on FreeBSD 12

On FreeBSD 12 (since r309017) v_cache_count no longer exists. A
compatibility shim is in place if COMPAT_FREEBSD11 is defined in
the kernel, but if not libstatgrab fails to return any memory
statistics. This patch modifies libstatgrab to mimic this compatibility
behaviour (ie. return 0), regardless of whether COMPAT_FREEBSD11
is defined, which ensures the remaining statistics are returned
correctly.

A more complete solution will be considered upstream and hopefully
be included in the next release.

Reported by:	Alexey Milevsky <a.milevsky@gmail.com>
Approved by:	ports-secteam (miwi)
This commit is contained in:
Tim Bishop 2019-01-27 15:25:33 +00:00
parent d47aba596e
commit 2ce6461628
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/branches/2019Q1/; revision=491358
2 changed files with 23 additions and 2 deletions

View File

@ -3,6 +3,7 @@
PORTNAME= libstatgrab
PORTVERSION= 0.91
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://ftp.mirrorservice.org/pub/i-scream/libstatgrab/ \
http://dl.ambiweb.de/mirrors/ftp.i-scream.org/libstatgrab/ \
@ -13,10 +14,10 @@ COMMENT= Provides a useful interface to system statistics
LICENSE= LGPL21
USE_LDCONFIG= yes
GNU_CONFIGURE= yes
USES= pathfix pkgconfig libtool
USE_LDCONFIG= yes
GNU_CONFIGURE= yes
CONFIGURE_ARGS+= --docdir=${DOCSDIR}
OPTIONS_DEFINE= TOOLS DOCS
@ -31,4 +32,10 @@ TOOLS_VARS= SHEBANG_FILES+="src/statgrab/statgrab-make-mrtg-config.in \
OPTIONS_SUB= yes
.include <bsd.port.options.mk>
.if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1200016
EXTRA_PATCHES= ${PATCHDIR}/extra-patch-src_libstatgrab_memory__stats.c
.endif
.include <bsd.port.mk>

View File

@ -0,0 +1,14 @@
--- src/libstatgrab/memory_stats.c.orig 2019-01-21 17:51:57 UTC
+++ src/libstatgrab/memory_stats.c
@@ -323,10 +323,7 @@ sg_get_mem_stats_int(sg_mem_stats *mem_stats_buf) {
RETURN_WITH_SET_ERROR_WITH_ERRNO("mem", SG_ERROR_SYSCTLBYNAME, "vm.stats.vm.v_inactive_count");
}
- size = sizeof(cache_count);
- if (sysctlbyname("vm.stats.vm.v_cache_count", &cache_count, &size, NULL, 0) < 0) {
- RETURN_WITH_SET_ERROR_WITH_ERRNO("mem", SG_ERROR_SYSCTLBYNAME, "vm.stats.vm.v_cache_count");
- }
+ cache_count = 0;
/* Of couse nothing is ever that simple :) And I have inactive pages to
* deal with too. So I'm going to add them to free memory :)