aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/dir.c
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2016-10-29 18:46:34 +0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:34:22 +0200
commit998151782c3f7e9f09e5b5a4fcb3bd3bb4cb2464 (patch)
tree68461312a0667b89f2b6e373801971831122f8b0 /fs/f2fs/dir.c
parentb3244e069470597a99be362af7e8b91f8ada4938 (diff)
f2fs: report error of f2fs_fill_dentries
Report error of f2fs_fill_dentries to ->iterate_shared, otherwise when error ocurrs, user may just list part of dirents in target directory without any hints. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Conflicts: fs/f2fs/dir.c fs/f2fs/f2fs.h fs/f2fs/inline.c
Diffstat (limited to 'fs/f2fs/dir.c')
-rw-r--r--fs/f2fs/dir.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 8e2fa018c..ee6c99794 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -786,7 +786,7 @@ bool f2fs_empty_dir(struct inode *dir)
return true;
}
-bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir,
+int f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir,
struct f2fs_dentry_ptr *d, unsigned int n, unsigned int bit_pos,
struct fscrypt_str *fstr)
{
@@ -822,7 +822,7 @@ bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir,
(u32)de->hash_code, 0,
&de_name, fstr);
if (err)
- return true;
+ return err;
de_name = *fstr;
fstr->len = save_len;
@@ -833,12 +833,12 @@ bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir,
le32_to_cpu(de->ino), d_type);
if (over) {
file->f_pos += bit_pos - start_bit_pos;
- return true;
+ return 1;
}
bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
}
- return false;
+ return 0;
}
static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
@@ -882,18 +882,21 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
dentry_page = get_lock_data_page(inode, n, false);
if (IS_ERR(dentry_page)) {
err = PTR_ERR(dentry_page);
- if (err == -ENOENT)
+ if (err == -ENOENT) {
+ err = 0;
continue;
- else
+ } else {
goto out;
+ }
}
dentry_blk = kmap(dentry_page);
make_dentry_ptr(inode, &d, (void *)dentry_blk, 1);
- if (f2fs_fill_dentries(file, dirent, filldir, &d, n,
- bit_pos, &fstr)) {
+ err = f2fs_fill_dentries(file, dirent, filldir, &d, n,
+ bit_pos, &fstr);
+ if (err) {
kunmap(dentry_page);
f2fs_put_page(dentry_page, 1);
break;
@@ -904,10 +907,9 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
kunmap(dentry_page);
f2fs_put_page(dentry_page, 1);
}
- err = 0;
out:
fscrypt_fname_free_buffer(&fstr);
- return err;
+ return err < 0 ? err : 0;
}
static int f2fs_dir_open(struct inode *inode, struct file *filp)