@@ -31,7 +31,7 @@ MODULE_LICENSE("GPL");
3131/* The units the vfs expects inode->i_blocks to be in */
3232#define VFS_BLOCK_SIZE 512
3333
34- static int befs_readdir (struct file * , void * , filldir_t );
34+ static int befs_readdir (struct file * , struct dir_context * );
3535static int befs_get_block (struct inode * , sector_t , struct buffer_head * , int );
3636static int befs_readpage (struct file * file , struct page * page );
3737static sector_t befs_bmap (struct address_space * mapping , sector_t block );
@@ -66,7 +66,7 @@ static struct kmem_cache *befs_inode_cachep;
6666
6767static const struct file_operations befs_dir_operations = {
6868 .read = generic_read_dir ,
69- .readdir = befs_readdir ,
69+ .iterate = befs_readdir ,
7070 .llseek = generic_file_llseek ,
7171};
7272
@@ -211,25 +211,24 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
211211}
212212
213213static int
214- befs_readdir (struct file * filp , void * dirent , filldir_t filldir )
214+ befs_readdir (struct file * file , struct dir_context * ctx )
215215{
216- struct inode * inode = file_inode (filp );
216+ struct inode * inode = file_inode (file );
217217 struct super_block * sb = inode -> i_sb ;
218218 befs_data_stream * ds = & BEFS_I (inode )-> i_data .ds ;
219219 befs_off_t value ;
220220 int result ;
221221 size_t keysize ;
222222 unsigned char d_type ;
223223 char keybuf [BEFS_NAME_LEN + 1 ];
224- char * nlsname ;
225- int nlsnamelen ;
226- const char * dirname = filp -> f_path .dentry -> d_name .name ;
224+ const char * dirname = file -> f_path .dentry -> d_name .name ;
227225
228226 befs_debug (sb , "---> befs_readdir() "
229- "name %s, inode %ld, filp->f_pos %Ld" ,
230- dirname , inode -> i_ino , filp -> f_pos );
227+ "name %s, inode %ld, ctx->pos %Ld" ,
228+ dirname , inode -> i_ino , ctx -> pos );
231229
232- result = befs_btree_read (sb , ds , filp -> f_pos , BEFS_NAME_LEN + 1 ,
230+ more :
231+ result = befs_btree_read (sb , ds , ctx -> pos , BEFS_NAME_LEN + 1 ,
233232 keybuf , & keysize , & value );
234233
235234 if (result == BEFS_ERR ) {
@@ -251,24 +250,29 @@ befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
251250
252251 /* Convert to NLS */
253252 if (BEFS_SB (sb )-> nls ) {
253+ char * nlsname ;
254+ int nlsnamelen ;
254255 result =
255256 befs_utf2nls (sb , keybuf , keysize , & nlsname , & nlsnamelen );
256257 if (result < 0 ) {
257258 befs_debug (sb , "<--- befs_readdir() ERROR" );
258259 return result ;
259260 }
260- result = filldir (dirent , nlsname , nlsnamelen , filp -> f_pos ,
261- (ino_t ) value , d_type );
261+ if (!dir_emit (ctx , nlsname , nlsnamelen ,
262+ (ino_t ) value , d_type )) {
263+ kfree (nlsname );
264+ return 0 ;
265+ }
262266 kfree (nlsname );
263-
264267 } else {
265- result = filldir (dirent , keybuf , keysize , filp -> f_pos ,
266- (ino_t ) value , d_type );
268+ if (!dir_emit (ctx , keybuf , keysize ,
269+ (ino_t ) value , d_type ))
270+ return 0 ;
267271 }
268- if (! result )
269- filp -> f_pos ++ ;
272+ ctx -> pos ++ ;
273+ goto more ;
270274
271- befs_debug (sb , "<--- befs_readdir() filp->f_pos %Ld" , filp -> f_pos );
275+ befs_debug (sb , "<--- befs_readdir() pos %Ld" , ctx -> pos );
272276
273277 return 0 ;
274278}
0 commit comments