Facilitating Jails with only linux binaries

Found on SVNews , SVNews r364366 ( service kindly provided by olli@ ).
Code:
linux: add sysctl compat.linux.use_emul_path

This is a step towards facilitating jails with only Linux binaries.
Supporting emul_path adds path lookups which are completely spurious
if the binary at hand runs in a Linux-based root directory.

Origin:

Does someone know more details about it?
 
Normally, when executing Linux binaries with FreeBSD’s compatibility layer, path lookups are handled specially. First, the kernel prepends the value of emul_path (its default is /compat/linux) and performs the lookup. If it fails, the original path is taken as-is (i.e. without emul_path).

That feature is very useful. For example, it enables you to mount a special Linux version of procfs on /compat/linux/proc. Linux binaries who try to access, say, /proc/cpuinfo will automatically be redirected to /compat/linux/proc/cpuinfo. Another example, when a Linux binary starts a shell as /bin/sh, it will be rewritten as /compat/linux/bin/sh (which is actually bash). It also makes locating libray files for Linux binaries easier, and a lot of other things.

However, when you have a pure Linux jail, all of that is not necessary. Inside the jail (i.e. relative to the jail’s root directory), /proc is already linprocfs, and /bin/sh is already the Linux binary of bash. The additional lookups are a waste of kernel time, and also they fill the kernel’s name cache. Therefore, the commit that you quoted above implements a new sysctl that can be used to disable those lookups. In other words, when that sysctl is switched off (default is on), the emul_path is ignored, and no special handling of path names for Linux binaries occurs.
 
I'm sorry, I couldn't answer earlier. Thank you olli@ for the detailed explanation. It's hard to find such in depth explanation about base development for layman's, your effort is much appreciated.
 
Back
Top