From c994db58a2e5857b13b8a2b26db2c91e2ac5a596 Mon Sep 17 00:00:00 2001 From: chmh0624 Date: Sun, 27 Jul 2025 12:36:56 +0800 Subject: [PATCH] Clarify write usage in comment for /dev/chardev The original comment referred to /dev/hello, but the actual device created by the module is /dev/chardev. In addition, writing to /dev/chardev using output redirection (>) typically fails due to insufficient permissions, since redirection is handled by the shell before sudo applies. As a result, the device_write() function may never be entered. This change updates the comment to recommend using a pipe with `sudo tee`, which correctly elevates privileges and allows the write operation to reach the driver. --- examples/chardev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chardev.c b/examples/chardev.c index 3b2d67c9..b64305a4 100644 --- a/examples/chardev.c +++ b/examples/chardev.c @@ -152,7 +152,7 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */ return bytes_read; } -/* Called when a process writes to dev file: echo "hi" > /dev/hello */ +/* Called when a process writes to dev file: echo "hi" | sudo tee /dev/chardev */ static ssize_t device_write(struct file *filp, const char __user *buff, size_t len, loff_t *off) {