]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/linux
Use compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / linux
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: linux
7 # REQUIRE: archdep
8 # KEYWORD: nojail
9
10 . /etc/rc.subr
11
12 name="linux"
13 desc="Enable Linux ABI"
14 rcvar="linux_enable"
15 start_cmd="${name}_start"
16 stop_cmd=":"
17
18 linux_start()
19 {
20         local _emul_path _tmpdir
21         _emul_path="$(sysctl -n compat.linux.emul_path)"
22
23         load_kld -e 'linux(aout|elf)' linux
24         case `sysctl -n hw.machine_arch` in
25         amd64)
26                 load_kld -e 'linux64elf' linux64
27                 ;;
28         esac
29         if [ -x ${_emul_path}/sbin/ldconfigDisabled ]; then
30                 _tmpdir=`mktemp -d -t linux-ldconfig`
31                 ${_emul_path}/sbin/ldconfig -C ${_tmpdir}/ld.so.cache
32                 if ! cmp -s ${_tmpdir}/ld.so.cache ${_emul_path}/etc/ld.so.cache; then
33                         cat ${_tmpdir}/ld.so.cache > ${_emul_path}/etc/ld.so.cache
34                 fi
35                 rm -rf ${_tmpdir}
36         fi
37
38         # Linux uses the pre-pts(4) tty naming scheme.
39         load_kld pty
40
41         # Handle unbranded ELF executables by defaulting to ELFOSABI_LINUX.
42         if [ `sysctl -ni kern.elf64.fallback_brand` -eq "-1" ]; then
43                 sysctl kern.elf64.fallback_brand=3 > /dev/null
44         fi
45
46         if [ `sysctl -ni kern.elf32.fallback_brand` -eq "-1" ]; then
47                 sysctl kern.elf32.fallback_brand=3 > /dev/null
48         fi
49
50         if checkyesno linux_mounts_enable; then 
51                 mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
52                 mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
53                 mount -o nocover -t devfs devfs "${_emul_path}/dev"
54                 mount -o nocover,linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd"
55                 mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
56         fi
57 }
58
59 load_rc_config $name
60 run_rc_command "$1"