Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[readdir] convert befs

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro f0f49ef5 be4ccdcc

+22 -18
+22 -18
fs/befs/linuxvfs.c
··· 31 31 /* The units the vfs expects inode->i_blocks to be in */ 32 32 #define VFS_BLOCK_SIZE 512 33 33 34 - static int befs_readdir(struct file *, void *, filldir_t); 34 + static int befs_readdir(struct file *, struct dir_context *); 35 35 static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int); 36 36 static int befs_readpage(struct file *file, struct page *page); 37 37 static sector_t befs_bmap(struct address_space *mapping, sector_t block); ··· 66 66 67 67 static const struct file_operations befs_dir_operations = { 68 68 .read = generic_read_dir, 69 - .readdir = befs_readdir, 69 + .iterate = befs_readdir, 70 70 .llseek = generic_file_llseek, 71 71 }; 72 72 ··· 211 211 } 212 212 213 213 static int 214 - befs_readdir(struct file *filp, void *dirent, filldir_t filldir) 214 + befs_readdir(struct file *file, struct dir_context *ctx) 215 215 { 216 - struct inode *inode = file_inode(filp); 216 + struct inode *inode = file_inode(file); 217 217 struct super_block *sb = inode->i_sb; 218 218 befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; 219 219 befs_off_t value; ··· 221 221 size_t keysize; 222 222 unsigned char d_type; 223 223 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; 227 225 228 226 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); 231 229 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, 233 232 keybuf, &keysize, &value); 234 233 235 234 if (result == BEFS_ERR) { ··· 250 251 251 252 /* Convert to NLS */ 252 253 if (BEFS_SB(sb)->nls) { 254 + char *nlsname; 255 + int nlsnamelen; 253 256 result = 254 257 befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); 255 258 if (result < 0) { 256 259 befs_debug(sb, "<--- befs_readdir() ERROR"); 257 260 return result; 258 261 } 259 - result = filldir(dirent, nlsname, nlsnamelen, filp->f_pos, 260 - (ino_t) value, d_type); 262 + if (!dir_emit(ctx, nlsname, nlsnamelen, 263 + (ino_t) value, d_type)) { 264 + kfree(nlsname); 265 + return 0; 266 + } 261 267 kfree(nlsname); 262 - 263 268 } else { 264 - result = filldir(dirent, keybuf, keysize, filp->f_pos, 265 - (ino_t) value, d_type); 269 + if (!dir_emit(ctx, keybuf, keysize, 270 + (ino_t) value, d_type)) 271 + return 0; 266 272 } 267 - if (!result) 268 - filp->f_pos++; 273 + ctx->pos++; 274 + goto more; 269 275 270 - befs_debug(sb, "<--- befs_readdir() filp->f_pos %Ld", filp->f_pos); 276 + befs_debug(sb, "<--- befs_readdir() pos %Ld", ctx->pos); 271 277 272 278 return 0; 273 279 }