diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-23 12:23:53 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-09 02:39:09 -0400 |
commit | 849f3127bb46ef75a66dffc1b9b0d3f5f43fa395 (patch) | |
tree | d06e4f134598bae03340063ce4065a5ac96b457a /kernel | |
parent | cd678fce428018dee0c9345ed63ebf9920d9902f (diff) |
switch /dev/kmsg to ->write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/printk/printk.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 1ce770687ea8..7a6e69441f75 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
@@ -519,14 +519,13 @@ struct devkmsg_user { | |||
519 | char buf[8192]; | 519 | char buf[8192]; |
520 | }; | 520 | }; |
521 | 521 | ||
522 | static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv, | 522 | static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) |
523 | unsigned long count, loff_t pos) | ||
524 | { | 523 | { |
525 | char *buf, *line; | 524 | char *buf, *line; |
526 | int i; | 525 | int i; |
527 | int level = default_message_loglevel; | 526 | int level = default_message_loglevel; |
528 | int facility = 1; /* LOG_USER */ | 527 | int facility = 1; /* LOG_USER */ |
529 | size_t len = iov_length(iv, count); | 528 | size_t len = iocb->ki_nbytes; |
530 | ssize_t ret = len; | 529 | ssize_t ret = len; |
531 | 530 | ||
532 | if (len > LOG_LINE_MAX) | 531 | if (len > LOG_LINE_MAX) |
@@ -535,13 +534,10 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv, | |||
535 | if (buf == NULL) | 534 | if (buf == NULL) |
536 | return -ENOMEM; | 535 | return -ENOMEM; |
537 | 536 | ||
538 | line = buf; | 537 | buf[len] = '\0'; |
539 | for (i = 0; i < count; i++) { | 538 | if (copy_from_iter(buf, len, from) != len) { |
540 | if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) { | 539 | kfree(buf); |
541 | ret = -EFAULT; | 540 | return -EFAULT; |
542 | goto out; | ||
543 | } | ||
544 | line += iv[i].iov_len; | ||
545 | } | 541 | } |
546 | 542 | ||
547 | /* | 543 | /* |
@@ -567,10 +563,8 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv, | |||
567 | line = endp; | 563 | line = endp; |
568 | } | 564 | } |
569 | } | 565 | } |
570 | line[len] = '\0'; | ||
571 | 566 | ||
572 | printk_emit(facility, level, NULL, 0, "%s", line); | 567 | printk_emit(facility, level, NULL, 0, "%s", line); |
573 | out: | ||
574 | kfree(buf); | 568 | kfree(buf); |
575 | return ret; | 569 | return ret; |
576 | } | 570 | } |
@@ -802,7 +796,7 @@ static int devkmsg_release(struct inode *inode, struct file *file) | |||
802 | const struct file_operations kmsg_fops = { | 796 | const struct file_operations kmsg_fops = { |
803 | .open = devkmsg_open, | 797 | .open = devkmsg_open, |
804 | .read = devkmsg_read, | 798 | .read = devkmsg_read, |
805 | .aio_write = devkmsg_writev, | 799 | .write_iter = devkmsg_write, |
806 | .llseek = devkmsg_llseek, | 800 | .llseek = devkmsg_llseek, |
807 | .poll = devkmsg_poll, | 801 | .poll = devkmsg_poll, |
808 | .release = devkmsg_release, | 802 | .release = devkmsg_release, |