From patchwork Mon Nov 13 18:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Mudrunka X-Patchwork-Id: 744410 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20AE0C4332F for ; Mon, 13 Nov 2023 18:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjKMSaJ (ORCPT ); Mon, 13 Nov 2023 13:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjKMSaJ (ORCPT ); Mon, 13 Nov 2023 13:30:09 -0500 X-Greylist: delayed 361 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 13 Nov 2023 10:30:05 PST Received: from harvie.cz (harvie.cz [77.87.242.242]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 130A410EC; Mon, 13 Nov 2023 10:30:05 -0800 (PST) Received: from anemophobia.amit.cz (unknown [31.30.84.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by harvie.cz (Postfix) with ESMTPSA id 2FA2B1802A6; Mon, 13 Nov 2023 19:24:02 +0100 (CET) From: Tomas Mudrunka Cc: tomas.mudrunka@gmail.com, Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] /proc/sysrq-trigger: accept multiple keys at once Date: Mon, 13 Nov 2023 19:22:19 +0100 Message-ID: <20231113182227.698989-1-tomas.mudrunka@gmail.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Just for convenience. This way we can do: `echo reisub > /proc/sysrq-trigger` Instead of: `for i in r e i s u b; do echo "$i" > /proc/sysrq-trigger; done;` Signed-off-by: Tomas Mudrunka --- drivers/tty/sysrq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 6b4a28bcf..bc5a679f6 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -1154,10 +1154,12 @@ EXPORT_SYMBOL(unregister_sysrq_key); static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - if (count) { + size_t i; + + for (i = 0; i < count; i++) { char c; - if (get_user(c, buf)) + if (get_user(c, buf+i)) return -EFAULT; __handle_sysrq(c, false); }