M7350v3_en_gpl
This commit is contained in:
@ -822,6 +822,44 @@ static const struct file_operations oldmem_fops = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
|
||||
unsigned long count, loff_t pos)
|
||||
{
|
||||
char *line, *p;
|
||||
int i;
|
||||
ssize_t ret = -EFAULT;
|
||||
size_t len = iov_length(iv, count);
|
||||
|
||||
line = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (line == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
/*
|
||||
* copy all vectors into a single string, to ensure we do
|
||||
* not interleave our log line with other printk calls
|
||||
*/
|
||||
p = line;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
|
||||
goto out;
|
||||
p += iv[i].iov_len;
|
||||
}
|
||||
p[0] = '\0';
|
||||
|
||||
ret = printk("%s", line);
|
||||
/* printk can add a prefix */
|
||||
if (ret > len)
|
||||
ret = len;
|
||||
out:
|
||||
kfree(line);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct file_operations kmsg_fops = {
|
||||
.aio_write = kmsg_writev,
|
||||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
static const struct memdev {
|
||||
const char *name;
|
||||
umode_t mode;
|
||||
@ -842,9 +880,7 @@ static const struct memdev {
|
||||
[7] = { "full", 0666, &full_fops, NULL },
|
||||
[8] = { "random", 0666, &random_fops, NULL },
|
||||
[9] = { "urandom", 0666, &urandom_fops, NULL },
|
||||
#ifdef CONFIG_PRINTK
|
||||
[11] = { "kmsg", 0644, &kmsg_fops, NULL },
|
||||
#endif
|
||||
[11] = { "kmsg", 0, &kmsg_fops, NULL },
|
||||
#ifdef CONFIG_CRASH_DUMP
|
||||
[12] = { "oldmem", 0, &oldmem_fops, NULL },
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user