2002-06-13 22:14:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
2019-10-02 11:40:40 +00:00
|
|
|
# PROVIDE: linux
|
2021-04-12 14:38:16 +01:00
|
|
|
# REQUIRE: kldxref
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
2019-10-02 11:40:40 +00:00
|
|
|
name="linux"
|
|
|
|
desc="Enable Linux ABI"
|
2019-10-03 16:38:44 +00:00
|
|
|
rcvar="linux_enable"
|
2006-12-20 11:37:15 +00:00
|
|
|
start_cmd="${name}_start"
|
|
|
|
stop_cmd=":"
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
linux_start()
|
|
|
|
{
|
2019-11-07 18:15:24 +00:00
|
|
|
local _emul_path _tmpdir
|
2006-12-30 22:53:20 +00:00
|
|
|
|
2016-03-08 19:08:55 +00:00
|
|
|
case `sysctl -n hw.machine_arch` in
|
2021-03-16 16:48:13 +00:00
|
|
|
aarch64)
|
|
|
|
load_kld -e 'linux64elf' linux64
|
|
|
|
;;
|
2016-03-08 19:08:55 +00:00
|
|
|
amd64)
|
2021-03-16 16:48:13 +00:00
|
|
|
load_kld -e 'linuxelf' linux
|
2019-04-10 07:51:13 +00:00
|
|
|
load_kld -e 'linux64elf' linux64
|
2016-03-08 19:08:55 +00:00
|
|
|
;;
|
2021-03-16 16:48:13 +00:00
|
|
|
i386)
|
|
|
|
load_kld -e 'linuxelf' linux
|
|
|
|
;;
|
2016-03-08 19:08:55 +00:00
|
|
|
esac
|
2021-02-08 21:52:31 +00:00
|
|
|
|
|
|
|
_emul_path="$(sysctl -n compat.linux.emul_path)"
|
|
|
|
|
2021-02-02 14:40:38 +00:00
|
|
|
if [ -x ${_emul_path}/sbin/ldconfigDisabled ]; then
|
2006-01-11 21:30:41 +00:00
|
|
|
_tmpdir=`mktemp -d -t linux-ldconfig`
|
2021-02-02 14:40:38 +00:00
|
|
|
${_emul_path}/sbin/ldconfig -C ${_tmpdir}/ld.so.cache
|
|
|
|
if ! cmp -s ${_tmpdir}/ld.so.cache ${_emul_path}/etc/ld.so.cache; then
|
|
|
|
cat ${_tmpdir}/ld.so.cache > ${_emul_path}/etc/ld.so.cache
|
2006-01-11 21:30:41 +00:00
|
|
|
fi
|
|
|
|
rm -rf ${_tmpdir}
|
2002-06-13 22:14:37 +00:00
|
|
|
fi
|
2019-11-07 18:15:24 +00:00
|
|
|
|
|
|
|
# Linux uses the pre-pts(4) tty naming scheme.
|
|
|
|
load_kld pty
|
|
|
|
|
2021-04-21 12:54:29 +01:00
|
|
|
# Explicitly load the filesystem modules; they are usually required,
|
|
|
|
# even with linux_mounts_enable="NO".
|
|
|
|
load_kld fdescfs
|
|
|
|
load_kld linprocfs
|
|
|
|
load_kld linsysfs
|
|
|
|
|
2019-11-07 18:15:24 +00:00
|
|
|
# Handle unbranded ELF executables by defaulting to ELFOSABI_LINUX.
|
|
|
|
if [ `sysctl -ni kern.elf64.fallback_brand` -eq "-1" ]; then
|
|
|
|
sysctl kern.elf64.fallback_brand=3 > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ `sysctl -ni kern.elf32.fallback_brand` -eq "-1" ]; then
|
|
|
|
sysctl kern.elf32.fallback_brand=3 > /dev/null
|
|
|
|
fi
|
|
|
|
|
2019-11-13 20:27:38 +00:00
|
|
|
if checkyesno linux_mounts_enable; then
|
|
|
|
mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
|
|
|
|
mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
|
|
|
|
mount -o nocover -t devfs devfs "${_emul_path}/dev"
|
2020-07-04 18:01:29 +00:00
|
|
|
mount -o nocover,linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd"
|
2019-11-13 20:27:38 +00:00
|
|
|
mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
|
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|