Skip to content

Commit c994db5

Browse files
committed
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.
1 parent 42d1e00 commit c994db5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/chardev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */
152152
return bytes_read;
153153
}
154154

155-
/* Called when a process writes to dev file: echo "hi" > /dev/hello */
155+
/* Called when a process writes to dev file: echo "hi" | sudo tee /dev/chardev */
156156
static ssize_t device_write(struct file *filp, const char __user *buff,
157157
size_t len, loff_t *off)
158158
{

0 commit comments

Comments
 (0)