aboutsummaryrefslogtreecommitdiffstats
path: root/fs/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/readdir.c')
-rw-r--r--fs/readdir.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/readdir.c b/fs/readdir.c
index 93a7559bbfd8..b318d9b5af2e 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -117,7 +117,7 @@ asmlinkage long old_readdir(unsigned int fd, struct old_linux_dirent __user * di
117 buf.dirent = dirent; 117 buf.dirent = dirent;
118 118
119 error = vfs_readdir(file, fillonedir, &buf); 119 error = vfs_readdir(file, fillonedir, &buf);
120 if (error >= 0) 120 if (buf.result)
121 error = buf.result; 121 error = buf.result;
122 122
123 fput(file); 123 fput(file);
@@ -209,9 +209,8 @@ asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user * diren
209 buf.error = 0; 209 buf.error = 0;
210 210
211 error = vfs_readdir(file, filldir, &buf); 211 error = vfs_readdir(file, filldir, &buf);
212 if (error < 0) 212 if (error >= 0)
213 goto out_putf; 213 error = buf.error;
214 error = buf.error;
215 lastdirent = buf.previous; 214 lastdirent = buf.previous;
216 if (lastdirent) { 215 if (lastdirent) {
217 if (put_user(file->f_pos, &lastdirent->d_off)) 216 if (put_user(file->f_pos, &lastdirent->d_off))
@@ -219,8 +218,6 @@ asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user * diren
219 else 218 else
220 error = count - buf.count; 219 error = count - buf.count;
221 } 220 }
222
223out_putf:
224 fput(file); 221 fput(file);
225out: 222out:
226 return error; 223 return error;
@@ -293,19 +290,16 @@ asmlinkage long sys_getdents64(unsigned int fd, struct linux_dirent64 __user * d
293 buf.error = 0; 290 buf.error = 0;
294 291
295 error = vfs_readdir(file, filldir64, &buf); 292 error = vfs_readdir(file, filldir64, &buf);
296 if (error < 0) 293 if (error >= 0)
297 goto out_putf; 294 error = buf.error;
298 error = buf.error;
299 lastdirent = buf.previous; 295 lastdirent = buf.previous;
300 if (lastdirent) { 296 if (lastdirent) {
301 typeof(lastdirent->d_off) d_off = file->f_pos; 297 typeof(lastdirent->d_off) d_off = file->f_pos;
302 error = -EFAULT;
303 if (__put_user(d_off, &lastdirent->d_off)) 298 if (__put_user(d_off, &lastdirent->d_off))
304 goto out_putf; 299 error = -EFAULT;
305 error = count - buf.count; 300 else
301 error = count - buf.count;
306 } 302 }
307
308out_putf:
309 fput(file); 303 fput(file);
310out: 304out:
311 return error; 305 return error;