proc_get_binpath() returns a FreeBSD host path. For a Linux process
whose text lives under the emulator root, linprocfs filled the exe
symlink with e.g. /compat/linux/usr/bin/foo. That is not the
executable's name in the Linux namespace: the Linux ABI resolves
absolute paths from compat.linux.emul_path, so following the symlink
looked up /compat/linux/compat/linux/usr/bin/foo and failed with
ENOENT, and readlink consumers that compare or derive paths from the
result saw a host configuration detail that Linux never exposes.
Strip the emul_path prefix when present so /proc/<pid>/exe names the
executable in the Linux namespace (readlink, stat, execve), matching
Linux. With this fix the common case -- Linux binaries installed
under the emulator root -- works on a default Linuxulator setup, with
no mounts beyond those made by rc.d/linux.
Text outside the emulator root (e.g. Linux binaries that ports
install under ${PREFIX}, such as www/linux-brave) already reports the
correct host path; following it relies on namei restarting the lookup
in the native namespace and therefore requires procfs(5) mounted at
/proc. That is a configuration and documentation matter, not
addressed here.
PR: 297426
MFC after: 2 weeks