1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: linux 7# REQUIRE: kldxref zfs 8# KEYWORD: nojail 9 10. /etc/rc.subr 11 12name="linux" 13desc="Enable Linux ABI" 14rcvar="linux_enable" 15start_cmd="${name}_start" 16stop_cmd=":" 17 18linux_start() 19{ 20 local _emul_path _tmpdir 21 22 case `sysctl -n hw.machine_arch` in 23 aarch64) 24 load_kld -e 'linux64elf' linux64 25 ;; 26 amd64) 27 load_kld -e 'linuxelf' linux 28 load_kld -e 'linux64elf' linux64 29 ;; 30 i386) 31 load_kld -e 'linuxelf' linux 32 ;; 33 esac 34 35 _emul_path="$(sysctl -n compat.linux.emul_path)" 36 37 if [ -x ${_emul_path}/sbin/ldconfigDisabled ]; then 38 _tmpdir=`mktemp -d -t linux-ldconfig` 39 ${_emul_path}/sbin/ldconfig -C ${_tmpdir}/ld.so.cache 40 if ! cmp -s ${_tmpdir}/ld.so.cache ${_emul_path}/etc/ld.so.cache; then 41 cat ${_tmpdir}/ld.so.cache > ${_emul_path}/etc/ld.so.cache 42 fi 43 rm -rf ${_tmpdir} 44 fi 45 46 # Linux uses the pre-pts(4) tty naming scheme. 47 load_kld pty 48 49 # Explicitly load the filesystem modules; they are usually required, 50 # even with linux_mounts_enable="NO". 51 load_kld fdescfs 52 load_kld linprocfs 53 load_kld linsysfs 54 55 # Handle unbranded ELF executables by defaulting to ELFOSABI_LINUX. 56 if [ `sysctl -ni kern.elf64.fallback_brand` -eq "-1" ]; then 57 sysctl kern.elf64.fallback_brand=3 > /dev/null 58 fi 59 60 if [ `sysctl -ni kern.elf32.fallback_brand` -eq "-1" ]; then 61 sysctl kern.elf32.fallback_brand=3 > /dev/null 62 fi 63 64 if checkyesno linux_mounts_enable; then 65 mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc" 66 mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys" 67 mount -o nocover -t devfs devfs "${_emul_path}/dev" 68 mount -o nocover,linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd" 69 mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm" 70 fi 71} 72 73load_rc_config $name 74run_rc_command "$1" 75