4 # Copyright (c) 2005 Josh Parsons <jbparsons@ucdavis.edu>
6 # Portions derived from qemu-binfmt-conf.sh
7 # Copyright (c) 2003 Fabrice Bellard
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 # try to install binfmt_misc
29 if grep -Fq binfmt_misc
/proc
/modules
31 elif [ -x /sbin
/modprobe
]
32 then /sbin
/modprobe binfmt_misc
33 elif [ -x /opt
/sbin
/modprobe
]
34 then /opt
/sbin
/modprobe binfmt_misc
35 elif [ -r /lib
/modules
/`uname -r`/kernel
/fs
/binfmt_misc.o
]
36 then insmod
/lib
/modules
/`uname -r`/kernel
/fs
/binfmt_misc.o
37 else exit 0 # no binfmt_misc module
40 # now look for its controls
45 if [ -d /proc
/sys
/fs
/binfmt_misc
/status
]
46 then BINFMT_MISC_DIR
=/proc
/sys
/fs
/binfmt_misc
47 elif grep -Fq binfmt_misc
/proc
/mounts
48 then parse_mounts
`grep -F binfmt_misc /proc/mounts`
49 elif [ -d /proc
/sys
/fs
/binfmt_misc
]
50 then MOUNT_AT
=/proc
/sys
/fs
/binfmt_misc
51 else mkdir
-p /tmp
/binfmt_misc
; MOUNT_AT
=/tmp
/binfmt_misc
54 # mount binfmt_misc's control interface if we need to
57 mount
-t binfmt_misc nodev
$MOUNT_AT
58 BINFMT_MISC_DIR
=$MOUNT_AT
61 echo "Using binfmt_misc interface fs at $BINFMT_MISC_DIR"
62 echo "Using qemu binaries in $QEMU_BIN_DIR"
67 i386|i486|i586|i686|i86pc|BePC
)
70 "Power Macintosh"|ppc|ppc64
)
78 # register the interpreter for each cpu except for the native one
79 if [ $cpu != "i386" ] ; then
80 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\xfb\xff\xff\xff:$QEMU_BIN_DIR/qemu-i386:" > $BINFMT_MISC_DIR/register
81 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\xfb\xff\xff\xff:$QEMU_BIN_DIR/qemu-i386:" > $BINFMT_MISC_DIR/register
83 if [ $cpu != "arm" ] ; then
84 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\xfb\xff\xff\xff:$QEMU_BIN_DIR/qemu-arm:" > $BINFMT_MISC_DIR/register
85 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\xfb\xff\xff:$QEMU_BIN_DIR/qemu-armeb:" > $BINFMT_MISC_DIR/register
87 if [ $cpu != "sparc" ] ; then
88 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\xfb\xff\xff\xff:$QEMU_BIN_DIR/qemu-sparc:" > $BINFMT_MISC_DIR/register
90 if [ $cpu != "ppc" ] ; then
91 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\xfb\xff\xff\xff:$QEMU_BIN_DIR/qemu-ppc:" > $BINFMT_MISC_DIR/register
94 # umount binfmt_misc's control interface if we mounted it earlier