From jbeich@tormail.org  Wed Oct 17 01:39:30 2012
Return-Path: <jbeich@tormail.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 094707F2
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Oct 2012 01:39:26 +0000 (UTC)
	(envelope-from jbeich@tormail.org)
Received: from outgoing.tormail.org (outgoing.tormail.org [82.221.96.22])
	by mx1.freebsd.org (Postfix) with ESMTP id 9A5AA8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Oct 2012 01:39:25 +0000 (UTC)
Received: from localhost ([127.0.0.1] helo=internal.tormail.org)
	by outgoing.tormail.org with esmtp (Exim 4.72)
	(envelope-from <jbeich@tormail.org>)
	id 1TOIbO-0006pu-Fw
	for FreeBSD-gnats-submit@freebsd.org; Wed, 17 Oct 2012 05:39:19 +0400
Received: from jbeich by internal.tormail.org with local (Exim 4.63)
	(envelope-from <jbeich@tormail.org>)
	id 1TOIZW-000GhH-HX
	for FreeBSD-gnats-submit@freebsd.org; Wed, 17 Oct 2012 01:37:23 +0000
Message-Id: <1TOIZW-000GhH-HX@internal.tormail.org>
Date: Wed, 17 Oct 2012 05:21:55 +0600
From: Jan Beich <jbeich@tormail.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] sysutils/py-psutil: get_virtual_mem() fails without COMPAT_FREEBSD[4-7]

>Number:         172803
>Category:       ports
>Synopsis:       [patch] sysutils/py-psutil: get_virtual_mem() fails without COMPAT_FREEBSD[4-7]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sunpoet
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 17 01:40:02 UTC 2012
>Closed-Date:    Sat Apr 13 11:49:19 UTC 2013
>Last-Modified:  Sat Apr 13 11:50:00 UTC 2013
>Originator:     Jan Beich
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
$ sysctl -n vfs.bufspace
0

$ lsvfs
Filesystem                        Refs Flags
-------------------------------- ----- ---------------
zfs                                 37 jail, delegated-administration
devfs                                4 synthetic, jail
tmpfs                                5
procfs                               3 synthetic, jail
linprocfs                            4 synthetic
nullfs                              12 loopback, jail
linsysfs                             3 synthetic
>Description:
vfs.bufspace type was changed from `int' to `long' in r189595.

ref. http://svnweb.freebsd.org/changeset/base/189595
     http://svnweb.freebsd.org/changeset/base/189627
     https://code.google.com/p/psutil/issues/detail?id=325
>How-To-Repeat:
>Fix:
--- bufspace_type.diff begins here ---
Index: sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c
===================================================================
--- sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	(revision 305988)
+++ sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	(working copy)
@@ -1,5 +1,35 @@
 --- psutil/_psutil_bsd.c.orig	2012-08-16 23:07:37.000000000 +0800
 +++ psutil/_psutil_bsd.c	2012-09-27 14:50:20.843763756 +0800
+@@ -576,12 +576,19 @@ get_process_memory_info(PyObject* self, 
+ static PyObject*
+ get_virtual_mem(PyObject* self, PyObject* args)
+ {
+-    unsigned int   total, active, inactive, wired, cached, free, buffers;
++    unsigned int   total, active, inactive, wired, cached, free;
+     size_t		   size = sizeof(total);
+ 	struct vmtotal vm;
+ 	int            mib[] = {CTL_VM, VM_METER};
+ 	long           pagesize = getpagesize();
+ 
++#if __FreeBSD_version > 702101
++    long buffers;
++#else
++    int buffers;
++#endif
++    size_t buffers_size = sizeof(buffers);
++
+     if (sysctlbyname("vm.stats.vm.v_page_count", &total, &size, NULL, 0))
+         goto error;
+     if (sysctlbyname("vm.stats.vm.v_active_count", &active, &size, NULL, 0))
+@@ -594,7 +601,7 @@ get_virtual_mem(PyObject* self, PyObject
+         goto error;
+     if (sysctlbyname("vm.stats.vm.v_free_count", &free, &size, NULL, 0))
+         goto error;
+-    if (sysctlbyname("vfs.bufspace", &buffers, &size, NULL, 0))
++    if (sysctlbyname("vfs.bufspace", &buffers, &buffers_size, NULL, 0))
+         goto error;
+ 
+     size = sizeof(vm);
 @@ -1376,8 +1376,10 @@
              strlcat(opts, ",noclusterr", sizeof(opts));
          if (flags & MNT_NOCLUSTERW)
--- bufspace_type.diff ends here ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sunpoet 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Oct 17 01:40:13 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172803 
State-Changed-From-To: open->closed 
State-Changed-By: crees 
State-Changed-When: Sat Apr 13 11:49:18 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172803 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/172803: commit references a PR
Date: Sat, 13 Apr 2013 11:49:09 +0000 (UTC)

 Author: crees
 Date: Sat Apr 13 11:49:01 2013
 New Revision: 315794
 URL: http://svnweb.freebsd.org/changeset/ports/315794
 
 Log:
   Fix on FreeBSD 8+
   
   PR:		ports/172803
   Submitted by:	Jan Beich
   Approved by:	maintainer timeout (sunpoet, ~6 months)
   Approved by:	portmgr (decke)
 
 Modified:
   head/sysutils/py-psutil/Makefile
   head/sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c
 
 Modified: head/sysutils/py-psutil/Makefile
 ==============================================================================
 --- head/sysutils/py-psutil/Makefile	Sat Apr 13 09:41:06 2013	(r315793)
 +++ head/sysutils/py-psutil/Makefile	Sat Apr 13 11:49:01 2013	(r315794)
 @@ -1,12 +1,9 @@
 -# New ports collection makefile for:	py-psutil
 -# Date created:				04 May 2010
 -# Whom:					Ju Pengfei <jupengfei@gmail.com>
 -#
 +# Created by: Ju Pengfei <jupengfei@gmail.com>
  # $FreeBSD$
 -#
  
  PORTNAME=	psutil
  PORTVERSION=	0.6.1
 +PORTREVISION=	1
  CATEGORIES=	sysutils python
  MASTER_SITES=	GOOGLE_CODE
  PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
 
 Modified: head/sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c
 ==============================================================================
 --- head/sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	Sat Apr 13 09:41:06 2013	(r315793)
 +++ head/sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	Sat Apr 13 11:49:01 2013	(r315794)
 @@ -1,5 +1,35 @@
  --- psutil/_psutil_bsd.c.orig	2012-08-16 23:07:37.000000000 +0800
  +++ psutil/_psutil_bsd.c	2012-09-27 14:50:20.843763756 +0800
 +@@ -576,12 +576,19 @@ get_process_memory_info(PyObject* self, 
 + static PyObject*
 + get_virtual_mem(PyObject* self, PyObject* args)
 + {
 +-    unsigned int   total, active, inactive, wired, cached, free, buffers;
 ++    unsigned int   total, active, inactive, wired, cached, free;
 +     size_t		   size = sizeof(total);
 + 	struct vmtotal vm;
 + 	int            mib[] = {CTL_VM, VM_METER};
 + 	long           pagesize = getpagesize();
 + 
 ++#if __FreeBSD_version > 702101
 ++    long buffers;
 ++#else
 ++    int buffers;
 ++#endif
 ++    size_t buffers_size = sizeof(buffers);
 ++
 +     if (sysctlbyname("vm.stats.vm.v_page_count", &total, &size, NULL, 0))
 +         goto error;
 +     if (sysctlbyname("vm.stats.vm.v_active_count", &active, &size, NULL, 0))
 +@@ -594,7 +601,7 @@ get_virtual_mem(PyObject* self, PyObject
 +         goto error;
 +     if (sysctlbyname("vm.stats.vm.v_free_count", &free, &size, NULL, 0))
 +         goto error;
 +-    if (sysctlbyname("vfs.bufspace", &buffers, &size, NULL, 0))
 ++    if (sysctlbyname("vfs.bufspace", &buffers, &buffers_size, NULL, 0))
 +         goto error;
 + 
 +     size = sizeof(vm);
  @@ -1376,8 +1376,10 @@
               strlcat(opts, ",noclusterr", sizeof(opts));
           if (flags & MNT_NOCLUSTERW)
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
 >>> import psutil
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/local/lib/python2.7/site-packages/psutil/__init__.py", line 88, in <module>
     import psutil._psbsd as _psplatform
   File "/usr/local/lib/python2.7/site-packages/psutil/_psbsd.py", line 28, in <module>
     TOTAL_PHYMEM = _psutil_bsd.get_virtual_mem()[0]
 SystemError: error return without exception set
 
 
 >>> import _psutil_bsd
 >>> _psutil_bsd.get_virtual_mem()
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 SystemError: error return without exception set
