Date: Wed, 25 Jan 2006 08:34:56 -0800 From: Brooks Davis <brooks@one-eyed-alien.net> To: freebsd-ports@freebsd.org Subject: Re: porting an app that checks /proc/meminfo Message-ID: <20060125163456.GC2848@odin.ac.hmc.edu> In-Reply-To: <20060125160613.GA34407@pentarou.parodius.com> References: <20060124172317.GF72149@iib.unsam.edu.ar> <43D66A69.4010005@gmail.com> <20060125020259.GB5928@odin.ac.hmc.edu> <20060125130228.GA79842@iib.unsam.edu.ar> <20060125160613.GA34407@pentarou.parodius.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--yVhtmJPUSI46BTXb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [Please don't top post on freebsd lists.] On Wed, Jan 25, 2006 at 08:06:13AM -0800, Jeremy Chadwick wrote: > I believe the calls he's referring to are the kvm*(3) calls and the > sysctl*(3) calls. Here's a list: >=20 > kvm(3) - kernel memory interface > kvm_geterr(3) - get error message on kvm descriptor > kvm_getfiles(3) - survey open files > kvm_getloadavg(3) - get load average of the system > kvm_getprocs(3), kvm_getargv(3), kvm_getenvv(3) - access user process sta= te > kvm_getswapinfo(3) - return swap summary statistics for the system > kvm_nlist(3) - retrieve symbol table names from a kernel image > kvm_open(3), kvm_openfiles(3), kvm_close(3) - initialize kernel virtual m= emory access > kvm_read(3), kvm_write(3) - read or write kernel virtual memory > sysctl(3), sysctlbyname(3), sysctlnametomib(3) - get or set system inform= ation I was refering to sysctl. A few of the kvm calls are usable as wrappers to sysctl calls, but I don't really think that's a good idea unless you need to support core dumps in your utility. > Secondly, yes, these are "BSD" specific. I believe these will work > on NetBSD, OpenBSD, and FreeBSD (4, 5, 6, and 7); however, some of > the BSDs handle the kvm*(3) differently (some need to be linked with > libkvm, others do not). > > Thirdly, no, there is no standardised way to get VM/system information > from different operating systems. Linux nuts use /proc, BSD folk use > the above, Solaris folk use whatever Solaris has (I honestly forget > but probably some subset of kvm), and so on and so forth. That's basicly correct. -- Brooks > --=20 > | Jeremy Chadwick jdc at parodius.com | > | Parodius Networking http://www.parodius.com/ | > | UNIX Systems Administrator Mountain View, CA, USA | > | Making life hard for others since 1977. | >=20 > On Wed, Jan 25, 2006 at 10:02:28AM -0300, Fernan Aguero wrote: > > +----[ Brooks Davis <brooks@one-eyed-alien.net> (24.Jan.2006 23:06): > > | > > | On Tue, Jan 24, 2006 at 03:56:57PM -0200, Rainer Alves wrote: > > | > Fernan Aguero wrote: > > | > >The program builds fine, but because it uses /proc/meminfo > > | > >to check for available memory, when you run it, it will > > | > >complain about the lack of /proc/meminfo and won't let you > > | > >do anything.=20 > > | > > > > | > ... > > | > >How does one gets the values of i) memory used by the > > | > >program/process and ii) amount of RAM available in the > > | > >computer without using /proc/meminfo in FreeBSD?=20 > > | >=20 > > | > Take a loot at sysutils/muse, which uses /dev/mem to gather this in= fo: > > |=20 > > | Please don't do this. Really! There's no point in gratuitously > > | groveling around in the kernel's live memory image to get data you ha= ve > > | access to via unprivileged calls. > > | > > +----] > >=20 > > Brooks, > >=20 > > what are these unprivileged calls? can you list a few so we > > can check the corresponding man pages? Are they BSD > > specific? > >=20 > > Again I'm not versed in C so what follows is just what I > > could grasp from a few google searches. > >=20 > > It seems like in linux you can also use unprivileged calls > > to get this info, but you have also the option of using the > > /proc filesystem. I don't know what are these unprivileged > > calls like in linux ... but perhaps they are pretty standard > > across systems? > >=20 > > I'm not positive about this but I just have the impression > > that there should be a generic (not linux-specific or BSD > > specific) way to get this info, like a generic call that has > > the same name and similar arguments across different OS (of > > course the internal implementation should be different in > > each OS) ... does such thing exist? > >=20 > > Fernan > > _______________________________________________ > > freebsd-ports@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-ports > > To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org" > _______________________________________________ > freebsd-ports@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ports > To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org" --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --yVhtmJPUSI46BTXb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFD16ivXY6L6fI4GtQRAuX4AJ9GeTmx0fKzUibqGKTBzk7WlSEObgCdGkEv 6twvsY+E9VJigJ5IkYSmO74= =4+z9 -----END PGP SIGNATURE----- --yVhtmJPUSI46BTXb--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060125163456.GC2848>