| From | Jens Axboe <> | Subject | [PATCH 120/437] fs/eventfd: convert to read/write iterators | Date | Thu, 11 Apr 2024 09:14:20 -0600 |
| |
Signed-off-by: Jens Axboe <axboe@kernel.dk> --- fs/eventfd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/eventfd.c b/fs/eventfd.c index 9afdb722fa92..6995253a37f3 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -244,16 +244,16 @@ static ssize_t eventfd_read(struct kiocb *iocb, struct iov_iter *to) return sizeof(ucnt); } -static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t count, - loff_t *ppos) +static ssize_t eventfd_write(struct kiocb *iocb, struct iov_iter *from) { - struct eventfd_ctx *ctx = file->private_data; + struct eventfd_ctx *ctx = iocb->ki_filp->private_data; + size_t count = iov_iter_count(from); ssize_t res; __u64 ucnt; if (count != sizeof(ucnt)) return -EINVAL; - if (copy_from_user(&ucnt, buf, sizeof(ucnt))) + if (!copy_from_iter_full(&ucnt, sizeof(ucnt), from)) return -EFAULT; if (ucnt == ULLONG_MAX) return -EINVAL; @@ -261,7 +261,7 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c res = -EAGAIN; if (ULLONG_MAX - ctx->count > ucnt) res = sizeof(ucnt); - else if (!(file->f_flags & O_NONBLOCK)) { + else if (!(iocb->ki_filp->f_flags & O_NONBLOCK)) { res = wait_event_interruptible_locked_irq(ctx->wqh, ULLONG_MAX - ctx->count > ucnt); if (!res) @@ -306,7 +306,7 @@ static const struct file_operations eventfd_fops = { .release = eventfd_release, .poll = eventfd_poll, .read_iter = eventfd_read, - .write = eventfd_write, + .write_iter = eventfd_write, .llseek = noop_llseek, }; -- 2.43.0
|