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

[readdir] convert jfs

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

Al Viro 070a0ebf 77acfa29

+31 -36
+29 -34
fs/jfs/jfs_dtree.c
··· 3002 3002 * return: offset = (pn, index) of start entry 3003 3003 * of next jfs_readdir()/dtRead() 3004 3004 */ 3005 - int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 3005 + int jfs_readdir(struct file *file, struct dir_context *ctx) 3006 3006 { 3007 - struct inode *ip = file_inode(filp); 3007 + struct inode *ip = file_inode(file); 3008 3008 struct nls_table *codepage = JFS_SBI(ip->i_sb)->nls_tab; 3009 3009 int rc = 0; 3010 3010 loff_t dtpos; /* legacy OS/2 style position */ ··· 3033 3033 int overflow, fix_page, page_fixed = 0; 3034 3034 static int unique_pos = 2; /* If we can't fix broken index */ 3035 3035 3036 - if (filp->f_pos == DIREND) 3036 + if (ctx->pos == DIREND) 3037 3037 return 0; 3038 3038 3039 3039 if (DO_INDEX(ip)) { ··· 3045 3045 */ 3046 3046 do_index = 1; 3047 3047 3048 - dir_index = (u32) filp->f_pos; 3048 + dir_index = (u32) ctx->pos; 3049 3049 3050 3050 if (dir_index > 1) { 3051 3051 struct dir_table_slot dirtab_slot; ··· 3053 3053 if (dtEmpty(ip) || 3054 3054 (dir_index >= JFS_IP(ip)->next_index)) { 3055 3055 /* Stale position. Directory has shrunk */ 3056 - filp->f_pos = DIREND; 3056 + ctx->pos = DIREND; 3057 3057 return 0; 3058 3058 } 3059 3059 repeat: 3060 3060 rc = read_index(ip, dir_index, &dirtab_slot); 3061 3061 if (rc) { 3062 - filp->f_pos = DIREND; 3062 + ctx->pos = DIREND; 3063 3063 return rc; 3064 3064 } 3065 3065 if (dirtab_slot.flag == DIR_INDEX_FREE) { 3066 3066 if (loop_count++ > JFS_IP(ip)->next_index) { 3067 3067 jfs_err("jfs_readdir detected " 3068 3068 "infinite loop!"); 3069 - filp->f_pos = DIREND; 3069 + ctx->pos = DIREND; 3070 3070 return 0; 3071 3071 } 3072 3072 dir_index = le32_to_cpu(dirtab_slot.addr2); 3073 3073 if (dir_index == -1) { 3074 - filp->f_pos = DIREND; 3074 + ctx->pos = DIREND; 3075 3075 return 0; 3076 3076 } 3077 3077 goto repeat; ··· 3080 3080 index = dirtab_slot.slot; 3081 3081 DT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 3082 3082 if (rc) { 3083 - filp->f_pos = DIREND; 3083 + ctx->pos = DIREND; 3084 3084 return 0; 3085 3085 } 3086 3086 if (p->header.flag & BT_INTERNAL) { 3087 3087 jfs_err("jfs_readdir: bad index table"); 3088 3088 DT_PUTPAGE(mp); 3089 - filp->f_pos = -1; 3089 + ctx->pos = -1; 3090 3090 return 0; 3091 3091 } 3092 3092 } else { ··· 3094 3094 /* 3095 3095 * self "." 3096 3096 */ 3097 - filp->f_pos = 0; 3098 - if (filldir(dirent, ".", 1, 0, ip->i_ino, 3099 - DT_DIR)) 3097 + ctx->pos = 0; 3098 + if (!dir_emit(ctx, ".", 1, ip->i_ino, DT_DIR)) 3100 3099 return 0; 3101 3100 } 3102 3101 /* 3103 3102 * parent ".." 3104 3103 */ 3105 - filp->f_pos = 1; 3106 - if (filldir(dirent, "..", 2, 1, PARENT(ip), DT_DIR)) 3104 + ctx->pos = 1; 3105 + if (!dir_emit(ctx, "..", 2, PARENT(ip), DT_DIR)) 3107 3106 return 0; 3108 3107 3109 3108 /* 3110 3109 * Find first entry of left-most leaf 3111 3110 */ 3112 3111 if (dtEmpty(ip)) { 3113 - filp->f_pos = DIREND; 3112 + ctx->pos = DIREND; 3114 3113 return 0; 3115 3114 } 3116 3115 ··· 3127 3128 * pn > 0: Real entries, pn=1 -> leftmost page 3128 3129 * pn = index = -1: No more entries 3129 3130 */ 3130 - dtpos = filp->f_pos; 3131 + dtpos = ctx->pos; 3131 3132 if (dtpos == 0) { 3132 3133 /* build "." entry */ 3133 - 3134 - if (filldir(dirent, ".", 1, filp->f_pos, ip->i_ino, 3135 - DT_DIR)) 3134 + if (!dir_emit(ctx, ".", 1, ip->i_ino, DT_DIR)) 3136 3135 return 0; 3137 3136 dtoffset->index = 1; 3138 - filp->f_pos = dtpos; 3137 + ctx->pos = dtpos; 3139 3138 } 3140 3139 3141 3140 if (dtoffset->pn == 0) { 3142 3141 if (dtoffset->index == 1) { 3143 3142 /* build ".." entry */ 3144 - 3145 - if (filldir(dirent, "..", 2, filp->f_pos, 3146 - PARENT(ip), DT_DIR)) 3143 + if (!dir_emit(ctx, "..", 2, PARENT(ip), DT_DIR)) 3147 3144 return 0; 3148 3145 } else { 3149 3146 jfs_err("jfs_readdir called with " ··· 3147 3152 } 3148 3153 dtoffset->pn = 1; 3149 3154 dtoffset->index = 0; 3150 - filp->f_pos = dtpos; 3155 + ctx->pos = dtpos; 3151 3156 } 3152 3157 3153 3158 if (dtEmpty(ip)) { 3154 - filp->f_pos = DIREND; 3159 + ctx->pos = DIREND; 3155 3160 return 0; 3156 3161 } 3157 3162 3158 - if ((rc = dtReadNext(ip, &filp->f_pos, &btstack))) { 3163 + if ((rc = dtReadNext(ip, &ctx->pos, &btstack))) { 3159 3164 jfs_err("jfs_readdir: unexpected rc = %d " 3160 3165 "from dtReadNext", rc); 3161 - filp->f_pos = DIREND; 3166 + ctx->pos = DIREND; 3162 3167 return 0; 3163 3168 } 3164 3169 /* get start leaf page and index */ ··· 3166 3171 3167 3172 /* offset beyond directory eof ? */ 3168 3173 if (bn < 0) { 3169 - filp->f_pos = DIREND; 3174 + ctx->pos = DIREND; 3170 3175 return 0; 3171 3176 } 3172 3177 } ··· 3175 3180 if (dirent_buf == 0) { 3176 3181 DT_PUTPAGE(mp); 3177 3182 jfs_warn("jfs_readdir: __get_free_page failed!"); 3178 - filp->f_pos = DIREND; 3183 + ctx->pos = DIREND; 3179 3184 return -ENOMEM; 3180 3185 } 3181 3186 ··· 3290 3295 3291 3296 jfs_dirent = (struct jfs_dirent *) dirent_buf; 3292 3297 while (jfs_dirents--) { 3293 - filp->f_pos = jfs_dirent->position; 3294 - if (filldir(dirent, jfs_dirent->name, 3295 - jfs_dirent->name_len, filp->f_pos, 3298 + ctx->pos = jfs_dirent->position; 3299 + if (!dir_emit(ctx, jfs_dirent->name, 3300 + jfs_dirent->name_len, 3296 3301 jfs_dirent->ino, DT_UNKNOWN)) 3297 3302 goto out; 3298 3303 jfs_dirent = next_jfs_dirent(jfs_dirent); ··· 3304 3309 } 3305 3310 3306 3311 if (!overflow && (bn == 0)) { 3307 - filp->f_pos = DIREND; 3312 + ctx->pos = DIREND; 3308 3313 break; 3309 3314 } 3310 3315
+1 -1
fs/jfs/jfs_dtree.h
··· 265 265 extern int dtModify(tid_t tid, struct inode *ip, struct component_name * key, 266 266 ino_t * orig_ino, ino_t new_ino, int flag); 267 267 268 - extern int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir); 268 + extern int jfs_readdir(struct file *file, struct dir_context *ctx); 269 269 #endif /* !_H_JFS_DTREE */
+1 -1
fs/jfs/namei.c
··· 1529 1529 1530 1530 const struct file_operations jfs_dir_operations = { 1531 1531 .read = generic_read_dir, 1532 - .readdir = jfs_readdir, 1532 + .iterate = jfs_readdir, 1533 1533 .fsync = jfs_fsync, 1534 1534 .unlocked_ioctl = jfs_ioctl, 1535 1535 #ifdef CONFIG_COMPAT