diff options
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/hypfs/inode.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 4c8008dd938e..99824ff8dd35 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -74,7 +74,7 @@ static void hypfs_remove(struct dentry *dentry) | |||
74 | parent = dentry->d_parent; | 74 | parent = dentry->d_parent; |
75 | mutex_lock(&parent->d_inode->i_mutex); | 75 | mutex_lock(&parent->d_inode->i_mutex); |
76 | if (hypfs_positive(dentry)) { | 76 | if (hypfs_positive(dentry)) { |
77 | if (S_ISDIR(dentry->d_inode->i_mode)) | 77 | if (d_is_dir(dentry)) |
78 | simple_rmdir(parent->d_inode, dentry); | 78 | simple_rmdir(parent->d_inode, dentry); |
79 | else | 79 | else |
80 | simple_unlink(parent->d_inode, dentry); | 80 | simple_unlink(parent->d_inode, dentry); |
@@ -144,36 +144,32 @@ static int hypfs_open(struct inode *inode, struct file *filp) | |||
144 | return nonseekable_open(inode, filp); | 144 | return nonseekable_open(inode, filp); |
145 | } | 145 | } |
146 | 146 | ||
147 | static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov, | 147 | static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to) |
148 | unsigned long nr_segs, loff_t offset) | ||
149 | { | 148 | { |
150 | char *data; | 149 | struct file *file = iocb->ki_filp; |
151 | ssize_t ret; | 150 | char *data = file->private_data; |
152 | struct file *filp = iocb->ki_filp; | 151 | size_t available = strlen(data); |
153 | /* XXX: temporary */ | 152 | loff_t pos = iocb->ki_pos; |
154 | char __user *buf = iov[0].iov_base; | 153 | size_t count; |
155 | size_t count = iov[0].iov_len; | ||
156 | |||
157 | if (nr_segs != 1) | ||
158 | return -EINVAL; | ||
159 | |||
160 | data = filp->private_data; | ||
161 | ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data)); | ||
162 | if (ret <= 0) | ||
163 | return ret; | ||
164 | 154 | ||
165 | iocb->ki_pos += ret; | 155 | if (pos < 0) |
166 | file_accessed(filp); | 156 | return -EINVAL; |
167 | 157 | if (pos >= available || !iov_iter_count(to)) | |
168 | return ret; | 158 | return 0; |
159 | count = copy_to_iter(data + pos, available - pos, to); | ||
160 | if (!count) | ||
161 | return -EFAULT; | ||
162 | iocb->ki_pos = pos + count; | ||
163 | file_accessed(file); | ||
164 | return count; | ||
169 | } | 165 | } |
170 | static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, | 166 | |
171 | unsigned long nr_segs, loff_t offset) | 167 | static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from) |
172 | { | 168 | { |
173 | int rc; | 169 | int rc; |
174 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; | 170 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; |
175 | struct hypfs_sb_info *fs_info = sb->s_fs_info; | 171 | struct hypfs_sb_info *fs_info = sb->s_fs_info; |
176 | size_t count = iov_length(iov, nr_segs); | 172 | size_t count = iov_iter_count(from); |
177 | 173 | ||
178 | /* | 174 | /* |
179 | * Currently we only allow one update per second for two reasons: | 175 | * 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 | } | 198 | } |
203 | hypfs_update_update(sb); | 199 | hypfs_update_update(sb); |
204 | rc = count; | 200 | rc = count; |
201 | iov_iter_advance(from, count); | ||
205 | out: | 202 | out: |
206 | mutex_unlock(&fs_info->lock); | 203 | mutex_unlock(&fs_info->lock); |
207 | return rc; | 204 | return rc; |
@@ -440,10 +437,10 @@ struct dentry *hypfs_create_str(struct dentry *dir, | |||
440 | static const struct file_operations hypfs_file_ops = { | 437 | static const struct file_operations hypfs_file_ops = { |
441 | .open = hypfs_open, | 438 | .open = hypfs_open, |
442 | .release = hypfs_release, | 439 | .release = hypfs_release, |
443 | .read = do_sync_read, | 440 | .read = new_sync_read, |
444 | .write = do_sync_write, | 441 | .write = new_sync_write, |
445 | .aio_read = hypfs_aio_read, | 442 | .read_iter = hypfs_read_iter, |
446 | .aio_write = hypfs_aio_write, | 443 | .write_iter = hypfs_write_iter, |
447 | .llseek = no_llseek, | 444 | .llseek = no_llseek, |
448 | }; | 445 | }; |
449 | 446 | ||