Messages in this thread Patch in this message | | | Date | Tue, 13 Aug 2002 21:58:13 -0700 | From | Andrew Morton <> | Subject | Re: [patch] printk from userspace |
| |
Benjamin LaHaise wrote: > > ... > Something like the following untested code is much better.
I agree. And it worked first time.
--- 2.5.31/drivers/char/mem.c~bcrl-printk Tue Aug 13 21:53:24 2002 +++ 2.5.31-akpm/drivers/char/mem.c Tue Aug 13 21:53:34 2002 @@ -579,6 +579,24 @@ static struct file_operations full_fops write: write_full, }; +static ssize_t kmsg_write(struct file * file, const char * buf, + size_t count, loff_t *ppos) +{ + char tmp[1025]; + + if (count > 1024) + count = 1024; + if (copy_from_user(tmp, buf, count)) + return -EFAULT; + tmp[count] = 0; + printk("%s", tmp); + return count; +} + +static struct file_operations kmsg_fops = { + write: kmsg_write, +}; + static int memory_open(struct inode * inode, struct file * filp) { switch (minor(inode->i_rdev)) { @@ -608,6 +626,9 @@ static int memory_open(struct inode * in case 9: filp->f_op = &urandom_fops; break; + case 11: + filp->f_op = &kmsg_fops; + break; default: return -ENXIO; } @@ -634,7 +655,8 @@ void __init memory_devfs_register (void) {5, "zero", S_IRUGO | S_IWUGO, &zero_fops}, {7, "full", S_IRUGO | S_IWUGO, &full_fops}, {8, "random", S_IRUGO | S_IWUSR, &random_fops}, - {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops} + {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops}, + {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops}, }; int i; . - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |