Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jul 2004 21:28:36 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        gomalley@mthoodcards.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Getting swap info without kvm access
Message-ID:  <20040703022836.GH6574@dan.emsphone.com>
In-Reply-To: <Pine.LNX.4.20.0407021623160.7716-100000@grace.rockwood.loc>
References:  <Pine.LNX.4.20.0407021623160.7716-100000@grace.rockwood.loc>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040703022836.GH6574>