lkml.org 
[lkml]   [2005]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] kmsg_write: don't return printk return value
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 <guichaz@yahoo.fr>

---
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;
\
 
 \ /
  Last update: 2005-11-15 13:21    [W:2.366 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site