From owner-freebsd-questions@FreeBSD.ORG Sat Jul 3 02:28:41 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 630D116A4CE for ; Sat, 3 Jul 2004 02:28:41 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1202043D53 for ; Sat, 3 Jul 2004 02:28:41 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i632SaMF059825; Fri, 2 Jul 2004 21:28:36 -0500 (CDT) (envelope-from dan) Date: Fri, 2 Jul 2004 21:28:36 -0500 From: Dan Nelson To: gomalley@mthoodcards.com Message-ID: <20040703022836.GH6574@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-questions@freebsd.org Subject: Re: Getting swap info without kvm access X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jul 2004 02:28:41 -0000 In the last episode (Jul 02), gomalley@mthoodcards.com said: > I've written an Afterstep applet that retrieves and displays > different time and system information. The Linux port uses a few > functions like gmtime() and gethostname() and reads most of the info > from /proc files. The FreeBSD port used the function calls and gets > most of the info from sysctl() calls, except for the swap space. As > written now, that info is retrieved with kvm_getswapinfo(). The > problem is that that function requires access to /dev/mem which isn't > available without sgid privileges. The current work-around is to > display 0 for swap space if the applet is running un-privileged. > > I've searched and browsed the mailing lists, I've poured over the > .h's, .c's, sysctl -a and man pages for weeks but I'm stumped. Is > there some way to get total and either free or used swap space > without using /dev/mem? If not, why is that one piece of info not > available through a sysctl() call? It is in 5.x. The kvm_getswapinfo() function reads the vm.swap_info sysctl when getting status on a live system. You'll just have to install the applet setgid kmem to get swap info on 4.x. -- Dan Nelson dnelson@allantgroup.com