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

[readdir] convert hfs

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

Al Viro 002f8bec f0f49ef5

+23 -26
+23 -26
fs/hfs/dir.c
··· 51 51 /* 52 52 * hfs_readdir 53 53 */ 54 - static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 54 + static int hfs_readdir(struct file *file, struct dir_context *ctx) 55 55 { 56 - struct inode *inode = file_inode(filp); 56 + struct inode *inode = file_inode(file); 57 57 struct super_block *sb = inode->i_sb; 58 58 int len, err; 59 59 char strbuf[HFS_MAX_NAMELEN]; ··· 62 62 struct hfs_readdir_data *rd; 63 63 u16 type; 64 64 65 - if (filp->f_pos >= inode->i_size) 65 + if (ctx->pos >= inode->i_size) 66 66 return 0; 67 67 68 68 err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd); ··· 73 73 if (err) 74 74 goto out; 75 75 76 - switch ((u32)filp->f_pos) { 77 - case 0: 76 + if (ctx->pos == 0) { 78 77 /* This is completely artificial... */ 79 - if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR)) 78 + if (!dir_emit_dot(file, ctx)) 80 79 goto out; 81 - filp->f_pos++; 82 - /* fall through */ 83 - case 1: 80 + ctx->pos = 1; 81 + } 82 + if (ctx->pos == 1) { 84 83 if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { 85 84 err = -EIO; 86 85 goto out; ··· 96 97 // err = -EIO; 97 98 // goto out; 98 99 //} 99 - if (filldir(dirent, "..", 2, 1, 100 + if (!dir_emit(ctx, "..", 2, 100 101 be32_to_cpu(entry.thread.ParID), DT_DIR)) 101 102 goto out; 102 - filp->f_pos++; 103 - /* fall through */ 104 - default: 105 - if (filp->f_pos >= inode->i_size) 106 - goto out; 107 - err = hfs_brec_goto(&fd, filp->f_pos - 1); 108 - if (err) 109 - goto out; 103 + ctx->pos = 2; 110 104 } 105 + if (ctx->pos >= inode->i_size) 106 + goto out; 107 + err = hfs_brec_goto(&fd, ctx->pos - 1); 108 + if (err) 109 + goto out; 111 110 112 111 for (;;) { 113 112 if (be32_to_cpu(fd.key->cat.ParID) != inode->i_ino) { ··· 128 131 err = -EIO; 129 132 goto out; 130 133 } 131 - if (filldir(dirent, strbuf, len, filp->f_pos, 134 + if (!dir_emit(ctx, strbuf, len, 132 135 be32_to_cpu(entry.dir.DirID), DT_DIR)) 133 136 break; 134 137 } else if (type == HFS_CDR_FIL) { ··· 137 140 err = -EIO; 138 141 goto out; 139 142 } 140 - if (filldir(dirent, strbuf, len, filp->f_pos, 143 + if (!dir_emit(ctx, strbuf, len, 141 144 be32_to_cpu(entry.file.FlNum), DT_REG)) 142 145 break; 143 146 } else { ··· 145 148 err = -EIO; 146 149 goto out; 147 150 } 148 - filp->f_pos++; 149 - if (filp->f_pos >= inode->i_size) 151 + ctx->pos++; 152 + if (ctx->pos >= inode->i_size) 150 153 goto out; 151 154 err = hfs_brec_goto(&fd, 1); 152 155 if (err) 153 156 goto out; 154 157 } 155 - rd = filp->private_data; 158 + rd = file->private_data; 156 159 if (!rd) { 157 160 rd = kmalloc(sizeof(struct hfs_readdir_data), GFP_KERNEL); 158 161 if (!rd) { 159 162 err = -ENOMEM; 160 163 goto out; 161 164 } 162 - filp->private_data = rd; 163 - rd->file = filp; 165 + file->private_data = rd; 166 + rd->file = file; 164 167 list_add(&rd->list, &HFS_I(inode)->open_dir_list); 165 168 } 166 169 memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key)); ··· 303 306 304 307 const struct file_operations hfs_dir_operations = { 305 308 .read = generic_read_dir, 306 - .readdir = hfs_readdir, 309 + .iterate = hfs_readdir, 307 310 .llseek = generic_file_llseek, 308 311 .release = hfs_dir_release, 309 312 };