From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faNjG-0005K0-Q4 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 12:00:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faNjD-00063j-KL for qemu-devel@nongnu.org; Tue, 03 Jul 2018 12:00:34 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1faNjD-00061H-3m for qemu-devel@nongnu.org; Tue, 03 Jul 2018 12:00:31 -0400 Received: by mail-wm0-x22d.google.com with SMTP id 69-v6so2844285wmf.3 for ; Tue, 03 Jul 2018 09:00:30 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Tue, 3 Jul 2018 17:00:22 +0100 Message-Id: <20180703160022.10705-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Riku Voipio , Laurent Vivier Currently running the script twice will fail with "sh: echo: I/O error" as the registration is already complete. Add a new option --clear to reset the entries to save the user doing it by hand. Signed-off-by: Alex Bennée --- scripts/qemu-binfmt-conf.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index d7eefda0b8..13ef4713e6 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -160,7 +160,7 @@ qemu_get_family() { usage() { cat < /proc/sys/fs/binfmt_misc/register } +qemu_clear_interpreter() { + if [ -e /proc/sys/fs/binfmt_misc/qemu-$cpu ]; then + echo "Removing qemu-$cpu as binfmt interpreter for $cpu" + echo -1 > /proc/sys/fs/binfmt_misc/qemu-$cpu + fi +} + qemu_generate_systemd() { echo "Setting $qemu as binfmt interpreter for $cpu for systemd-binfmt.service" qemu_generate_register > "$EXPORTDIR/qemu-$cpu.conf" @@ -302,7 +310,7 @@ DEBIANDIR="/usr/share/binfmts" QEMU_PATH=/usr/local/bin FLAGS="" -options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,credential: -- "$@") +options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,clear,credential: -- "$@") eval set -- "$options" while true ; do @@ -354,6 +362,10 @@ while true ; do FLAGS="" fi ;; + --clear) + shift + BINFMT_SET=qemu_clear_interpreter + ;; *) break ;; -- 2.17.1