On 06/05/2014 07:47 PM, Mike Frysinger wrote: > The current script isn't terribly friendly -- you basically get one chance > to run it per boot w/out manually recovering the system state. > > It also doesn't lend itself to being made into an init script w/out a lot > of manual editing. > > Rewrite the sucker with proper functions so that people can easily run it > and integrate into their system, and make it easier for CPU maintainers > to add new targets. > > There's also a few fixes smattered about, but considering the whole file > has been written from scratch, not sure they need splitting out. > > Signed-off-by: Mike Frysinger <[email protected]> > --- > scripts/qemu-binfmt-conf.sh | 306 > ++++++++++++++++++++++++++++++++++---------- > 1 file changed, 240 insertions(+), 66 deletions(-) > mode change 100644 => 100755 scripts/qemu-binfmt-conf.sh
> +++ b/scripts/qemu-binfmt-conf.sh
> @@ -1,72 +1,246 @@
> #!/bin/sh
No copyright or license notice?
> +
> +usage() {
> + local ret="${1:-0}"
'local' is a bashism, not compatible with /bin/sh of dash on Debian
based systems.
> +
> +# Usage: has <needle> <list of haystack items>
> +# See if <needle> can be found in <haystack>.
> +has() {
> + local needle="$1"
and again (I'll quit pointing it out)
> +# Make sure the binfmt_misc filesystem is ready for us to use.
> +BINFMT_MISC="/proc/sys/fs/binfmt_misc"
> +binfmt_init() {
> + if ${dryrun}; then
> + return 0
> + fi
> + if [ ! -d ${BINFMT_MISC} ]; then
Underquoted. Just because $BINFMT_MISC currently happens to not need
quoting based on the definition 5 lines above shouldn't give you the
excuse to get lazy.
> + modprobe binfmt_misc
> + fi
> + if [ ! -f ${BINFMT_MISC}/register ]; then
Underquoted.
> + mount binfmt_misc -t binfmt_misc ${BINFMT_MISC}
Underquoted.
> +# Register the specified magic.
> +register() {
> + local fmt="$1"
> + local arch="$2"
> + local path="$(find_qemu "${arch}")"
> + local magic=":${arch}:${fmt}:${path}:"
> +
> + unregister "$@"
> +
> + if [ -z "${path}" ]; then
> + echo "${arch}: Could not locate a qemu binary"
> + else
> + decho "${arch}: would register using ${path}"
> + decho "${arch}: echo '${magic}' > ${BINFMT_MISC}/register"
> + if ! ${dryrun}; then
> + if ! echo "${magic}" > ${BINFMT_MISC}/register; then
Underquoted.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
