Commit f0f49ef5 authored by Al Viro's avatar Al Viro

[readdir] convert befs

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent be4ccdcc
...@@ -31,7 +31,7 @@ MODULE_LICENSE("GPL"); ...@@ -31,7 +31,7 @@ MODULE_LICENSE("GPL");
/* The units the vfs expects inode->i_blocks to be in */ /* The units the vfs expects inode->i_blocks to be in */
#define VFS_BLOCK_SIZE 512 #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_get_block(struct inode *, sector_t, struct buffer_head *, int);
static int befs_readpage(struct file *file, struct page *page); static int befs_readpage(struct file *file, struct page *page);
static sector_t befs_bmap(struct address_space *mapping, sector_t block); static sector_t befs_bmap(struct address_space *mapping, sector_t block);
...@@ -66,7 +66,7 @@ static struct kmem_cache *befs_inode_cachep; ...@@ -66,7 +66,7 @@ static struct kmem_cache *befs_inode_cachep;
static const struct file_operations befs_dir_operations = { static const struct file_operations befs_dir_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.readdir = befs_readdir, .iterate = befs_readdir,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
}; };
...@@ -211,9 +211,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) ...@@ -211,9 +211,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
} }
static int 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; struct super_block *sb = inode->i_sb;
befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
befs_off_t value; befs_off_t value;
...@@ -221,15 +221,14 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -221,15 +221,14 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
size_t keysize; size_t keysize;
unsigned char d_type; unsigned char d_type;
char keybuf[BEFS_NAME_LEN + 1]; char keybuf[BEFS_NAME_LEN + 1];
char *nlsname; const char *dirname = file->f_path.dentry->d_name.name;
int nlsnamelen;
const char *dirname = filp->f_path.dentry->d_name.name;
befs_debug(sb, "---> befs_readdir() " befs_debug(sb, "---> befs_readdir() "
"name %s, inode %ld, filp->f_pos %Ld", "name %s, inode %ld, ctx->pos %Ld",
dirname, inode->i_ino, filp->f_pos); 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); keybuf, &keysize, &value);
if (result == BEFS_ERR) { if (result == BEFS_ERR) {
...@@ -251,24 +250,29 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -251,24 +250,29 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* Convert to NLS */ /* Convert to NLS */
if (BEFS_SB(sb)->nls) { if (BEFS_SB(sb)->nls) {
char *nlsname;
int nlsnamelen;
result = result =
befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen);
if (result < 0) { if (result < 0) {
befs_debug(sb, "<--- befs_readdir() ERROR"); befs_debug(sb, "<--- befs_readdir() ERROR");
return result; return result;
} }
result = filldir(dirent, nlsname, nlsnamelen, filp->f_pos, if (!dir_emit(ctx, nlsname, nlsnamelen,
(ino_t) value, d_type); (ino_t) value, d_type)) {
kfree(nlsname);
return 0;
}
kfree(nlsname); kfree(nlsname);
} else { } else {
result = filldir(dirent, keybuf, keysize, filp->f_pos, if (!dir_emit(ctx, keybuf, keysize,
(ino_t) value, d_type); (ino_t) value, d_type))
return 0;
} }
if (!result) ctx->pos++;
filp->f_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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment