]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[readdir] convert befs
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 22 May 2013 17:44:05 +0000 (13:44 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 29 Jun 2013 08:56:55 +0000 (12:56 +0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/befs/linuxvfs.c

index f95dddced968f6f4509f1536b80462baa1c4393b..e9c75e20db32d43b550506f5f8f62b2656f760e7 100644 (file)
@@ -31,7 +31,7 @@ MODULE_LICENSE("GPL");
 /* The units the vfs expects inode->i_blocks to be in */
 #define VFS_BLOCK_SIZE 512
 
-static int befs_readdir(struct file *, void *, filldir_t);
+static int befs_readdir(struct file *, struct dir_context *);
 static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 static int befs_readpage(struct file *file, struct page *page);
 static sector_t befs_bmap(struct address_space *mapping, sector_t block);
@@ -66,7 +66,7 @@ static struct kmem_cache *befs_inode_cachep;
 
 static const struct file_operations befs_dir_operations = {
        .read           = generic_read_dir,
-       .readdir        = befs_readdir,
+       .iterate        = befs_readdir,
        .llseek         = generic_file_llseek,
 };
 
@@ -211,9 +211,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 }
 
 static int
-befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
+befs_readdir(struct file *file, struct dir_context *ctx)
 {
-       struct inode *inode = file_inode(filp);
+       struct inode *inode = file_inode(file);
        struct super_block *sb = inode->i_sb;
        befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
        befs_off_t value;
@@ -221,15 +221,14 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        size_t keysize;
        unsigned char d_type;
        char keybuf[BEFS_NAME_LEN + 1];
-       char *nlsname;
-       int nlsnamelen;
-       const char *dirname = filp->f_path.dentry->d_name.name;
+       const char *dirname = file->f_path.dentry->d_name.name;
 
        befs_debug(sb, "---> befs_readdir() "
-                  "name %s, inode %ld, filp->f_pos %Ld",
-                  dirname, inode->i_ino, filp->f_pos);
+                  "name %s, inode %ld, ctx->pos %Ld",
+                  dirname, inode->i_ino, ctx->pos);
 
-       result = befs_btree_read(sb, ds, filp->f_pos, BEFS_NAME_LEN + 1,
+more:
+       result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
                                 keybuf, &keysize, &value);
 
        if (result == BEFS_ERR) {
@@ -251,24 +250,29 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 
        /* Convert to NLS */
        if (BEFS_SB(sb)->nls) {
+               char *nlsname;
+               int nlsnamelen;
                result =
                    befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen);
                if (result < 0) {
                        befs_debug(sb, "<--- befs_readdir() ERROR");
                        return result;
                }
-               result = filldir(dirent, nlsname, nlsnamelen, filp->f_pos,
-                                (ino_t) value, d_type);
+               if (!dir_emit(ctx, nlsname, nlsnamelen,
+                                (ino_t) value, d_type)) {
+                       kfree(nlsname);
+                       return 0;
+               }
                kfree(nlsname);
-
        } else {
-               result = filldir(dirent, keybuf, keysize, filp->f_pos,
-                                (ino_t) value, d_type);
+               if (!dir_emit(ctx, keybuf, keysize,
+                                (ino_t) value, d_type))
+                       return 0;
        }
-       if (!result)
-               filp->f_pos++;
+       ctx->pos++;
+       goto more;
 
-       befs_debug(sb, "<--- befs_readdir() filp->f_pos %Ld", filp->f_pos);
+       befs_debug(sb, "<--- befs_readdir() pos %Ld", ctx->pos);
 
        return 0;
 }