Statistics
| Branch: | Revision:

root / qemu-binfmt-conf.sh @ 1e0e6d8b

History | View | Annotate | Download (3 kB)

1
#!/bin/sh
2
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC program execution by the kernel
3

    
4
# load the binfmt_misc module
5
if [ ! -d /proc/sys/fs/binfmt_misc ]; then
6
  /sbin/modprobe binfmt_misc
7
fi
8
if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
9
  mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
10
fi
11

    
12
# probe cpu type
13
cpu=`uname -m`
14
case "$cpu" in
15
  i386|i486|i586|i686|i86pc|BePC)
16
    cpu="i386"
17
  ;;
18
  m68k)
19
    cpu="m68k"
20
  ;;
21
  mips*)
22
    cpu="mips"
23
  ;;
24
  "Power Macintosh"|ppc|ppc64)
25
    cpu="ppc"
26
  ;;
27
  armv4l)
28
    cpu="arm"
29
  ;;
30
esac
31

    
32
# register the interpreter for each cpu except for the native one
33
if [ $cpu != "i386" ] ; then
34
    echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
35
    echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
36
fi
37
if [ $cpu != "arm" ] ; then
38
    echo   ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
39
    echo   ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register
40
fi
41
if [ $cpu != "sparc" ] ; then
42
    echo   ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register
43
fi
44
if [ $cpu != "ppc" ] ; then
45
    echo   ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register
46
fi
47
if [ $cpu != "m68k" ] ; then
48
    echo   'Please check cpu value and header information for m68k!'
49
    echo   ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-m68k:' > /proc/sys/fs/binfmt_misc/register
50
fi
51
if [ $cpu != "mips" ] ; then
52
    # FIXME: We could use the other endianness on a MIPS host.
53
    echo   ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register
54
    echo   ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register
55
fi