Commit a457ac28 authored by Al Viro's avatar Al Viro

hypfs: switch to read_iter/write_iter

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent db671a8e
...@@ -144,36 +144,32 @@ static int hypfs_open(struct inode *inode, struct file *filp) ...@@ -144,36 +144,32 @@ static int hypfs_open(struct inode *inode, struct file *filp)
return nonseekable_open(inode, filp); return nonseekable_open(inode, filp);
} }
static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov, static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
unsigned long nr_segs, loff_t offset)
{ {
char *data; struct file *file = iocb->ki_filp;
ssize_t ret; char *data = file->private_data;
struct file *filp = iocb->ki_filp; size_t available = strlen(data);
/* XXX: temporary */ loff_t pos = iocb->ki_pos;
char __user *buf = iov[0].iov_base; size_t count;
size_t count = iov[0].iov_len;
if (nr_segs != 1)
return -EINVAL;
data = filp->private_data;
ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data));
if (ret <= 0)
return ret;
iocb->ki_pos += ret; if (pos < 0)
file_accessed(filp); return -EINVAL;
if (pos >= available || !iov_iter_count(to))
return ret; return 0;
count = copy_to_iter(data + pos, available - pos, to);
if (!count)
return -EFAULT;
iocb->ki_pos = pos + count;
file_accessed(file);
return count;
} }
static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t offset) static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
{ {
int rc; int rc;
struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; struct super_block *sb = file_inode(iocb->ki_filp)->i_sb;
struct hypfs_sb_info *fs_info = sb->s_fs_info; struct hypfs_sb_info *fs_info = sb->s_fs_info;
size_t count = iov_length(iov, nr_segs); size_t count = iov_iter_count(from);
/* /*
* Currently we only allow one update per second for two reasons: * Currently we only allow one update per second for two reasons:
...@@ -202,6 +198,7 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -202,6 +198,7 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
} }
hypfs_update_update(sb); hypfs_update_update(sb);
rc = count; rc = count;
iov_iter_advance(from, count);
out: out:
mutex_unlock(&fs_info->lock); mutex_unlock(&fs_info->lock);
return rc; return rc;
...@@ -440,10 +437,10 @@ struct dentry *hypfs_create_str(struct dentry *dir, ...@@ -440,10 +437,10 @@ struct dentry *hypfs_create_str(struct dentry *dir,
static const struct file_operations hypfs_file_ops = { static const struct file_operations hypfs_file_ops = {
.open = hypfs_open, .open = hypfs_open,
.release = hypfs_release, .release = hypfs_release,
.read = do_sync_read, .read = new_sync_read,
.write = do_sync_write, .write = new_sync_write,
.aio_read = hypfs_aio_read, .read_iter = hypfs_read_iter,
.aio_write = hypfs_aio_write, .write_iter = hypfs_write_iter,
.llseek = no_llseek, .llseek = no_llseek,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment