Messages in this thread Patch in this message | | | Date | Tue, 15 Nov 2005 13:18:39 +0100 | From | Guillaume Chazarain <> | 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;
| |