diff mbox series

/proc/sysrq-trigger: accept multiple keys at once

Message ID 20231113182227.698989-1-tomas.mudrunka@gmail.com
State New
Headers show
Series /proc/sysrq-trigger: accept multiple keys at once | expand

Commit Message

Tomas Mudrunka Nov. 13, 2023, 6:22 p.m. UTC
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 <tomas.mudrunka@gmail.com>
---
 drivers/tty/sysrq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

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);
 	}