| From foo@baz Mon Nov 18 17:17:51 PST 2013 |
| Date: Mon, 18 Nov 2013 17:17:51 -0800 |
| To: Greg KH <gregkh@linuxfoundation.org> |
| From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Subject: staging: exfat: readdir to iterate change |
| |
| readdir has gone away from the vfs functions, moving to iterate to fix a |
| number of issues. Port the exfat driver to this api. |
| |
| This port was based on commit 2c6a2473b800f8eadc94c9a711fee8671dd1a244 |
| ([readdir] convert fatfs). I think it is correct, but others should |
| verify I didn't mess anything up. |
| |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/staging/exfat/exfat_super.c | 24 ++++++++++++------------ |
| 1 file changed, 12 insertions(+), 12 deletions(-) |
| |
| --- a/drivers/staging/exfat/exfat_super.c |
| +++ b/drivers/staging/exfat/exfat_super.c |
| @@ -274,9 +274,9 @@ static void __set_sb_clean(struct super_ |
| #endif |
| } |
| |
| -static int exfat_readdir(struct file *filp, void *dirent, filldir_t filldir) |
| +static int exfat_iterate(struct file *file, struct dir_context *ctx) |
| { |
| - struct inode *inode = filp->f_path.dentry->d_inode; |
| + struct inode *inode = file_inode(file); |
| struct super_block *sb = inode->i_sb; |
| struct exfat_sb_info *sbi = EXFAT_SB(sb); |
| FS_INFO_T *p_fs = &(sbi->fs_info); |
| @@ -288,7 +288,7 @@ static int exfat_readdir(struct file *fi |
| |
| __lock_super(sb); |
| |
| - cpos = filp->f_pos; |
| + cpos = ctx->pos; |
| if ((p_fs->vol_type == EXFAT) || (inode->i_ino == EXFAT_ROOT_INO)) { |
| while (cpos < 2) { |
| if (inode->i_ino == EXFAT_ROOT_INO) |
| @@ -296,12 +296,12 @@ static int exfat_readdir(struct file *fi |
| else if (cpos == 0) |
| inum = inode->i_ino; |
| else |
| - inum = parent_ino(filp->f_path.dentry); |
| + inum = parent_ino(file->f_path.dentry); |
| |
| - if (filldir(dirent, "..", cpos+1, cpos, inum, DT_DIR) < 0) |
| + if (!dir_emit_dots(file, ctx)) |
| goto out; |
| cpos++; |
| - filp->f_pos++; |
| + ctx->pos++; |
| } |
| if (cpos == 2) { |
| cpos = 0; |
| @@ -335,7 +335,7 @@ get_new: |
| if (!memcmp(de.ShortName, DOS_CUR_DIR_NAME, DOS_NAME_LENGTH)) { |
| inum = inode->i_ino; |
| } else if (!memcmp(de.ShortName, DOS_PAR_DIR_NAME, DOS_NAME_LENGTH)) { |
| - inum = parent_ino(filp->f_path.dentry); |
| + inum = parent_ino(file->f_path.dentry); |
| } else { |
| loff_t i_pos = ((loff_t) EXFAT_I(inode)->fid.start_clu << 32) | |
| ((EXFAT_I(inode)->fid.rwoffset-1) & 0xffffffff); |
| @@ -349,15 +349,15 @@ get_new: |
| } |
| } |
| |
| - if (filldir(dirent, de.Name, strlen(de.Name), cpos-1, inum, |
| - (de.Attr & ATTR_SUBDIR) ? DT_DIR : DT_REG) < 0) |
| + if (!dir_emit(ctx, de.Name, strlen(de.Name), inum, |
| + (de.Attr & ATTR_SUBDIR) ? DT_DIR : DT_REG)) |
| goto out; |
| |
| - filp->f_pos = cpos; |
| + ctx->pos = cpos; |
| goto get_new; |
| |
| end_of_dir: |
| - filp->f_pos = cpos; |
| + ctx->pos = cpos; |
| out: |
| __unlock_super(sb); |
| return err; |
| @@ -437,7 +437,7 @@ static int exfat_file_fsync(struct file |
| const struct file_operations exfat_dir_operations = { |
| .llseek = generic_file_llseek, |
| .read = generic_read_dir, |
| - .readdir = exfat_readdir, |
| + .iterate = exfat_iterate, |
| #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) |
| .ioctl = exfat_generic_ioctl, |
| .fsync = exfat_file_fsync, |