/dev for Linux binaries in freebsd

Mario Lobo lobo at bsd.com.br
Sat Sep 26 21:03:44 UTC 2015


On Sat, 26 Sep 2015 13:44:33 +0200
Alexander Leidinger <Alexander at leidinger.net> wrote:

> 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.

Thanks for the tips, Alexander.

I`ll see what I can find out.

-- 
Mario Lobo
http://www.mallavoodoo.com.br
FreeBSD since 2.2.8 [not Pro-Audio.... YET!!]
 
"UNIX was not designed to stop you from doing stupid things, 
because that would also stop you from doing clever things."


More information about the freebsd-emulation mailing list