/dev for Linux binaries in freebsd

Alexander Leidinger Alexander at leidinger.net
Sat Sep 26 11:50:42 UTC 2015


Quoting Mario Lobo <lobo at bsd.com.br> (from Thu, 24 Sep 2015 19:54:43 -0300):

> I was trying to find out where a linux binary will look for the /dev
> directory.
>
> I tried to link the device I need to /compat/linux/dev but that didn't
> work.

This is expected. Do not create links to the real /dev there, you will  
create a loop (see below).

> How can a linux binary see the devices (serial ports, usb, etc) of the
> system?

The behavior under the assumption that you haven't chrooted into  
/compat/linux is:

A linux program will ask the kernel for /dev/xyz.
The kernel knows that it is a linux program, and as such it will first  
look for /compat/linux/dev/xyz.
If the kernel doesn't find the device there, it will look for /dev/xyz.

As such you should not touch /compat/linux/dev at all, it will  
"fall-through" to the real /dev.

Maybe your real problem is not that you can't access the right /dev/  
entry, but that the devide doesn't understand what the linux program  
wants to do.

You can use ktrace or dtrace to check what the program tries to do.  
You should see in the output what the real patch is it tries to reach  
and what kind or errno it get's when it tries to access it.


If you chroot into /compat/linux, you need to mount devfs in  
additionally to /compat/linux/dev.

Bye,
Alexander.
-- 
http://www.Leidinger.net Alexander at Leidinger.net: PGP 0xC773696B3BAC17DC
http://www.FreeBSD.org    netchild at FreeBSD.org  : PGP 0xC773696B3BAC17DC


More information about the freebsd-emulation mailing list