kmsg_write returns with printk, so some programs may be confused by
a successful write() with a return value different than the buffer length.
# /bin/echo something > /dev/kmsg
/bin/echo: write error: Inappropriate ioctl for device
The drawbacks is that the printk return value can no more be quickly checked
from userspace.
Signed-off-by: Guillaume Chazarain <[email protected]>
---
mem.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
--
Guillaume
diff -r d18e06f9c571 drivers/char/mem.c
--- a/drivers/char/mem.c Mon Nov 14 10:22:49 2005 +0800
+++ b/drivers/char/mem.c Mon Nov 14 15:03:06 2005 +0100
@@ -817,7 +817,7 @@
size_t count, loff_t *ppos)
{
char *tmp;
- int ret;
+ ssize_t ret;
tmp = kmalloc(count + 1, GFP_KERNEL);
if (tmp == NULL)
@@ -826,6 +826,9 @@
if (!copy_from_user(tmp, buf, count)) {
tmp[count] = 0;
ret = printk("%s", tmp);
+ if (ret > count)
+ /* printk can add a prefix */
+ ret = count;
}
kfree(tmp);
return ret;
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]