linprocfs question. Porting app from linux to freebsd

Alexander Leidinger Alexander at Leidinger.net
Sat Jan 5 03:27:12 PST 2008


Quoting "Fernando Apesteguía" <fernando.apesteguia at gmail.com> (Fri, 4 Jan 2008 13:47:50 +0100):

> Hi all,
> 
> I was suggested to contact the linux compatibility team (or Roman
> Divacky) to get some help.
> 
> I want to port an application from Linux to FreeBSD. The linux app.
> makes extensive use of the procfs. Now, I have several options to port
> the software:
> 
> 1 - Use sysctl. The problem here is that some information (about cpu
> or memory, for instance) is not available through this interface.

I suggest to do as much as possible with sysctl. For the CPU you get
maybe more info from /var/run/dmesg.boot. Apart from that I can only
repeat what you got already: use the CPUID call directly, or depend
upon a port which gives you this information (execute the program from
ports and parse the output).

Regarding the memory: there are ways to obtain this info, as already
suggested, have a look at the ganglia port, or have a look how top gets
all the memory info. As you was already told, not every memory type in
Linux maps to a corresponding FreeBSD value. So maybe printing a 'N/A'
or '-' instead of a value may be a sensible solution.

> 2 - Write a kernel module to get an uniform access (Ivan Vorak
> suggested me this)

I don't think users want to install a kernel module just to get a GUI
program which is able to display some values. At least I would not be
interested in something like this.

> 3 - Use linprocfs.
> 
> The easiest to me is the third point. All the access would be very
> similar. However, there are some missing files in the linprocfs. I

It would be a good start to tell us which files are missing and also
provide a description what it is and what example output looks like. We
want to improve linprocfs for sure. Patches which implement some
missing stuff are even more welcome.

> would like to know if there are some plans of keeping adding more
> linux-like files as the devices, filesystems or modules files you can
> get under /proc in a linux system or I should look for another
> alternative (like the module Ivan suggests.)

Requiring to mount a FS or to load a kernel module is not very
userfriendly if there are ways to obtain the info in a different way.
FreeBSD is not going to have procfs or linprocfs mounted by default,
and we discourage the use of procfs if not really necessary. For this
reason you should really try to do as much as possible with sysctl and
similar methods as suggested above.

Bye,
Alexander.

-- 
BOFH excuse #102:

Power company testing new voltage spike (creation) equipment
http://www.Leidinger.net  Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org     netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-emulation mailing list