diff options
Diffstat (limited to 'arch/s390/hypfs/inode.c')
-rw-r--r-- | arch/s390/hypfs/inode.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 4b010ff814c9..7383781f3e6a 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -150,33 +150,24 @@ static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
150 | unsigned long nr_segs, loff_t offset) | 150 | unsigned long nr_segs, loff_t offset) |
151 | { | 151 | { |
152 | char *data; | 152 | char *data; |
153 | size_t len; | 153 | ssize_t ret; |
154 | struct file *filp = iocb->ki_filp; | 154 | struct file *filp = iocb->ki_filp; |
155 | /* XXX: temporary */ | 155 | /* XXX: temporary */ |
156 | char __user *buf = iov[0].iov_base; | 156 | char __user *buf = iov[0].iov_base; |
157 | size_t count = iov[0].iov_len; | 157 | size_t count = iov[0].iov_len; |
158 | 158 | ||
159 | if (nr_segs != 1) { | 159 | if (nr_segs != 1) |
160 | count = -EINVAL; | 160 | return -EINVAL; |
161 | goto out; | ||
162 | } | ||
163 | 161 | ||
164 | data = filp->private_data; | 162 | data = filp->private_data; |
165 | len = strlen(data); | 163 | ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data)); |
166 | if (offset > len) { | 164 | if (ret <= 0) |
167 | count = 0; | 165 | return ret; |
168 | goto out; | 166 | |
169 | } | 167 | iocb->ki_pos += ret; |
170 | if (count > len - offset) | ||
171 | count = len - offset; | ||
172 | if (copy_to_user(buf, data + offset, count)) { | ||
173 | count = -EFAULT; | ||
174 | goto out; | ||
175 | } | ||
176 | iocb->ki_pos += count; | ||
177 | file_accessed(filp); | 168 | file_accessed(filp); |
178 | out: | 169 | |
179 | return count; | 170 | return ret; |
180 | } | 171 | } |
181 | static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, | 172 | static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, |
182 | unsigned long nr_segs, loff_t offset) | 173 | unsigned long nr_segs, loff_t offset) |