Re: Getting system info from the kernel

Alexander Viro (viro@math.psu.edu)
Mon, 15 Nov 1999 20:30:28 -0500 (EST)


On 15 Nov 1999, Doug Alcorn wrote:

> "Jeff Buckey" <jbuckey@earthlink.net> writes:
>
> > I'm very sorry to post this question here but I can't seem to find this info
> > anywhere else. I would like to know if there are (I presume there will be)
> > any system calls in the Linux kernel to access information on the memory of
> > the current system, such as amount of memory used, free, used swap, free
> > swap...etc. Much like can be achieved by reading the /proc/meminfo
> > file.
>
> I am a newbie to the linux-kernel mailing list; however, I don't think
> that system calls to the kernel for status info will be developed.
> The point of /proc is to provide user space access to this information
> without having to make syscalls to the kernel.

The point of /proc is to avoid direct poking into the kernel memory.
Moreover, in its current form it is highly non-portable. And that includes
portability between 2.0/2.2/2.4. Please, _stop_ abusing it. Basically,
_nobody_ promises that any given file in /proc will remain there in 2.4.
Most likely 2.4 will keep compatibility symlinks, but even that is not
guaranteed. If k3wl krapplications will break - too bad for them.
The thing is in flux right now. Some things will become sysctls,
some will move into more reasonable places and some will simply die. The
only documented parts are /proc/<pid>/*, /proc/self and /proc/sys. FWIC
the rest is fair game.

> > Also what are the thoughts of people on this list as to using /proc/meminfo
> > for this kind of task? I've been seeing some negative posts in other
> > mailing lists as to using proc at all, although I think it's quite a nice
> > feature.
>
> Granted there is some "overhead" in creating the filehandles, but I
> think /proc is the preferred way to go.

For some things - yes. But the main overhead here is the horrible
mess in namespace (and kernel-side interfaces, but that's another story).
Again, it _will_ change. Use at your own risk and don't come complaining
if changes will break your code. You have been warned.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/