2002-06-13 18:14:37 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
#
|
|
|
|
|
|
2019-10-02 07:40:40 -04:00
|
|
|
# PROVIDE: linux
|
2021-09-20 01:25:23 -04:00
|
|
|
# REQUIRE: kldxref zfs
|
2004-10-07 09:55:26 -04:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 18:14:37 -04:00
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
2019-10-02 07:40:40 -04:00
|
|
|
name="linux"
|
|
|
|
|
desc="Enable Linux ABI"
|
2019-10-03 12:38:44 -04:00
|
|
|
rcvar="linux_enable"
|
2006-12-20 06:37:15 -05:00
|
|
|
start_cmd="${name}_start"
|
|
|
|
|
stop_cmd=":"
|
2002-06-13 18:14:37 -04:00
|
|
|
|
2021-10-12 04:40:36 -04:00
|
|
|
linux_mount() {
|
|
|
|
|
local _fs _mount_point
|
|
|
|
|
_fs="$1"
|
|
|
|
|
_mount_point="$2"
|
|
|
|
|
shift 2
|
|
|
|
|
if ! mount | grep -q "^$_fs on $_mount_point ("; then
|
|
|
|
|
mkdir -p "$_mount_point"
|
|
|
|
|
mount "$@" -t "$_fs" "$_fs" "$_mount_point"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-13 18:14:37 -04:00
|
|
|
linux_start()
|
|
|
|
|
{
|
2019-11-07 13:15:24 -05:00
|
|
|
local _emul_path _tmpdir
|
2006-12-30 17:53:20 -05:00
|
|
|
|
2016-03-08 14:08:55 -05:00
|
|
|
case `sysctl -n hw.machine_arch` in
|
2021-03-16 12:48:13 -04:00
|
|
|
aarch64)
|
|
|
|
|
load_kld -e 'linux64elf' linux64
|
|
|
|
|
;;
|
2016-03-08 14:08:55 -05:00
|
|
|
amd64)
|
2021-03-16 12:48:13 -04:00
|
|
|
load_kld -e 'linuxelf' linux
|
2019-04-10 03:51:13 -04:00
|
|
|
load_kld -e 'linux64elf' linux64
|
2016-03-08 14:08:55 -05:00
|
|
|
;;
|
2021-03-16 12:48:13 -04:00
|
|
|
i386)
|
|
|
|
|
load_kld -e 'linuxelf' linux
|
|
|
|
|
;;
|
2016-03-08 14:08:55 -05:00
|
|
|
esac
|
2021-02-08 16:52:31 -05:00
|
|
|
|
|
|
|
|
_emul_path="$(sysctl -n compat.linux.emul_path)"
|
|
|
|
|
|
2021-02-02 09:40:38 -05:00
|
|
|
if [ -x ${_emul_path}/sbin/ldconfigDisabled ]; then
|
2006-01-11 16:30:41 -05:00
|
|
|
_tmpdir=`mktemp -d -t linux-ldconfig`
|
2021-02-02 09:40:38 -05: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 16:30:41 -05:00
|
|
|
fi
|
|
|
|
|
rm -rf ${_tmpdir}
|
2002-06-13 18:14:37 -04:00
|
|
|
fi
|
2019-11-07 13:15:24 -05:00
|
|
|
|
|
|
|
|
# Linux uses the pre-pts(4) tty naming scheme.
|
|
|
|
|
load_kld pty
|
|
|
|
|
|
2021-04-21 07:54:29 -04: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 13:15:24 -05: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
|
|
|
|
|
|
2021-10-12 04:40:36 -04:00
|
|
|
if checkyesno linux_mounts_enable; then
|
|
|
|
|
linux_mount linprocfs "${_emul_path}/proc" -o nocover
|
|
|
|
|
linux_mount linsysfs "${_emul_path}/sys" -o nocover
|
|
|
|
|
linux_mount devfs "${_emul_path}/dev" -o nocover
|
|
|
|
|
linux_mount fdescfs "${_emul_path}/dev/fd" -o nocover,linrdlnk
|
|
|
|
|
linux_mount tmpfs "${_emul_path}/dev/shm" -o nocover,mode=1777
|
2019-11-13 15:27:38 -05:00
|
|
|
fi
|
2002-06-13 18:14:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
|
run_rc_command "$1"
|